summaryrefslogtreecommitdiff
path: root/src/pal/tests/palsuite/filemapping_memmgt/LocalAlloc
diff options
context:
space:
mode:
Diffstat (limited to 'src/pal/tests/palsuite/filemapping_memmgt/LocalAlloc')
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/LocalAlloc/CMakeLists.txt4
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/LocalAlloc/test1/CMakeLists.txt20
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/LocalAlloc/test1/LocalAlloc.c50
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/LocalAlloc/test1/testinfo.dat12
4 files changed, 86 insertions, 0 deletions
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/LocalAlloc/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/LocalAlloc/CMakeLists.txt
new file mode 100644
index 0000000000..f6aa0cb2d9
--- /dev/null
+++ b/src/pal/tests/palsuite/filemapping_memmgt/LocalAlloc/CMakeLists.txt
@@ -0,0 +1,4 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+add_subdirectory(test1)
+
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/LocalAlloc/test1/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/LocalAlloc/test1/CMakeLists.txt
new file mode 100644
index 0000000000..163d49085e
--- /dev/null
+++ b/src/pal/tests/palsuite/filemapping_memmgt/LocalAlloc/test1/CMakeLists.txt
@@ -0,0 +1,20 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ LocalAlloc.c
+)
+
+add_executable(paltest_localalloc_test1
+ ${SOURCES}
+)
+
+add_dependencies(paltest_localalloc_test1 CoreClrPal)
+
+target_link_libraries(paltest_localalloc_test1
+ pthread
+ rt
+ m
+ CoreClrPal
+)
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/LocalAlloc/test1/LocalAlloc.c b/src/pal/tests/palsuite/filemapping_memmgt/LocalAlloc/test1/LocalAlloc.c
new file mode 100644
index 0000000000..a3472cf845
--- /dev/null
+++ b/src/pal/tests/palsuite/filemapping_memmgt/LocalAlloc/test1/LocalAlloc.c
@@ -0,0 +1,50 @@
+//
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+/*=============================================================
+**
+** Source: LocalAlloc.c
+**
+** Purpose: Positive test the LocalAlloc API.
+** Call LocalAlloc with zero as the allocation attribute
+**
+**
+**============================================================*/
+#include <palsuite.h>
+
+int __cdecl main(int argc, char *argv[])
+{
+ HLOCAL LocalHeap;
+ HLOCAL FreeHeap;
+ int err;
+ const SIZE_T heapSize = 64;
+
+ /*Initialize the PAL environment*/
+ err = PAL_Initialize(argc, argv);
+ if(0 != err)
+ {
+ return FAIL;
+ }
+
+ /*Allocate the specified number of bytes from the heap*/
+ /*with allocation attribute: zero which is required by PAL Doc*/
+ LocalHeap = LocalAlloc(0, heapSize);
+ if(!LocalHeap)
+ {
+ Fail("\nFailed to call LocalAlloc API, "
+ "error code=%u\n", GetLastError());
+ }
+
+ /*Free the allocated local heap memory*/
+ FreeHeap = LocalFree(LocalHeap);
+ if(FreeHeap)
+ {
+ Fail("Failed to call LocalFree API, "
+ "error code=%u\n", GetLastError());
+ }
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/LocalAlloc/test1/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/LocalAlloc/test1/testinfo.dat
new file mode 100644
index 0000000000..a2f422380f
--- /dev/null
+++ b/src/pal/tests/palsuite/filemapping_memmgt/LocalAlloc/test1/testinfo.dat
@@ -0,0 +1,12 @@
+#
+# Copyright (c) Microsoft Corporation. All rights reserved.
+#
+
+Version = 1.0
+Section = Filemapping_memmgt
+Function = LocalAlloc
+Name = Positive test LocalAlloc API to Allocate the specified number of bytes from the heap
+TYPE = DEFAULT
+EXE1 = localalloc
+Description
+=Test the LocalAlloc with zero ad allocation attribute