diff options
Diffstat (limited to 'src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc')
64 files changed, 1728 insertions, 0 deletions
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/CMakeLists.txt new file mode 100644 index 0000000000..eafaa66856 --- /dev/null +++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/CMakeLists.txt @@ -0,0 +1,24 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +add_subdirectory(test1) +add_subdirectory(test10) +add_subdirectory(test11) +add_subdirectory(test12) +add_subdirectory(test13) +add_subdirectory(test14) +add_subdirectory(test15) +add_subdirectory(test16) +add_subdirectory(test17) +add_subdirectory(test18) +add_subdirectory(test19) +add_subdirectory(test2) +add_subdirectory(test20) +add_subdirectory(test21) +add_subdirectory(test3) +add_subdirectory(test4) +add_subdirectory(test5) +add_subdirectory(test6) +add_subdirectory(test7) +add_subdirectory(test8) +add_subdirectory(test9) + diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test1/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test1/CMakeLists.txt new file mode 100644 index 0000000000..90ba41bd79 --- /dev/null +++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test1/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_test1 + ${SOURCES} +) + +add_dependencies(paltest_virtualalloc_test1 coreclrpal) + +target_link_libraries(paltest_virtualalloc_test1 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test1/VirtualAlloc.c b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test1/VirtualAlloc.c new file mode 100644 index 0000000000..26ee942ba1 --- /dev/null +++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test1/VirtualAlloc.c @@ -0,0 +1,50 @@ +// 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_COMMIT allocation type +** and PAGE_READONLY 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_COMMIT, //allocation type + PAGE_READONLY); //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/test1/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test1/testinfo.dat new file mode 100644 index 0000000000..5b8311a05d --- /dev/null +++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test1/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_COMMIT allocation type +=and PAGE_READONLY access protection diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test10/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test10/CMakeLists.txt new file mode 100644 index 0000000000..51b0e1d92e --- /dev/null +++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test10/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_test10 + ${SOURCES} +) + +add_dependencies(paltest_virtualalloc_test10 coreclrpal) + +target_link_libraries(paltest_virtualalloc_test10 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test10/VirtualAlloc.c b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test10/VirtualAlloc.c new file mode 100644 index 0000000000..ac06b9b5c8 --- /dev/null +++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test10/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_EXECUTE_READ 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_EXECUTE_READ); //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/test10/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test10/testinfo.dat new file mode 100644 index 0000000000..960f2265d5 --- /dev/null +++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test10/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_EXECUTE_READ access protection diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test11/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test11/CMakeLists.txt new file mode 100644 index 0000000000..adff47087b --- /dev/null +++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test11/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_test11 + ${SOURCES} +) + +add_dependencies(paltest_virtualalloc_test11 coreclrpal) + +target_link_libraries(paltest_virtualalloc_test11 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test11/VirtualAlloc.c b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test11/VirtualAlloc.c new file mode 100644 index 0000000000..a3df39b634 --- /dev/null +++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test11/VirtualAlloc.c @@ -0,0 +1,49 @@ +// 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_READONLY 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_EXECUTE_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/test11/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test11/testinfo.dat new file mode 100644 index 0000000000..5d9f0ad880 --- /dev/null +++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test11/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_EXECUTE_READWRITE access protection diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test12/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test12/CMakeLists.txt new file mode 100644 index 0000000000..26f303573e --- /dev/null +++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test12/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_test12 + ${SOURCES} +) + +add_dependencies(paltest_virtualalloc_test12 coreclrpal) + +target_link_libraries(paltest_virtualalloc_test12 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test12/VirtualAlloc.c b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test12/VirtualAlloc.c new file mode 100644 index 0000000000..8b3508635f --- /dev/null +++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test12/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_NOACCESS 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_NOACCESS); //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/test12/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test12/testinfo.dat new file mode 100644 index 0000000000..ac2b91c0dc --- /dev/null +++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test12/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_COMMIT allocation type +=and PAGE_NOACCESS access protection diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test13/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test13/CMakeLists.txt new file mode 100644 index 0000000000..f85cbdc694 --- /dev/null +++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test13/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_test13 + ${SOURCES} +) + +add_dependencies(paltest_virtualalloc_test13 coreclrpal) + +target_link_libraries(paltest_virtualalloc_test13 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test13/VirtualAlloc.c b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test13/VirtualAlloc.c new file mode 100644 index 0000000000..d2109c0339 --- /dev/null +++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test13/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_COMMIT|MEM_TOP_DOWN allocation type +** and PAGE_READONLY 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_COMMIT|MEM_TOP_DOWN, //allocation type + PAGE_READONLY); //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/test13/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test13/testinfo.dat new file mode 100644 index 0000000000..a571e9f8d2 --- /dev/null +++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test13/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_COMMIT|MEM_TOP_DOWN allocation type +=and PAGE_READONLY access protection diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test14/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test14/CMakeLists.txt new file mode 100644 index 0000000000..41ed0ca208 --- /dev/null +++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test14/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_test14 + ${SOURCES} +) + +add_dependencies(paltest_virtualalloc_test14 coreclrpal) + +target_link_libraries(paltest_virtualalloc_test14 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test14/VirtualAlloc.c b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test14/VirtualAlloc.c new file mode 100644 index 0000000000..49bd21875e --- /dev/null +++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test14/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_COMMIT|MEM_TOP_DOWN 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_COMMIT|MEM_TOP_DOWN, //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/test14/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test14/testinfo.dat new file mode 100644 index 0000000000..60decb8461 --- /dev/null +++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test14/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_COMMIT|MEM_TOP_DOWN allocation type +=and PAGE_READWRITE access protection diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test15/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test15/CMakeLists.txt new file mode 100644 index 0000000000..87b29108b2 --- /dev/null +++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test15/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_test15 + ${SOURCES} +) + +add_dependencies(paltest_virtualalloc_test15 coreclrpal) + +target_link_libraries(paltest_virtualalloc_test15 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test15/VirtualAlloc.c b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test15/VirtualAlloc.c new file mode 100644 index 0000000000..3cf1502f26 --- /dev/null +++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test15/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_COMMIT|MEM_TOP_DOWN allocation type +** and PAGE_EXECUTE 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_COMMIT|MEM_TOP_DOWN, //allocation type + PAGE_EXECUTE); //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/test15/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test15/testinfo.dat new file mode 100644 index 0000000000..2d9845ded6 --- /dev/null +++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test15/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_COMMIT|MEM_TOP_DOWN allocation type +=and PAGE_EXECUTE access protection diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test16/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test16/CMakeLists.txt new file mode 100644 index 0000000000..90e3f3bdb2 --- /dev/null +++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test16/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_test16 + ${SOURCES} +) + +add_dependencies(paltest_virtualalloc_test16 coreclrpal) + +target_link_libraries(paltest_virtualalloc_test16 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test16/VirtualAlloc.c b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test16/VirtualAlloc.c new file mode 100644 index 0000000000..ce61b9aa39 --- /dev/null +++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test16/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_COMMIT|MEM_TOP_DOWN allocation type +** and PAGE_EXECUTE_READ 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_COMMIT|MEM_TOP_DOWN, //allocation type + PAGE_EXECUTE_READ); //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/test16/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test16/testinfo.dat new file mode 100644 index 0000000000..1389f1f92e --- /dev/null +++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test16/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_COMMIT|MEM_TOP_DOWN allocation type +=and PAGE_EXECUTE_READ access protection diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test17/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test17/CMakeLists.txt new file mode 100644 index 0000000000..461b48ccc0 --- /dev/null +++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test17/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_test17 + ${SOURCES} +) + +add_dependencies(paltest_virtualalloc_test17 coreclrpal) + +target_link_libraries(paltest_virtualalloc_test17 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test17/VirtualAlloc.c b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test17/VirtualAlloc.c new file mode 100644 index 0000000000..eb609f14e4 --- /dev/null +++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test17/VirtualAlloc.c @@ -0,0 +1,49 @@ +// 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_COMMIT|MEM_TOP_DOWN allocation type +** and PAGE_READONLY 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_COMMIT|MEM_TOP_DOWN, //allocation type + PAGE_EXECUTE_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/test17/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test17/testinfo.dat new file mode 100644 index 0000000000..49ced63836 --- /dev/null +++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test17/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_COMMIT|MEM_TOP_DOWN allocation type +=and PAGE_EXECUTE_READWRITE access protection diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test18/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test18/CMakeLists.txt new file mode 100644 index 0000000000..69823be14b --- /dev/null +++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test18/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_test18 + ${SOURCES} +) + +add_dependencies(paltest_virtualalloc_test18 coreclrpal) + +target_link_libraries(paltest_virtualalloc_test18 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test18/VirtualAlloc.c b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test18/VirtualAlloc.c new file mode 100644 index 0000000000..e46da851db --- /dev/null +++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test18/VirtualAlloc.c @@ -0,0 +1,49 @@ +// 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_COMMIT|MEM_TOP_DOWN allocation type +** and PAGE_NOACCESS 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_COMMIT|MEM_TOP_DOWN, //allocation type + PAGE_NOACCESS); //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/test18/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test18/testinfo.dat new file mode 100644 index 0000000000..1fd4ac6f14 --- /dev/null +++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test18/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_COMMIT|MEM_TOP_DOWN allocation type +=and PAGE_NOACCESS access protection diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test19/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test19/CMakeLists.txt new file mode 100644 index 0000000000..fa65b4fa46 --- /dev/null +++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test19/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_test19 + ${SOURCES} +) + +add_dependencies(paltest_virtualalloc_test19 coreclrpal) + +target_link_libraries(paltest_virtualalloc_test19 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test19/VirtualAlloc.c b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test19/VirtualAlloc.c new file mode 100644 index 0000000000..5cbe48b15e --- /dev/null +++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test19/VirtualAlloc.c @@ -0,0 +1,51 @@ +// 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 to reserve and commit +** simultaneously with MEM_COMMIT|MEM_RESERVE|MEM_TOP_DOWN +** allocation type and PAGE_READONLY 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); + } + + //reserve and commit simultaneously by using MEM_COMMIT|MEM_RESERVE + lpVirtualAddress = VirtualAlloc(NULL,//system determine where to allocate the region + 1024, //specify the size + MEM_COMMIT|MEM_RESERVE|MEM_TOP_DOWN, //allocation type + PAGE_READONLY); //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/test19/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test19/testinfo.dat new file mode 100644 index 0000000000..6e427da15a --- /dev/null +++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test19/testinfo.dat @@ -0,0 +1,14 @@ +# 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 to reserve and commit +=simultaneously by using MEM_COMMIT|MEM_RESERVE|MEM_TOP_DOWN +=allocation type and PAGE_READONLY access protection diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test2/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test2/CMakeLists.txt new file mode 100644 index 0000000000..1753b1edc5 --- /dev/null +++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test2/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_test2 + ${SOURCES} +) + +add_dependencies(paltest_virtualalloc_test2 coreclrpal) + +target_link_libraries(paltest_virtualalloc_test2 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test2/VirtualAlloc.c b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test2/VirtualAlloc.c new file mode 100644 index 0000000000..99cf76a523 --- /dev/null +++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test2/VirtualAlloc.c @@ -0,0 +1,49 @@ +// 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_COMMIT 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_COMMIT, //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/test2/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test2/testinfo.dat new file mode 100644 index 0000000000..c7d8b6783d --- /dev/null +++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test2/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_COMMIT allocation type +=and PAGE_READWRITE access protection diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test20/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test20/CMakeLists.txt new file mode 100644 index 0000000000..2c55071149 --- /dev/null +++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test20/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_test20 + ${SOURCES} +) + +add_dependencies(paltest_virtualalloc_test20 coreclrpal) + +target_link_libraries(paltest_virtualalloc_test20 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test20/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test20/testinfo.dat new file mode 100644 index 0000000000..6010a18c8a --- /dev/null +++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test20/testinfo.dat @@ -0,0 +1,12 @@ +# 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 VirtualAlloc to ensure that re-committed memory is not changed. diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test20/virtualalloc.c b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test20/virtualalloc.c new file mode 100644 index 0000000000..7aec3c7f55 --- /dev/null +++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test20/virtualalloc.c @@ -0,0 +1,50 @@ +// 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. +** Ensure that memory re-committed through VirtualAlloc +** is not changed. +** +** +**============================================================*/ +#include <palsuite.h> + +int __cdecl main(int argc, char *argv[]) +{ + int err; + int *ptr; + + //Initialize the PAL environment + err = PAL_Initialize(argc, argv); + if(0 != err) + { + ExitProcess(FAIL); + } + + ptr = (int *) VirtualAlloc(NULL, 4096, MEM_COMMIT | MEM_RESERVE, + PAGE_READWRITE); + if (ptr == NULL) + { + Fail("First VirtualAlloc failed!\n"); + } + + *ptr = 123; + + ptr = (int *) VirtualAlloc(ptr, 4096, MEM_COMMIT, PAGE_READWRITE); + if (ptr == NULL) + { + Fail("Second VirtualAlloc failed!\n"); + } + if (*ptr != 123) + { + Fail("VirtualAlloc modified (probably zeroed) re-committed memory!\n"); + } + + PAL_Terminate(); + return PASS; +} diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test21/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test21/CMakeLists.txt new file mode 100644 index 0000000000..f97c32af75 --- /dev/null +++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test21/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_test21 + ${SOURCES} +) + +add_dependencies(paltest_virtualalloc_test21 coreclrpal) + +target_link_libraries(paltest_virtualalloc_test21 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test21/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test21/testinfo.dat new file mode 100644 index 0000000000..c32d352d19 --- /dev/null +++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test21/testinfo.dat @@ -0,0 +1,12 @@ +# 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 VirtualAlloc to ensure that freed memory that is committed again is zeroed. diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test21/virtualalloc.c b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test21/virtualalloc.c new file mode 100644 index 0000000000..065a2ff5c8 --- /dev/null +++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test21/virtualalloc.c @@ -0,0 +1,54 @@ +// 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. +** Ensure that memory committed through VirtualAlloc, +** then freed, then committed again is zeroed. +** +** +**============================================================*/ +#include <palsuite.h> + +int __cdecl main(int argc, char *argv[]) +{ + int err; + int *ptr; + + //Initialize the PAL environment + err = PAL_Initialize(argc, argv); + if(0 != err) + { + ExitProcess(FAIL); + } + + ptr = (int *) VirtualAlloc(NULL, 4096, MEM_COMMIT | MEM_RESERVE, + PAGE_READWRITE); + if (ptr == NULL) + { + Fail("First VirtualAlloc failed!\n"); + } + *ptr = 123; + + if (!VirtualFree(ptr, 4096, MEM_DECOMMIT)) + { + Fail("VirtualFree failed!\n"); + } + + ptr = (int *) VirtualAlloc(ptr, 4096, MEM_COMMIT, PAGE_READWRITE); + if (ptr == NULL) + { + Fail("Second VirtualAlloc failed!\n"); + } + if (*ptr != 0) + { + Fail("VirtualAlloc failed to zero its memory!\n"); + } + + PAL_Terminate(); + return PASS; +} diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test3/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test3/CMakeLists.txt new file mode 100644 index 0000000000..035594bd79 --- /dev/null +++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test3/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_test3 + ${SOURCES} +) + +add_dependencies(paltest_virtualalloc_test3 coreclrpal) + +target_link_libraries(paltest_virtualalloc_test3 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test3/VirtualAlloc.c b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test3/VirtualAlloc.c new file mode 100644 index 0000000000..5c57ec337f --- /dev/null +++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test3/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_COMMIT allocation type +** and PAGE_EXECUTE 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_COMMIT, //allocation type + PAGE_EXECUTE); //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/test3/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test3/testinfo.dat new file mode 100644 index 0000000000..a3d5401493 --- /dev/null +++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test3/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_COMMIT allocation type +=and PAGE_EXECUTE access protection diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test4/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test4/CMakeLists.txt new file mode 100644 index 0000000000..5ce80bf52f --- /dev/null +++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test4/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_test4 + ${SOURCES} +) + +add_dependencies(paltest_virtualalloc_test4 coreclrpal) + +target_link_libraries(paltest_virtualalloc_test4 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test4/VirtualAlloc.c b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test4/VirtualAlloc.c new file mode 100644 index 0000000000..c134a14eb1 --- /dev/null +++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test4/VirtualAlloc.c @@ -0,0 +1,49 @@ +// 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_COMMIT allocation type +** and PAGE_EXECUTE_READ 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_COMMIT, //allocation type + PAGE_EXECUTE_READ); //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/test4/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test4/testinfo.dat new file mode 100644 index 0000000000..0e84e7a3ba --- /dev/null +++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test4/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_COMMIT allocation type +=and PAGE_EXECUTE_READ access protection diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test5/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test5/CMakeLists.txt new file mode 100644 index 0000000000..138d9c9727 --- /dev/null +++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test5/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_test5 + ${SOURCES} +) + +add_dependencies(paltest_virtualalloc_test5 coreclrpal) + +target_link_libraries(paltest_virtualalloc_test5 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test5/VirtualAlloc.c b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test5/VirtualAlloc.c new file mode 100644 index 0000000000..8c4f9dcdb6 --- /dev/null +++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test5/VirtualAlloc.c @@ -0,0 +1,50 @@ +// 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_COMMIT allocation type +** and PAGE_READONLY 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_COMMIT, //allocation type + PAGE_EXECUTE_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/test5/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test5/testinfo.dat new file mode 100644 index 0000000000..332b88b071 --- /dev/null +++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test5/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_COMMIT allocation type +=and PAGE_EXECUTE_READWRITE access protection diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test6/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test6/CMakeLists.txt new file mode 100644 index 0000000000..c61add9db4 --- /dev/null +++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test6/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_test6 + ${SOURCES} +) + +add_dependencies(paltest_virtualalloc_test6 coreclrpal) + +target_link_libraries(paltest_virtualalloc_test6 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test6/VirtualAlloc.c b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test6/VirtualAlloc.c new file mode 100644 index 0000000000..e9c33d86df --- /dev/null +++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test6/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_COMMIT allocation type +** and PAGE_NOACCESS 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_COMMIT, //allocation type + PAGE_NOACCESS); //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/test6/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test6/testinfo.dat new file mode 100644 index 0000000000..ac2b91c0dc --- /dev/null +++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test6/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_COMMIT allocation type +=and PAGE_NOACCESS access protection diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test7/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test7/CMakeLists.txt new file mode 100644 index 0000000000..b5452a0c48 --- /dev/null +++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test7/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_test7 + ${SOURCES} +) + +add_dependencies(paltest_virtualalloc_test7 coreclrpal) + +target_link_libraries(paltest_virtualalloc_test7 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test7/VirtualAlloc.c b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test7/VirtualAlloc.c new file mode 100644 index 0000000000..bee2735c9f --- /dev/null +++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test7/VirtualAlloc.c @@ -0,0 +1,53 @@ +// 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_READONLY 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_READONLY); //access protection + if(NULL == lpVirtualAddress) + { + Fail("\nFailed to call VirtualAlloc API!\n"); + PAL_Terminate(); + return 1; + } + + //decommit the specified region + err = VirtualFree(lpVirtualAddress,1024,MEM_DECOMMIT); + if(0 == err) + { + Fail("\nFailed to call VirtualFree API!\n"); + PAL_Terminate(); + return 1; + } + + + PAL_Terminate(); + return PASS; +} diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test7/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test7/testinfo.dat new file mode 100644 index 0000000000..2edcb56d3b --- /dev/null +++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test7/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_READONLY access protection 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 diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test9/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test9/CMakeLists.txt new file mode 100644 index 0000000000..aee950b2e4 --- /dev/null +++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test9/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_test9 + ${SOURCES} +) + +add_dependencies(paltest_virtualalloc_test9 coreclrpal) + +target_link_libraries(paltest_virtualalloc_test9 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test9/VirtualAlloc.c b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test9/VirtualAlloc.c new file mode 100644 index 0000000000..2711addacc --- /dev/null +++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test9/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_EXECUTE 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_EXECUTE); //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/test9/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test9/testinfo.dat new file mode 100644 index 0000000000..1e83744bba --- /dev/null +++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test9/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_EXECUTE access protection |