summaryrefslogtreecommitdiff
path: root/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test8
diff options
context:
space:
mode:
Diffstat (limited to 'src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test8')
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test8/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test8/VirtualAlloc.c48
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test8/testinfo.dat13
3 files changed, 80 insertions, 0 deletions
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test8/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test8/CMakeLists.txt
new file mode 100644
index 0000000000..584a0c505a
--- /dev/null
+++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test8/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ VirtualAlloc.c
+)
+
+add_executable(paltest_virtualalloc_test8
+ ${SOURCES}
+)
+
+add_dependencies(paltest_virtualalloc_test8 coreclrpal)
+
+target_link_libraries(paltest_virtualalloc_test8
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test8/VirtualAlloc.c b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test8/VirtualAlloc.c
new file mode 100644
index 0000000000..d548e0c8db
--- /dev/null
+++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test8/VirtualAlloc.c
@@ -0,0 +1,48 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+/*=============================================================
+**
+** Source: virtualalloc.c
+**
+** Purpose: Positive test the VirtualAlloc API.
+** Call VirtualAlloc with MEM_RESERVE allocation type
+** and PAGE_READWRITE access protection
+
+**
+**============================================================*/
+#include <palsuite.h>
+
+int __cdecl main(int argc, char *argv[])
+{
+ int err;
+ LPVOID lpVirtualAddress;
+
+ //Initialize the PAL environment
+ err = PAL_Initialize(argc, argv);
+ if(0 != err)
+ {
+ ExitProcess(FAIL);
+ }
+
+ //Allocate the physical storage in memory or in the paging file on disk
+ lpVirtualAddress = VirtualAlloc(NULL,//system determine where to allocate the region
+ 1024, //specify the size
+ MEM_RESERVE, //allocation type
+ PAGE_READWRITE); //access protection
+ if(NULL == lpVirtualAddress)
+ {
+ Fail("\nFailed to call VirtualAlloc API!\n");
+ }
+
+ //decommit the specified region
+ err = VirtualFree(lpVirtualAddress,1024,MEM_DECOMMIT);
+ if(0 == err)
+ {
+ Fail("\nFailed to call VirtualFree API!\n");
+ }
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test8/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test8/testinfo.dat
new file mode 100644
index 0000000000..c0ee6b6a69
--- /dev/null
+++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test8/testinfo.dat
@@ -0,0 +1,13 @@
+# Licensed to the .NET Foundation under one or more agreements.
+# The .NET Foundation licenses this file to you under the MIT license.
+# See the LICENSE file in the project root for more information.
+
+Version = 1.0
+Section = Filemapping_memmgt
+Function = VirtualAlloc
+Name = Positive test for VirtualAlloc API
+TYPE = DEFAULT
+EXE1 = virtualalloc
+Description
+=Test the VirtualAlloc with MEM_RESERVE allocation type
+=and PAGE_READWRITE access protection