summaryrefslogtreecommitdiff
path: root/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc
diff options
context:
space:
mode:
Diffstat (limited to 'src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc')
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/CMakeLists.txt8
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test1/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test1/test1.c72
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test1/testinfo.dat14
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test2/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test2/test2.c79
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test2/testinfo.dat15
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test3/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test3/test3.c78
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test3/testinfo.dat16
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test4/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test4/test4.c80
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test4/testinfo.dat15
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test5/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test5/test5.c69
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test5/testinfo.dat15
16 files changed, 556 insertions, 0 deletions
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/CMakeLists.txt
new file mode 100644
index 0000000000..8083faf655
--- /dev/null
+++ b/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/CMakeLists.txt
@@ -0,0 +1,8 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+add_subdirectory(test1)
+add_subdirectory(test2)
+add_subdirectory(test3)
+add_subdirectory(test4)
+add_subdirectory(test5)
+
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test1/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test1/CMakeLists.txt
new file mode 100644
index 0000000000..1decb02c73
--- /dev/null
+++ b/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test1/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ test1.c
+)
+
+add_executable(paltest_heaprealloc_test1
+ ${SOURCES}
+)
+
+add_dependencies(paltest_heaprealloc_test1 coreclrpal)
+
+target_link_libraries(paltest_heaprealloc_test1
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test1/test1.c b/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test1/test1.c
new file mode 100644
index 0000000000..497d208eca
--- /dev/null
+++ b/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test1/test1.c
@@ -0,0 +1,72 @@
+// 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: test1.c
+**
+** Purpose: Allocate some memory. Then reallocate that memory. Ensure the
+** return values are correct, and also that data placed in the allocated
+** memory carries over to the reallocated block.
+**
+**
+**============================================================*/
+
+#include <palsuite.h>
+
+int __cdecl main(int argc, char *argv[])
+{
+
+ HANDLE TheHeap;
+ char* TheMemory;
+ char* ReAllocMemory;
+ int i;
+
+ if(PAL_Initialize(argc, argv) != 0)
+ {
+ return FAIL;
+ }
+
+ TheHeap = GetProcessHeap();
+
+ if(TheHeap == NULL)
+ {
+ Fail("ERROR: GetProcessHeap() returned NULL when it was called. "
+ "GetLastError() returned %d.",GetLastError());
+ }
+
+ /* Allocate 100 bytes on the heap */
+ if((TheMemory = HeapAlloc(TheHeap, 0, 100)) == NULL)
+ {
+ Fail("ERROR: HeapAlloc returned NULL when it was called. "
+ "GetLastError() returned %d.",GetLastError());
+ }
+
+ /* Set each byte of that memory block to 'x' */
+ memset(TheMemory, 'X', 100);
+
+ /* Reallocate the memory */
+ ReAllocMemory = HeapReAlloc(TheHeap, 0, TheMemory, 100);
+
+ if(ReAllocMemory == NULL)
+ {
+ Fail("ERROR: HeapReAlloc failed to reallocate the 100 bytes of "
+ "heap memory. GetLastError returns %d.",GetLastError());
+ }
+
+ /* Check that each byte of the memory Reallocated is 'x' */
+
+ for(i=0; i<100; ++i)
+ {
+ if(ReAllocMemory[i] != 'X')
+ {
+ Fail("ERROR: Byte number %d of the reallocated memory block "
+ "is not set to 'X' as it should be.",i);
+ }
+ }
+
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test1/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test1/testinfo.dat
new file mode 100644
index 0000000000..ad3a3ffc73
--- /dev/null
+++ b/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test1/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 = HeapReAlloc
+Name = Positive test for HeapReAlloc to check normal behaviour
+TYPE = DEFAULT
+EXE1 = test1
+Description
+= Allocate some memory. Then reallocate that memory. Ensure the
+= return values are correct, and also that data placed in the allocated
+= memory carries over to the reallocated block.
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test2/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test2/CMakeLists.txt
new file mode 100644
index 0000000000..6f5510387a
--- /dev/null
+++ b/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test2/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ test2.c
+)
+
+add_executable(paltest_heaprealloc_test2
+ ${SOURCES}
+)
+
+add_dependencies(paltest_heaprealloc_test2 coreclrpal)
+
+target_link_libraries(paltest_heaprealloc_test2
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test2/test2.c b/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test2/test2.c
new file mode 100644
index 0000000000..13e789f901
--- /dev/null
+++ b/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test2/test2.c
@@ -0,0 +1,79 @@
+// 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: test2.c
+**
+** Purpose: Allocate some memory. Then reallocate that memory into less
+** space than the original amount. Ensure the
+** return values are correct, and also that data placed in the allocated
+** memory carries over to the reallocated block.
+**
+**
+**============================================================*/
+
+#include <palsuite.h>
+
+int __cdecl main(int argc, char *argv[])
+{
+
+ HANDLE TheHeap;
+ char* TheMemory;
+ char* ReAllocMemory;
+ int i;
+
+ if(PAL_Initialize(argc, argv) != 0)
+ {
+ return FAIL;
+ }
+
+ TheHeap = GetProcessHeap();
+
+ if(TheHeap == NULL)
+ {
+ Fail("ERROR: GetProcessHeap() returned NULL when it was called. "
+ "GetLastError() returned %d.",GetLastError());
+ }
+
+ /* Allocate 200 bytes on the heap */
+ if((TheMemory = HeapAlloc(TheHeap, 0, 200)) == NULL)
+ {
+ Fail("ERROR: HeapAlloc returned NULL when it was called. "
+ "GetLastError() returned %d.",GetLastError());
+ }
+
+ /* Set the first 100 bytes to 'X' */
+ memset(TheMemory, 'X', 100);
+
+ /* Set the second 100 bytes to 'Z' */
+ memset(TheMemory+100, 'Z', 100);
+
+ /* Reallocate the memory to 100 bytes */
+ ReAllocMemory = HeapReAlloc(TheHeap, 0, TheMemory, 100);
+
+ if(ReAllocMemory == NULL)
+ {
+ Fail("ERROR: HeapReAlloc failed to reallocate the 100 bytes of "
+ "heap memory. GetLastError returns %d.",GetLastError());
+ }
+
+ /* Check that each of the first 100 bytes hasn't lost any data.
+ Anything beyond the first 100 might still be valid, but we can't
+ gaurentee it.
+ */
+
+ for(i=0; i<100; ++i)
+ {
+ /* Note: Cast to char* so the function knows the size is 1 */
+ if(ReAllocMemory[i] != 'X')
+ {
+ Fail("ERROR: Byte number %d of the reallocated memory block "
+ "is not set to 'X' as it should be.",i);
+ }
+ }
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test2/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test2/testinfo.dat
new file mode 100644
index 0000000000..95a12aafd5
--- /dev/null
+++ b/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test2/testinfo.dat
@@ -0,0 +1,15 @@
+# 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 = HeapReAlloc
+Name = Positive test for HeapReAlloc to reallocate into a smaller space
+TYPE = DEFAULT
+EXE1 = test2
+Description
+= Allocate some memory. Then reallocate that memory into less
+= space than the origional amount. Ensure the
+= return values are correct, and also that data placed in the allocated
+= memory carries over to the reallocated block.
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test3/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test3/CMakeLists.txt
new file mode 100644
index 0000000000..7ad836706a
--- /dev/null
+++ b/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test3/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ test3.c
+)
+
+add_executable(paltest_heaprealloc_test3
+ ${SOURCES}
+)
+
+add_dependencies(paltest_heaprealloc_test3 coreclrpal)
+
+target_link_libraries(paltest_heaprealloc_test3
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test3/test3.c b/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test3/test3.c
new file mode 100644
index 0000000000..dea9de348d
--- /dev/null
+++ b/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test3/test3.c
@@ -0,0 +1,78 @@
+// 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: test3.c
+**
+** Purpose: Allocate some memory. Then reallocate that memory into a
+** bigger space on the heap. Check that the first portion of the data is
+** unchanged. Then set the new portion to a value, to ensure that it is
+** properly writable memory.
+**
+**
+**============================================================*/
+
+#include <palsuite.h>
+
+int __cdecl main(int argc, char *argv[])
+{
+
+ HANDLE TheHeap;
+ char* TheMemory;
+ char* ReAllocMemory;
+ int i;
+
+ if(PAL_Initialize(argc, argv) != 0)
+ {
+ return FAIL;
+ }
+
+ TheHeap = GetProcessHeap();
+
+ if(TheHeap == NULL)
+ {
+ Fail("ERROR: GetProcessHeap() returned NULL when it was called. "
+ "GetLastError() returned %d.",GetLastError());
+ }
+
+ /* Allocate 100 bytes on the heap */
+ if((TheMemory = HeapAlloc(TheHeap, 0, 100)) == NULL)
+ {
+ Fail("ERROR: HeapAlloc returned NULL when it was called. "
+ "GetLastError() returned %d.",GetLastError());
+ }
+
+ /* Set the first 100 bytes to 'X' */
+ memset(TheMemory, 'X', 100);
+
+ /* Reallocate the memory to 200 bytes */
+ ReAllocMemory = HeapReAlloc(TheHeap, 0, TheMemory, 200);
+
+ if(ReAllocMemory == NULL)
+ {
+ Fail("ERROR: HeapReAlloc failed to reallocate the 100 bytes of "
+ "heap memory. GetLastError returns %d.",GetLastError());
+ }
+
+ /* Check that each of the first 100 bytes hasn't lost any data. */
+ for(i=0; i<100; ++i)
+ {
+
+ if(ReAllocMemory[i] != 'X')
+ {
+ Fail("ERROR: Byte number %d of the reallocated memory block "
+ "is not set to 'X' as it should be.",i);
+ }
+ }
+
+ /* Beyond the first 100 bytes is valid free memory. We'll set all this
+ memory to a value -- though, even if HeapReAlloc didn't work, it might
+ still be possible to memset this memory without raising an exception.
+ */
+ memset(ReAllocMemory+100, 'Z', 100);
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test3/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test3/testinfo.dat
new file mode 100644
index 0000000000..ed6da87c33
--- /dev/null
+++ b/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test3/testinfo.dat
@@ -0,0 +1,16 @@
+# 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 = HeapReAlloc
+Name = Positive test for HeapReAlloc to reallocate into a larger space
+TYPE = DEFAULT
+EXE1 = test3
+Description
+= Allocate some memory. Then reallocate that memory into a
+= bigger space on the heap. Check that the first portion of the data is
+= unchanged. Then set the new portion to a value, to ensure that it is
+= properly writable memory.
+
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test4/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test4/CMakeLists.txt
new file mode 100644
index 0000000000..024a4ef840
--- /dev/null
+++ b/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test4/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ test4.c
+)
+
+add_executable(paltest_heaprealloc_test4
+ ${SOURCES}
+)
+
+add_dependencies(paltest_heaprealloc_test4 coreclrpal)
+
+target_link_libraries(paltest_heaprealloc_test4
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test4/test4.c b/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test4/test4.c
new file mode 100644
index 0000000000..cebf904501
--- /dev/null
+++ b/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test4/test4.c
@@ -0,0 +1,80 @@
+// 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: test4.c
+**
+** Purpose: Call HeapReAlloc with a NULL pointer to memory. It should
+** return NULL.
+**
+**
+**============================================================*/
+
+/* Note: When attempted with a NULL Handle, this test crashes under win32.
+ As such, the behaviour isn't tested here.
+*/
+
+#include <palsuite.h>
+
+int __cdecl main(int argc, char *argv[])
+{
+
+ HANDLE TheHeap;
+ LPVOID TheMemory = NULL;
+
+ if(PAL_Initialize(argc, argv) != 0)
+ {
+ return FAIL;
+ }
+
+ TheHeap = GetProcessHeap();
+
+ if(TheHeap == NULL)
+ {
+ Fail("ERROR: GetProcessHeap() returned NULL when it was called. "
+ "GetLastError() returned %d.",GetLastError());
+ }
+
+ /* Allocate 100 bytes on the heap */
+ if(HeapAlloc(TheHeap, 0, 100) == NULL)
+ {
+ Fail("ERROR: HeapAlloc returned NULL when it was called. "
+ "GetLastError() returned %d.",GetLastError());
+ }
+
+ /* Call HeapReAlloc with a NULL memory pointer. It should fail */
+
+ if(HeapReAlloc(TheHeap, 0, TheMemory, 100) != NULL)
+ {
+ Fail("ERROR: HeapReAlloc was passed an invalid memory pointer. "
+ "It should have failed and returned NULL upon failure.");
+ }
+
+ if(GetLastError() != 0)
+ {
+ Fail("ERROR: GetLastError should be zero after passing a NULL "
+ "memory pointer to HeapReAlloc.\n");
+ }
+
+ /* Call HeapReAlloc with a size of 0 bytes on a NULL memory pointer.
+ It should still fail.
+ */
+
+ if(HeapReAlloc(TheHeap, 0, TheMemory, 0) != NULL)
+ {
+ Fail("ERROR: HeapReAlloc was passed an invalid memory pointer and "
+ "the amount of memory to reallocate was 0. "
+ "It should have failed and returned NULL upon failure.");
+ }
+
+ if(GetLastError() != 0)
+ {
+ Fail("ERROR: GetLastError should be zero after passing a NULL "
+ "memory pointer to HeapReAlloc.\n");
+ }
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test4/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test4/testinfo.dat
new file mode 100644
index 0000000000..cfa5f5ceed
--- /dev/null
+++ b/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test4/testinfo.dat
@@ -0,0 +1,15 @@
+# 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 = HeapReAlloc
+Name = Negative test for HeapReAlloc
+TYPE = DEFAULT
+EXE1 = test4
+Description
+= Call HeapReAlloc with a NULL pointer to memory. It should
+= return NULL.
+
+
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test5/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test5/CMakeLists.txt
new file mode 100644
index 0000000000..3ab3ec16e8
--- /dev/null
+++ b/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test5/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ test5.c
+)
+
+add_executable(paltest_heaprealloc_test5
+ ${SOURCES}
+)
+
+add_dependencies(paltest_heaprealloc_test5 coreclrpal)
+
+target_link_libraries(paltest_heaprealloc_test5
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test5/test5.c b/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test5/test5.c
new file mode 100644
index 0000000000..230e65e492
--- /dev/null
+++ b/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test5/test5.c
@@ -0,0 +1,69 @@
+// 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: test5.c
+**
+** Purpose: Allocate some memory. Then call HeapRealloc with 0 as the
+** amount of memory to reallocate. This should work, essentially freeing
+** the memory (though we can't verfiy this)
+**
+**
+**============================================================*/
+
+#include <palsuite.h>
+
+int __cdecl main(int argc, char *argv[])
+{
+
+ HANDLE TheHeap;
+ char* TheMemory;
+ char* ReAllocMemory;
+ char* ReAllocMemory2;
+
+ if(PAL_Initialize(argc, argv) != 0)
+ {
+ return FAIL;
+ }
+
+ TheHeap = GetProcessHeap();
+
+ if(TheHeap == NULL)
+ {
+ Fail("ERROR: GetProcessHeap() returned NULL when it was called. "
+ "GetLastError() returned %d.",GetLastError());
+ }
+
+ /* Allocate 100 bytes on the heap */
+ if((TheMemory = HeapAlloc(TheHeap, 0, 100)) == NULL)
+ {
+ Fail("ERROR: HeapAlloc returned NULL when it was called. "
+ "GetLastError() returned %d.",GetLastError());
+ }
+
+ /* Set each byte of that memory block to 'x' */
+ memset(TheMemory, 'X', 100);
+
+ /* Reallocate the memory into 0 bytes */
+ ReAllocMemory = HeapReAlloc(TheHeap, 0, TheMemory, 0);
+
+ if(ReAllocMemory == NULL)
+ {
+ Fail("ERROR: HeapReAlloc failed to reallocate the 100 bytes of "
+ "heap memory. GetLastError returns %d.",GetLastError());
+ }
+
+ /* Reallocate the memory we just put into 0 bytes, into 100 bytes. */
+ ReAllocMemory2 = HeapReAlloc(TheHeap, 0, ReAllocMemory, 100);
+
+ if(ReAllocMemory2 == NULL)
+ {
+ Fail("ERROR: HeapReAlloc failed to reallocate the 0 bytes of "
+ "heap memory into 100. GetLastError returns %d.",GetLastError());
+ }
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test5/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test5/testinfo.dat
new file mode 100644
index 0000000000..e36b9035c5
--- /dev/null
+++ b/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test5/testinfo.dat
@@ -0,0 +1,15 @@
+# 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 = HeapReAlloc
+Name = Positive test for HeapReAlloc to check behaviour with byte size 0
+TYPE = DEFAULT
+EXE1 = test5
+Description
+= Allocate some memory. Then call HeapRealloc with 0 as the
+= amount of memory to reallocate. This should work, essentially freeing
+= the memory (though we can't verfiy this)
+