From 4b4aad7217d3292650e77eec2cf4c198ea9c3b4b Mon Sep 17 00:00:00 2001 From: Jiyoung Yun Date: Wed, 23 Nov 2016 19:09:09 +0900 Subject: Imported Upstream version 1.1.0 --- .../HeapAlloc/test3/CMakeLists.txt | 19 +++++++ .../filemapping_memmgt/HeapAlloc/test3/HeapAlloc.c | 62 ++++++++++++++++++++++ .../HeapAlloc/test3/testinfo.dat | 12 +++++ 3 files changed, 93 insertions(+) create mode 100644 src/pal/tests/palsuite/filemapping_memmgt/HeapAlloc/test3/CMakeLists.txt create mode 100644 src/pal/tests/palsuite/filemapping_memmgt/HeapAlloc/test3/HeapAlloc.c create mode 100644 src/pal/tests/palsuite/filemapping_memmgt/HeapAlloc/test3/testinfo.dat (limited to 'src/pal/tests/palsuite/filemapping_memmgt/HeapAlloc/test3') diff --git a/src/pal/tests/palsuite/filemapping_memmgt/HeapAlloc/test3/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/HeapAlloc/test3/CMakeLists.txt new file mode 100644 index 0000000000..f0b89461d2 --- /dev/null +++ b/src/pal/tests/palsuite/filemapping_memmgt/HeapAlloc/test3/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(SOURCES + HeapAlloc.c +) + +add_executable(paltest_heapalloc_test3 + ${SOURCES} +) + +add_dependencies(paltest_heapalloc_test3 coreclrpal) + +target_link_libraries(paltest_heapalloc_test3 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/HeapAlloc/test3/HeapAlloc.c b/src/pal/tests/palsuite/filemapping_memmgt/HeapAlloc/test3/HeapAlloc.c new file mode 100644 index 0000000000..4a74fe8194 --- /dev/null +++ b/src/pal/tests/palsuite/filemapping_memmgt/HeapAlloc/test3/HeapAlloc.c @@ -0,0 +1,62 @@ +// 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: heapalloc.c +** +** Purpose: Positive test the HeapAlloc API. +** Call HeapAlloc asking for zero bytes +** with HEAP_ZERO_MEMORY control flag +** +** +**============================================================*/ +#include + +#define HEAPSIZE 0 + +int __cdecl main(int argc, char *argv[]) +{ + int err; + HANDLE ProcessHeapHandle; + LPVOID lpHeap; + + + //Initialize the PAL environment + err = PAL_Initialize(argc, argv); + if(0 != err) + { + ExitProcess(FAIL); + } + + //Retrieve the calling process heap handle + ProcessHeapHandle = GetProcessHeap(); + + if(!ProcessHeapHandle) + { + Fail("\nFailed to call GetProcessHeap API!\n"); + } + + lpHeap = HeapAlloc(ProcessHeapHandle,//HeapHandle + HEAP_ZERO_MEMORY,//control flag + HEAPSIZE); //specify the heap size + + //lpHeap should be non-NULL pointer + if(NULL == lpHeap) + { + Fail("Failed to call HeapAlloc API, when number of bytes to be allocated is zero!\n"); + } + + //free the heap memory + err = HeapFree(ProcessHeapHandle, + 0, + lpHeap); + if(0 == err) + { + Fail("Failed to call HeapFree API!\n"); + } + + PAL_Terminate(); + return PASS; +} diff --git a/src/pal/tests/palsuite/filemapping_memmgt/HeapAlloc/test3/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/HeapAlloc/test3/testinfo.dat new file mode 100644 index 0000000000..c7d67d3b4f --- /dev/null +++ b/src/pal/tests/palsuite/filemapping_memmgt/HeapAlloc/test3/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 = HeapAlloc +Name = Positive test for HeapAlloc API +TYPE = DEFAULT +EXE1 = heapalloc +Description +=Test the HeapAlloc asking for zero bytes with HEAP_ZERO_MEMORY control flag -- cgit v1.2.3