summaryrefslogtreecommitdiff
path: root/src/pal/tests/palsuite/filemapping_memmgt/RtlMoveMemory
diff options
context:
space:
mode:
Diffstat (limited to 'src/pal/tests/palsuite/filemapping_memmgt/RtlMoveMemory')
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/RtlMoveMemory/CMakeLists.txt7
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/RtlMoveMemory/test1/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/RtlMoveMemory/test1/test1.c56
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/RtlMoveMemory/test1/testinfo.dat15
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/RtlMoveMemory/test3/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/RtlMoveMemory/test3/test3.c72
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/RtlMoveMemory/test3/testinfo.dat17
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/RtlMoveMemory/test4/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/RtlMoveMemory/test4/test4.c76
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/RtlMoveMemory/test4/testinfo.dat18
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/RtlMoveMemory/test5/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/RtlMoveMemory/test5/test5.c63
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/RtlMoveMemory/test5/testinfo.dat18
13 files changed, 418 insertions, 0 deletions
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/RtlMoveMemory/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/RtlMoveMemory/CMakeLists.txt
new file mode 100644
index 0000000000..393074b4ee
--- /dev/null
+++ b/src/pal/tests/palsuite/filemapping_memmgt/RtlMoveMemory/CMakeLists.txt
@@ -0,0 +1,7 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+add_subdirectory(test1)
+add_subdirectory(test3)
+add_subdirectory(test4)
+add_subdirectory(test5)
+
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/RtlMoveMemory/test1/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/RtlMoveMemory/test1/CMakeLists.txt
new file mode 100644
index 0000000000..987c413d03
--- /dev/null
+++ b/src/pal/tests/palsuite/filemapping_memmgt/RtlMoveMemory/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_rtlmovememory_test1
+ ${SOURCES}
+)
+
+add_dependencies(paltest_rtlmovememory_test1 coreclrpal)
+
+target_link_libraries(paltest_rtlmovememory_test1
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/RtlMoveMemory/test1/test1.c b/src/pal/tests/palsuite/filemapping_memmgt/RtlMoveMemory/test1/test1.c
new file mode 100644
index 0000000000..7fc56510d8
--- /dev/null
+++ b/src/pal/tests/palsuite/filemapping_memmgt/RtlMoveMemory/test1/test1.c
@@ -0,0 +1,56 @@
+// 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: Simple test -- have two 128 blocks of memory allocated. Then
+** move one block to the other and check to see that the data was not
+** corrupted.
+**
+**
+**============================================================*/
+
+#include <palsuite.h>
+
+enum Memory
+{
+ MEMORY_AMOUNT = 128
+};
+
+int __cdecl main(int argc, char *argv[])
+{
+ char NewAddress[MEMORY_AMOUNT];
+ char OldAddress[MEMORY_AMOUNT];
+ int i;
+ char temp;
+
+ if(PAL_Initialize(argc, argv))
+ {
+ return FAIL;
+ }
+
+ /* Put some data into the block we'll be moving */
+ memset(OldAddress, 'X', MEMORY_AMOUNT);
+
+ /* Move the block to the NewAddress */
+ RtlMoveMemory(NewAddress, OldAddress, MEMORY_AMOUNT);
+
+ /* Check to ensure the data didn't get corrupted */
+ for(i=0; i<MEMORY_AMOUNT; ++i)
+ {
+ if(NewAddress[i] != 'X')
+ {
+ temp = NewAddress[i];
+ Fail("ERROR: When the memory was moved to a new location, the "
+ "data which was stored in it was somehow corrupted. "
+ "Character %d should have been 'X' but instead is %c.\n",
+ i, temp);
+ }
+ }
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/RtlMoveMemory/test1/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/RtlMoveMemory/test1/testinfo.dat
new file mode 100644
index 0000000000..645d46c968
--- /dev/null
+++ b/src/pal/tests/palsuite/filemapping_memmgt/RtlMoveMemory/test1/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 = RtlMoveMemory
+Name = Positive test for RtlMoveMemory API
+TYPE = DEFAULT
+EXE1 = test1
+Description
+= Simple test -- have two 128 blocks of memory allocated. Then
+= move one block to the other and check to see that the data was not
+= corrupted.
+
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/RtlMoveMemory/test3/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/RtlMoveMemory/test3/CMakeLists.txt
new file mode 100644
index 0000000000..14098a8dc1
--- /dev/null
+++ b/src/pal/tests/palsuite/filemapping_memmgt/RtlMoveMemory/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_rtlmovememory_test3
+ ${SOURCES}
+)
+
+add_dependencies(paltest_rtlmovememory_test3 coreclrpal)
+
+target_link_libraries(paltest_rtlmovememory_test3
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/RtlMoveMemory/test3/test3.c b/src/pal/tests/palsuite/filemapping_memmgt/RtlMoveMemory/test3/test3.c
new file mode 100644
index 0000000000..279c0c1199
--- /dev/null
+++ b/src/pal/tests/palsuite/filemapping_memmgt/RtlMoveMemory/test3/test3.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: test3.c
+**
+** Purpose: Allocate 128 bytes of memory and store data in it. Move 10
+** other bytes of memory to that location. Check that the first 10 bytes
+** carried over their data and that the other 118 were unchanged.
+**
+**
+**============================================================*/
+
+#include <palsuite.h>
+
+enum Memory
+{
+ NEW_MEMORY_AMOUNT = 128,
+ OLD_MEMORY_AMOUNT = 10
+};
+
+int __cdecl main(int argc, char *argv[])
+{
+ char NewAddress[NEW_MEMORY_AMOUNT];
+ char OldAddress[OLD_MEMORY_AMOUNT];
+ int i;
+
+
+ if(PAL_Initialize(argc, argv))
+ {
+ return FAIL;
+ }
+
+ /* Put some data into the block we'll be moving */
+ memset(OldAddress, 'X', OLD_MEMORY_AMOUNT);
+
+ /* Put some data into the block we're moving to */
+ memset(NewAddress, 'Z', NEW_MEMORY_AMOUNT);
+
+ /* Move the block to the NewAddress */
+ RtlMoveMemory(NewAddress, OldAddress, OLD_MEMORY_AMOUNT);
+
+ /* Check to ensure the moved data didn't get corrupted */
+ for(i=0; i<OLD_MEMORY_AMOUNT; ++i)
+ {
+ if(NewAddress[i] != 'X')
+ {
+ Fail("ERROR: When the memory was moved to a new location, the "
+ "data which was stored in it was somehow corrupted. "
+ "Character %d should have been 'X' but instead is %c.\n",
+ i, NewAddress[i]);
+ }
+ }
+
+ /* Check to ensure the memory which didn't move didn't get corrupted */
+ for(i=OLD_MEMORY_AMOUNT; i<NEW_MEMORY_AMOUNT; ++i)
+ {
+ if(NewAddress[i] != 'Z')
+ {
+ Fail("ERROR: When the memory was moved to a new location, the "
+ "data which was stored in it was somehow corrupted. "
+ "Character %d should have been 'Z' but instead is %c.\n",
+ i, NewAddress[i]);
+ }
+ }
+
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/RtlMoveMemory/test3/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/RtlMoveMemory/test3/testinfo.dat
new file mode 100644
index 0000000000..fb56f2e985
--- /dev/null
+++ b/src/pal/tests/palsuite/filemapping_memmgt/RtlMoveMemory/test3/testinfo.dat
@@ -0,0 +1,17 @@
+# 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 = RtlMoveMemory
+Name = Positive test for RtlMoveMemory API, move a small block to large
+TYPE = DEFAULT
+EXE1 = test3
+Description
+= Allocate 128 bytes of memory and store data in it. Move 10
+= other bytes of memory to that location. Check that the first 10 bytes
+= carried over their data and that the other 118 were unchanged.
+
+
+
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/RtlMoveMemory/test4/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/RtlMoveMemory/test4/CMakeLists.txt
new file mode 100644
index 0000000000..00aec7e8f7
--- /dev/null
+++ b/src/pal/tests/palsuite/filemapping_memmgt/RtlMoveMemory/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_rtlmovememory_test4
+ ${SOURCES}
+)
+
+add_dependencies(paltest_rtlmovememory_test4 coreclrpal)
+
+target_link_libraries(paltest_rtlmovememory_test4
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/RtlMoveMemory/test4/test4.c b/src/pal/tests/palsuite/filemapping_memmgt/RtlMoveMemory/test4/test4.c
new file mode 100644
index 0000000000..b6e1ecd6f7
--- /dev/null
+++ b/src/pal/tests/palsuite/filemapping_memmgt/RtlMoveMemory/test4/test4.c
@@ -0,0 +1,76 @@
+// 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: Test simple overlapping. Move the first 50 bytes of a
+** piece of memory to the latter 50 bytes. ie i -> i+50 Check to make sure
+** no data is lost.
+**
+**
+**============================================================*/
+
+#include <palsuite.h>
+
+enum Memory
+{
+ MEMORY_AMOUNT = 128
+};
+
+int __cdecl main(int argc, char *argv[])
+{
+ char* NewAddress;
+ char OldAddress[MEMORY_AMOUNT];
+ int i;
+
+ if(PAL_Initialize(argc, argv))
+ {
+ return FAIL;
+ }
+
+ NewAddress = OldAddress+50;
+
+ /* Put some data into the block we'll be moving
+ The first 50 byes will be 'X' and the rest set to 'Z'
+ */
+ memset(OldAddress, 'X', 50);
+ memset(NewAddress, 'Z', MEMORY_AMOUNT-50);
+
+ /* Move the first 50 bytes of OldAddress to OldAddress+50. This
+ is to test that the source and destination addresses can overlap.
+ */
+ RtlMoveMemory(NewAddress, OldAddress, 50);
+
+ /* Check to ensure the moved data didn't get corrupted
+ The first 50 bytes should be 'X'
+ */
+ for(i=0; i<50; ++i)
+ {
+ if(NewAddress[i] != 'X')
+ {
+ Fail("ERROR: When the memory was moved to a new location, the "
+ "data which was stored in it was somehow corrupted. "
+ "Character %d should have been 'X' but instead is %c.\n",
+ i, NewAddress[i]);
+ }
+ }
+
+ /* The rest of the memory should be 'Z' */
+ for(i=50; i<MEMORY_AMOUNT-50; ++i)
+ {
+ if(NewAddress[i] != 'Z')
+ {
+
+ Fail("ERROR: When the memory was moved to a new location, the "
+ "data which was stored in it was somehow corrupted. "
+ "Character %d should have been 'Z' but instead is %c.\n",
+ i, NewAddress[i]);
+ }
+ }
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/RtlMoveMemory/test4/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/RtlMoveMemory/test4/testinfo.dat
new file mode 100644
index 0000000000..56b82f2083
--- /dev/null
+++ b/src/pal/tests/palsuite/filemapping_memmgt/RtlMoveMemory/test4/testinfo.dat
@@ -0,0 +1,18 @@
+# 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 = RtlMoveMemory
+Name = Positive test for RtlMoveMemory API, test that overlapping works
+TYPE = DEFAULT
+EXE1 = test4
+Description
+= Test simple overlapping. Move the first 50 bytes of a
+= piece of memory to the latter 50 bytes. ie i -> i+50 Check to make sure
+= no data is lost.
+
+
+
+
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/RtlMoveMemory/test5/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/RtlMoveMemory/test5/CMakeLists.txt
new file mode 100644
index 0000000000..f2de78216e
--- /dev/null
+++ b/src/pal/tests/palsuite/filemapping_memmgt/RtlMoveMemory/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_rtlmovememory_test5
+ ${SOURCES}
+)
+
+add_dependencies(paltest_rtlmovememory_test5 coreclrpal)
+
+target_link_libraries(paltest_rtlmovememory_test5
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/RtlMoveMemory/test5/test5.c b/src/pal/tests/palsuite/filemapping_memmgt/RtlMoveMemory/test5/test5.c
new file mode 100644
index 0000000000..affcb0abc9
--- /dev/null
+++ b/src/pal/tests/palsuite/filemapping_memmgt/RtlMoveMemory/test5/test5.c
@@ -0,0 +1,63 @@
+// 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: Do more complex overlapping. Move a section of memory back so
+** that it actually ends up overlapping itself.
+**
+**
+**============================================================*/
+
+#include <palsuite.h>
+
+enum Memory
+{
+ MEMORY_AMOUNT = 128
+};
+
+int __cdecl main(int argc, char *argv[])
+{
+ char* NewAddress;
+ char* SectionToMove;
+ char TheMemory[MEMORY_AMOUNT];
+ int i;
+
+ if(PAL_Initialize(argc, argv))
+ {
+ return FAIL;
+ }
+
+ NewAddress = TheMemory;
+ SectionToMove = TheMemory+50;
+
+ /* Put some data into the first 50 bytes */
+ memset(TheMemory, 'X', 50);
+
+ /* Put some data into the rest of the memory */
+ memset(SectionToMove, 'Z', MEMORY_AMOUNT-50);
+
+ /* Move the section in the middle of TheMemory back to the start of
+ TheMemory -- but have it also overlap itself. (ie. the section
+ to be move is overlapping itself)
+ */
+ RtlMoveMemory(NewAddress, SectionToMove, MEMORY_AMOUNT-50);
+
+ /* Check to ensure the moved data didn't get corrupted */
+ for(i=0; i<MEMORY_AMOUNT-50; ++i)
+ {
+ if(NewAddress[i] != 'Z')
+ {
+ Fail("ERROR: When the memory was moved to a new location, the "
+ "data which was stored in it was somehow corrupted. "
+ "Character %d should have been 'Z' but instead is %c.\n",
+ i, NewAddress[i]);
+ }
+ }
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/RtlMoveMemory/test5/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/RtlMoveMemory/test5/testinfo.dat
new file mode 100644
index 0000000000..a4ba99a29d
--- /dev/null
+++ b/src/pal/tests/palsuite/filemapping_memmgt/RtlMoveMemory/test5/testinfo.dat
@@ -0,0 +1,18 @@
+# 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 = RtlMoveMemory
+Name = Positive test for RtlMoveMemory API, test that overlapping works
+TYPE = DEFAULT
+EXE1 = test5
+Description
+= Do more complex overlapping. Move a section of memory back so
+= that it actually ends up overlapping itself.
+
+
+
+
+