Author: rharabien
Date: Fri Oct 7 16:13:03 2011
New Revision: 54047
URL:
http://svn.reactos.org/svn/reactos?rev=54047&view=rev
Log:
[KMTESTS\NTOS_KE] - Add KeTimer test stub which tests only KeInitializeTimerEx (Note: this
function initializes more fields of dispatch header than KeInitializeEvent).
Added:
trunk/rostests/kmtests/ntos_ke/KeTimer.c (with props)
Modified:
trunk/rostests/kmtests/CMakeLists.txt
trunk/rostests/kmtests/kmtest_drv.rbuild
trunk/rostests/kmtests/kmtest_drv/testlist.c
Modified: trunk/rostests/kmtests/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/kmtests/CMakeLists.txt?re…
==============================================================================
--- trunk/rostests/kmtests/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/rostests/kmtests/CMakeLists.txt [iso-8859-1] Fri Oct 7 16:13:03 2011
@@ -43,6 +43,7 @@
ntos_ke/KeIrql.c
ntos_ke/KeProcessor.c
ntos_ke/KeSpinLock.c
+ ntos_ke/KeTimer.c
ntos_mm/MmSection.c
ntos_ob/ObReference.c
ntos_ob/ObType.c
Modified: trunk/rostests/kmtests/kmtest_drv.rbuild
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/kmtests/kmtest_drv.rbuild…
==============================================================================
--- trunk/rostests/kmtests/kmtest_drv.rbuild [iso-8859-1] (original)
+++ trunk/rostests/kmtests/kmtest_drv.rbuild [iso-8859-1] Fri Oct 7 16:13:03 2011
@@ -43,6 +43,7 @@
<file>KeIrql.c</file>
<file>KeProcessor.c</file>
<file>KeSpinLock.c</file>
+ <file>KeTimer.c</file>
</directory>
<directory name="ntos_mm">
<file>MmSection.c</file>
Modified: trunk/rostests/kmtests/kmtest_drv/testlist.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/kmtests/kmtest_drv/testli…
==============================================================================
--- trunk/rostests/kmtests/kmtest_drv/testlist.c [iso-8859-1] (original)
+++ trunk/rostests/kmtests/kmtest_drv/testlist.c [iso-8859-1] Fri Oct 7 16:13:03 2011
@@ -29,6 +29,7 @@
KMT_TESTFUNC Test_KeGuardedMutex;
KMT_TESTFUNC Test_KeIrql;
KMT_TESTFUNC Test_KeProcessor;
+KMT_TESTFUNC Test_KeTimer;
KMT_TESTFUNC Test_KernelType;
KMT_TESTFUNC Test_MmSection;
KMT_TESTFUNC Test_ObReference;
@@ -63,6 +64,7 @@
{ "KeGuardedMutex", Test_KeGuardedMutex },
{ "KeIrql", Test_KeIrql },
{ "-KeProcessor", Test_KeProcessor },
+ { "KeTimer", Test_KeTimer },
{ "-KernelType", Test_KernelType },
{ "MmSection", Test_MmSection },
{ "ObReference", Test_ObReference },
Added: trunk/rostests/kmtests/ntos_ke/KeTimer.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/kmtests/ntos_ke/KeTimer.c…
==============================================================================
--- trunk/rostests/kmtests/ntos_ke/KeTimer.c (added)
+++ trunk/rostests/kmtests/ntos_ke/KeTimer.c [iso-8859-1] Fri Oct 7 16:13:03 2011
@@ -1,0 +1,70 @@
+/*
+ * PROJECT: ReactOS kernel-mode tests
+ * LICENSE: GPLv2+ - See COPYING in the top level directory
+ * PURPOSE: Kernel-Mode Test Suite Timer test
+ * PROGRAMMER: Rafal Harabien <rafalh(a)reactos.org>
+ */
+
+#include <kmt_test.h>
+
+#define CheckTimer(Timer, ExpectedType, State, ExpectedWaitNext, \
+ Irql, ThreadList, ThreadCount) do \
+{ \
+ INT TheIndex; \
+ PLIST_ENTRY TheEntry; \
+ PKTHREAD TheThread; \
+ ok_eq_uint((Timer)->Header.Type, ExpectedType); \
+ ok_eq_uint((Timer)->Header.Hand, sizeof *(Timer) / sizeof(ULONG)); \
+ ok_eq_hex((Timer)->Header.Lock & 0xFF00FF00L, 0x00005500L); \
+ ok_eq_long((Timer)->Header.SignalState, State); \
+ TheEntry = (Timer)->Header.WaitListHead.Flink; \
+ for (TheIndex = 0; TheIndex < (ThreadCount); ++TheIndex) \
+ { \
+ TheThread = CONTAINING_RECORD(TheEntry, KTHREAD, \
+ WaitBlock[0].WaitListEntry); \
+ ok_eq_pointer(TheThread, (ThreadList)[TheIndex]); \
+ ok_eq_pointer(TheEntry->Flink->Blink, TheEntry); \
+ TheEntry = TheEntry->Flink; \
+ } \
+ ok_eq_pointer(TheEntry, &(Timer)->Header.WaitListHead); \
+ ok_eq_pointer(TheEntry->Flink->Blink, TheEntry); \
+ ok_eq_long(KeReadStateTimer(Timer), State); \
+ ok_eq_bool(Thread->WaitNext, ExpectedWaitNext); \
+ ok_irql(Irql); \
+} while (0)
+
+static
+VOID
+TestTimerFunctional(
+ IN PKTIMER Timer,
+ IN TIMER_TYPE Type,
+ IN KIRQL OriginalIrql)
+{
+ PKTHREAD Thread = KeGetCurrentThread();
+
+ memset(Timer, 0x55, sizeof *Timer);
+ KeInitializeTimerEx(Timer, Type);
+ CheckTimer(Timer, TimerNotificationObject + Type, 0L, FALSE, OriginalIrql, (PVOID
*)NULL, 0);
+}
+
+START_TEST(KeTimer)
+{
+ KTIMER Timer;
+ KIRQL Irql;
+ KIRQL Irqls[] = { PASSIVE_LEVEL, APC_LEVEL, DISPATCH_LEVEL, HIGH_LEVEL };
+ INT i;
+
+ for (i = 0; i < sizeof Irqls / sizeof Irqls[0]; ++i)
+ {
+ /* DRIVER_IRQL_NOT_LESS_OR_EQUAL (TODO: on MP only?) */
+ if (Irqls[i] > DISPATCH_LEVEL && KmtIsCheckedBuild)
+ return;
+ KeRaiseIrql(Irqls[i], &Irql);
+ TestTimerFunctional(&Timer, NotificationTimer, Irqls[i]);
+ TestTimerFunctional(&Timer, SynchronizationTimer, Irqls[i]);
+ KeLowerIrql(Irql);
+ }
+
+ ok_irql(PASSIVE_LEVEL);
+ KmtSetIrql(PASSIVE_LEVEL);
+}
Propchange: trunk/rostests/kmtests/ntos_ke/KeTimer.c
------------------------------------------------------------------------------
svn:eol-style = native