Add tests for Create/Open/Set/Cancel Timer in Executive. Under Win2003 SP1 works...
authorAleksey Bragin <aleksey@reactos.org>
Fri, 14 Jul 2006 21:04:31 +0000 (21:04 +0000)
committerAleksey Bragin <aleksey@reactos.org>
Fri, 14 Jul 2006 21:04:31 +0000 (21:04 +0000)
svn path=/trunk/; revision=23062

reactos/drivers/test/kmtest/kmtest.c
reactos/drivers/test/kmtest/kmtest.rbuild
reactos/drivers/test/kmtest/ntos_ex.c [new file with mode: 0644]

index a5d61ab..558a95f 100644 (file)
@@ -106,6 +106,7 @@ int kmtest_ok(int condition, const char *msg, ... )
 VOID FASTCALL NtoskrnlIoMdlTest();
 VOID FASTCALL NtoskrnlIoDeviceInterface();
 VOID FASTCALL NtoskrnlObTest();
+VOID FASTCALL NtoskrnlExecutiveTests();
 
 /*
  * DriverEntry
@@ -116,6 +117,7 @@ DriverEntry(PDRIVER_OBJECT DriverObject,
             PUNICODE_STRING RegistryPath)
 {
     DbgPrint("\n===============================================\nKernel Mode Regression Test driver starting...\n");
+    NtoskrnlExecutiveTests();
     NtoskrnlIoDeviceInterface();
     NtoskrnlIoMdlTest();
     NtoskrnlObTest();
index 36cbb6b..0e1f51a 100644 (file)
@@ -7,6 +7,7 @@
        <file>kmtest.c</file>
        <file>deviface.c</file>
        <file>deviface_test.c</file>
+       <file>ntos_ex.c</file>
        <file>ntos_io.c</file>
        <file>ntos_ob.c</file>
        <file>kmtest.rc</file>
diff --git a/reactos/drivers/test/kmtest/ntos_ex.c b/reactos/drivers/test/kmtest/ntos_ex.c
new file mode 100644 (file)
index 0000000..2d99069
--- /dev/null
@@ -0,0 +1,110 @@
+/*\r
+ * NTOSKRNL Executive Regressions KM-Test\r
+ * ReactOS Kernel Mode Regression Testing framework\r
+ *\r
+ * Copyright 2006 Aleksey Bragin <aleksey@reactos.org>\r
+ *\r
+ * This library is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU Library General Public\r
+ * License as published by the Free Software Foundation; either\r
+ * version 2 of the License, or (at your option) any later version.\r
+ *\r
+ * This library is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
+ * Library General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU Library General Public\r
+ * License along with this library; see the file COPYING.LIB.\r
+ * If not, write to the Free Software Foundation,\r
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\r
+ */\r
+\r
+/* INCLUDES *******************************************************************/\r
+\r
+#include <ddk/ntddk.h>\r
+#include <ntifs.h>\r
+#include <ndk/ntndk.h>\r
+#include "kmtest.h"\r
+\r
+#define NDEBUG\r
+#include "debug.h"\r
+\r
+/* PRIVATE FUNCTIONS ***********************************************************/\r
+\r
+VOID\r
+ExTimerTest()\r
+{\r
+    UNICODE_STRING TimerName;\r
+    OBJECT_ATTRIBUTES ObjectAttributes;\r
+    HANDLE TimerHandle;\r
+    HANDLE HandleOpened;\r
+    LARGE_INTEGER DueTime;\r
+    BOOLEAN PreviousState, CurrentState;\r
+    NTSTATUS Status;\r
+\r
+    StartTest();\r
+\r
+    // Create the timer\r
+    RtlInitUnicodeString(&TimerName, L"\\TestTimer");\r
+    InitializeObjectAttributes(&ObjectAttributes, &TimerName, 0, NULL, NULL);\r
+    Status = ZwCreateTimer(&TimerHandle, TIMER_ALL_ACCESS,\r
+        &ObjectAttributes, NotificationTimer);\r
+    ok(Status == STATUS_SUCCESS, "ZwCreateTimer failed with Status=0x%08lX", Status);\r
+\r
+    // Open the timer\r
+    Status = ZwOpenTimer(&HandleOpened, TIMER_ALL_ACCESS, &ObjectAttributes);\r
+    ok(Status == STATUS_SUCCESS, "ZwOpenTimer failed with Status=0x%08lX", Status);\r
+\r
+    // Set the timer, to some rather high value so it doesn't expire\r
+    DueTime.LowPart = -10000;\r
+    DueTime.HighPart = -10;\r
+    PreviousState = TRUE;\r
+    Status = ZwSetTimer(HandleOpened, &DueTime, NULL, NULL, FALSE, 0L, &PreviousState);\r
+    ok(Status == STATUS_SUCCESS, "ZwSetTimer failed with Status=0x%08lX", Status);\r
+    ok(PreviousState == FALSE, "Incorrect PreviousState returned when setting the timer");\r
+\r
+    // Cancel the timer\r
+    CurrentState = TRUE;\r
+    Status = ZwCancelTimer(HandleOpened, &CurrentState);\r
+    ok(Status == STATUS_SUCCESS, "ZwCancelTimer failed with Status=0x%08lX", Status);\r
+    ok(CurrentState == FALSE, "Incorrect CurrentState returned when canceling the timer");\r
+\r
+    // Set the timer to some small value, because we'll wait for it to expire\r
+    DueTime.LowPart = -100;\r
+    DueTime.HighPart = -1;\r
+    PreviousState = TRUE;\r
+    Status = ZwSetTimer(HandleOpened, &DueTime, NULL, NULL, FALSE, 0L, &PreviousState);\r
+    ok(Status == STATUS_SUCCESS, "ZwSetTimer failed with Status=0x%08lX", Status);\r
+    ok(PreviousState == FALSE, "Incorrect PreviousState returned when setting the timer");\r
+\r
+    // Wait until it expires\r
+    Status = ZwWaitForSingleObject(HandleOpened, FALSE, NULL);\r
+    ok(Status == STATUS_SUCCESS, "ZwWaitForSingleObject failed with Status=0x%08lX", Status);\r
+\r
+    // And cancel it\r
+    CurrentState = FALSE;\r
+    Status = ZwCancelTimer(HandleOpened, &CurrentState);\r
+    ok(Status == STATUS_SUCCESS, "ZwCancelTimer failed with Status=0x%08lX", Status);\r
+    ok(CurrentState == TRUE, "Incorrect CurrentState returned when setting the timer");\r
+\r
+    // TODO: Add tests for a timer with APC routines\r
+\r
+    // Cleanup...\r
+    Status = ZwClose(HandleOpened);\r
+    ok(Status == STATUS_SUCCESS, "ZwClose failed with Status=0x%08lX", Status);\r
+\r
+    Status = ZwClose(TimerHandle);\r
+    ok(Status == STATUS_SUCCESS, "ZwClose failed with Status=0x%08lX", Status);\r
+\r
+    FinishTest("NTOSKRNL Executive Timer");\r
+}\r
+\r
+/* PUBLIC FUNCTIONS ***********************************************************/\r
+\r
+VOID\r
+FASTCALL\r
+NtoskrnlExecutiveTests()\r
+{\r
+    ExTimerTest();\r
+}\r