[KMTESTS/RTL]
authorThomas Faber <thomas.faber@reactos.org>
Tue, 26 Jul 2011 07:40:19 +0000 (07:40 +0000)
committerThomas Faber <thomas.faber@reactos.org>
Tue, 26 Jul 2011 07:40:19 +0000 (07:40 +0000)
- add a concept test for Rtl functions, which can run unmodified in user/kernel mode

svn path=/branches/GSoC_2011/KMTestSuite/; revision=52889

kmtests/CMakeLists.txt
kmtests/kmtest.rbuild
kmtests/kmtest/testlist.c
kmtests/kmtest_drv.rbuild
kmtests/kmtest_drv/testlist.c
kmtests/rtl/RtlMemory.c [new file with mode: 0644]

index 00f2fe3..22d4d21 100644 (file)
@@ -32,6 +32,7 @@ list(APPEND KMTEST_DRV_SOURCE
     ntos_ke/KeProcessor.c
     ntos_ke/KeSpinLock.c
     ntos_ob/ObCreate.c
+    rtl/RtlMemory.c
 
     kmtest_drv/kmtest_drv.rc)
 
@@ -62,6 +63,7 @@ list(APPEND KMTEST_SOURCE
     kmtest/testlist.c
 
     example/Example_user.c
+    rtl/RtlMemory.c
 
     kmtest/kmtest.rc)
 
index 31e4bcb..b7464ea 100644 (file)
@@ -11,4 +11,7 @@
        <directory name="example">
                <file>Example_user.c</file>
        </directory>
+       <directory name="rtl">
+               <file>RtlMemory.c</file>
+       </directory>
 </module>
index 143660d..745ed92 100644 (file)
 #include <windows.h>
 #include <kmt_test.h>
 
-VOID Test_Example(VOID);
+KMT_TESTFUNC Test_Example;
+KMT_TESTFUNC Test_RtlMemory;
 
 /* tests with a leading '-' will not be listed */
 const KMT_TEST TestList[] =
 {
     { "Example",            Test_Example },
+    { "RtlMemory",          Test_RtlMemory },
     { NULL,                 NULL },
 };
index 7cb01ca..15e39da 100644 (file)
@@ -41,6 +41,9 @@
        <directory name="ntos_ob">
                <file>ObCreate.c</file>
        </directory>
+       <directory name="rtl">
+               <file>RtlMemory.c</file>
+       </directory>
 </module>
 <module name="kmtest_printf" type="staticlibrary">
        <include base="crt">include</include>
index 65e6a61..7310149 100644 (file)
@@ -27,6 +27,7 @@ KMT_TESTFUNC Test_KeIrql;
 KMT_TESTFUNC Test_KeProcessor;
 KMT_TESTFUNC Test_KernelType;
 KMT_TESTFUNC Test_ObCreate;
+KMT_TESTFUNC Test_RtlMemory;
 
 const KMT_TEST TestList[] =
 {
@@ -49,5 +50,6 @@ const KMT_TEST TestList[] =
     { "KeProcessor",                        Test_KeProcessor },
     { "-KernelType",                        Test_KernelType },
     { "ObCreate",                           Test_ObCreate },
+    { "RtlMemoryKM",                        Test_RtlMemory },
     { NULL,                                 NULL }
 };
diff --git a/kmtests/rtl/RtlMemory.c b/kmtests/rtl/RtlMemory.c
new file mode 100644 (file)
index 0000000..a46409c
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * PROJECT:         ReactOS kernel-mode tests
+ * LICENSE:         GPLv2+ - See COPYING in the top level directory
+ * PURPOSE:         Kernel-Mode Test Suite Runtime library memory functions test
+ * PROGRAMMER:      Thomas Faber <thfabba@gmx.de>
+ */
+
+/* TODO: move this to some header */
+#ifdef KMT_USER_MODE
+#   include <windows.h>
+#   define ok_irql(i)
+#   define KIRQL int
+#   define KeRaiseIrql(new, old)
+#   define KeLowerIrql(i)
+#elif KMT_KERNEL_MODE
+#   include <ntddk.h>
+#endif
+#include <kmt_test.h>
+
+START_TEST(RtlMemory)
+{
+    UCHAR Buffer[512];
+    KIRQL Irql;
+    int i;
+
+    KeRaiseIrql(HIGH_LEVEL, &Irql);
+
+    RtlFillMemory(Buffer, sizeof Buffer / 2, 0x55);
+    RtlFillMemory(Buffer + sizeof Buffer / 2, sizeof Buffer / 2, 0xAA);
+    for (i = 0; i < sizeof Buffer / 2; ++i)
+        ok_eq_uint(Buffer[i], 0x55);
+    for (i = sizeof Buffer / 2; i < sizeof Buffer; ++i)
+        ok_eq_uint(Buffer[i], 0xAA);
+
+    KeLowerIrql(Irql);
+}