[KMTESTS:OB]
authorPierre Schweitzer <pierre@reactos.org>
Mon, 28 Sep 2015 12:25:38 +0000 (12:25 +0000)
committerPierre Schweitzer <pierre@reactos.org>
Mon, 28 Sep 2015 12:25:38 +0000 (12:25 +0000)
Add a test dedicated to Stefan.

svn path=/trunk/; revision=69398

rostests/kmtests/CMakeLists.txt
rostests/kmtests/kmtest_drv/testlist.c
rostests/kmtests/ntos_ob/ObWait.c [new file with mode: 0644]

index b9741b4..b17c970 100644 (file)
@@ -74,6 +74,7 @@ list(APPEND KMTEST_DRV_SOURCE
     ntos_ob/ObReference.c
     ntos_ob/ObType.c
     ntos_ob/ObTypes.c
+    ntos_ob/ObWait.c
     ntos_ps/PsNotify.c
     ntos_se/SeHelpers.c
     ntos_se/SeInheritance.c
index b97b659..9a471b6 100644 (file)
@@ -66,6 +66,7 @@ KMT_TESTFUNC Test_RtlUnicodeString;
 KMT_TESTFUNC Test_ZwAllocateVirtualMemory;
 KMT_TESTFUNC Test_ZwCreateSection;
 KMT_TESTFUNC Test_ZwMapViewOfSection;
+KMT_TESTFUNC Test_ZwWaitForMultipleObjects;
 
 const KMT_TEST TestList[] =
 {
@@ -128,5 +129,6 @@ const KMT_TEST TestList[] =
     { "ZwAllocateVirtualMemory",            Test_ZwAllocateVirtualMemory },
     { "ZwCreateSection",                    Test_ZwCreateSection },
     { "ZwMapViewOfSection",                 Test_ZwMapViewOfSection },
+    { "ZwWaitForMultipleObjects",           Test_ZwWaitForMultipleObjects},
     { NULL,                                 NULL }
 };
diff --git a/rostests/kmtests/ntos_ob/ObWait.c b/rostests/kmtests/ntos_ob/ObWait.c
new file mode 100644 (file)
index 0000000..82e4b1a
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * PROJECT:         ReactOS kernel-mode tests
+ * LICENSE:         GPLv2+ - See COPYING in the top level directory
+ * PURPOSE:         Kernel-Mode Test Suite *WaitForMultipleObjects
+ * PROGRAMMER:      Pierre Schweitzer <thomas.faber@reactos.org>
+ */
+
+#include <kmt_test.h>
+
+#define NDEBUG
+#include <debug.h>
+
+static
+VOID
+NTAPI
+KernelModeTest(IN PVOID Context)
+{
+    NTSTATUS Status;
+
+    Status = ZwWaitForMultipleObjects(2, (void **)0x42424242, WaitAll, FALSE, NULL);
+    ok_eq_hex(Status, STATUS_ACCESS_VIOLATION);
+}
+
+START_TEST(ZwWaitForMultipleObjects)
+{
+    NTSTATUS Status;
+    OBJECT_ATTRIBUTES ObjectAttributes;
+    HANDLE ThreadHandle;
+    PVOID ThreadObject = NULL;
+
+    /* We've to be in kernel mode, so spawn a thread */
+    InitializeObjectAttributes(&ObjectAttributes,
+                               NULL,
+                               OBJ_KERNEL_HANDLE,
+                               NULL,
+                               NULL);
+    Status = PsCreateSystemThread(&ThreadHandle,
+                                  SYNCHRONIZE,
+                                  &ObjectAttributes,
+                                  NULL,
+                                  NULL,
+                                  KernelModeTest,
+                                  NULL);
+    ok_eq_hex(Status, STATUS_SUCCESS);
+    if (Status == STATUS_SUCCESS)
+    {
+        /* Then, just wait on our thread to finish */
+        Status = ObReferenceObjectByHandle(ThreadHandle,
+                                           SYNCHRONIZE,
+                                           *PsThreadType,
+                                           KernelMode,
+                                           &ThreadObject,
+                                           NULL);
+        ObCloseHandle(ThreadHandle, KernelMode);
+
+        Status = KeWaitForSingleObject(ThreadObject,
+                                       Executive,
+                                       KernelMode,
+                                       FALSE,
+                                       NULL);
+        ok_eq_hex(Status, STATUS_SUCCESS);
+        ObDereferenceObject(ThreadObject);
+    }
+}