Author: tfaber
Date: Wed Aug 24 14:09:53 2011
New Revision: 53419
URL:
http://svn.reactos.org/svn/reactos?rev=53419&view=rev
Log:
[KMTESTS/IO]
- Add IoInterrupt test with a simple test for KeSynchronizeExecution
Added:
branches/GSoC_2011/KMTestSuite/kmtests/ntos_io/IoInterrupt.c (with props)
Modified:
branches/GSoC_2011/KMTestSuite/kmtests/CMakeLists.txt
branches/GSoC_2011/KMTestSuite/kmtests/kmtest_drv.rbuild
branches/GSoC_2011/KMTestSuite/kmtests/kmtest_drv/testlist.c
Modified: branches/GSoC_2011/KMTestSuite/kmtests/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/KMTestSuite/kmtests/C…
==============================================================================
--- branches/GSoC_2011/KMTestSuite/kmtests/CMakeLists.txt [iso-8859-1] (original)
+++ branches/GSoC_2011/KMTestSuite/kmtests/CMakeLists.txt [iso-8859-1] Wed Aug 24 14:09:53
2011
@@ -27,6 +27,7 @@
ntos_ex/ExTimer.c
ntos_fsrtl/FsRtlExpression.c
ntos_io/IoDeviceInterface.c
+ ntos_io/IoInterrupt.c
ntos_io/IoIrp.c
ntos_io/IoMdl.c
ntos_ke/KeApc.c
Modified: branches/GSoC_2011/KMTestSuite/kmtests/kmtest_drv.rbuild
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/KMTestSuite/kmtests/k…
==============================================================================
--- branches/GSoC_2011/KMTestSuite/kmtests/kmtest_drv.rbuild [iso-8859-1] (original)
+++ branches/GSoC_2011/KMTestSuite/kmtests/kmtest_drv.rbuild [iso-8859-1] Wed Aug 24
14:09:53 2011
@@ -30,6 +30,7 @@
</directory>
<directory name="ntos_io">
<file>IoDeviceInterface.c</file>
+ <file>IoInterrupt.c</file>
<file>IoIrp.c</file>
<file>IoMdl.c</file>
</directory>
Modified: branches/GSoC_2011/KMTestSuite/kmtests/kmtest_drv/testlist.c
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/KMTestSuite/kmtests/k…
==============================================================================
--- branches/GSoC_2011/KMTestSuite/kmtests/kmtest_drv/testlist.c [iso-8859-1] (original)
+++ branches/GSoC_2011/KMTestSuite/kmtests/kmtest_drv/testlist.c [iso-8859-1] Wed Aug 24
14:09:53 2011
@@ -20,6 +20,7 @@
KMT_TESTFUNC Test_ExTimer;
KMT_TESTFUNC Test_FsRtlExpression;
KMT_TESTFUNC Test_IoDeviceInterface;
+KMT_TESTFUNC Test_IoInterrupt;
KMT_TESTFUNC Test_IoIrp;
KMT_TESTFUNC Test_IoMdl;
KMT_TESTFUNC Test_KeApc;
@@ -51,6 +52,7 @@
{ "Example", Test_Example },
{ "FsRtlExpression", Test_FsRtlExpression },
{ "IoDeviceInterface", Test_IoDeviceInterface },
+ { "IoInterrupt", Test_IoInterrupt },
{ "IoIrp", Test_IoIrp },
{ "IoMdl", Test_IoMdl },
{ "KeApc", Test_KeApc },
Added: branches/GSoC_2011/KMTestSuite/kmtests/ntos_io/IoInterrupt.c
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/KMTestSuite/kmtests/n…
==============================================================================
--- branches/GSoC_2011/KMTestSuite/kmtests/ntos_io/IoInterrupt.c (added)
+++ branches/GSoC_2011/KMTestSuite/kmtests/ntos_io/IoInterrupt.c [iso-8859-1] Wed Aug 24
14:09:53 2011
@@ -1,0 +1,95 @@
+/*
+ * PROJECT: ReactOS kernel-mode tests
+ * LICENSE: GPLv2+ - See COPYING in the top level directory
+ * PURPOSE: Kernel-Mode Test Suite Interrupt test
+ * PROGRAMMER: Thomas Faber <thfabba(a)gmx.de>
+ */
+
+#include <kmt_test.h>
+
+#define NDEBUG
+#include <debug.h>
+
+#define CheckSpinLock(Lock, Locked) do \
+{ \
+ if (KmtIsMultiProcessorBuild) \
+ ok_eq_ulongptr(*(Lock), (Locked) != 0); \
+ else \
+ ok_eq_ulongptr(*(Lock), 0); \
+} while (0)
+
+typedef struct
+{
+ BOOLEAN ReturnValue;
+ KIRQL ExpectedIrql;
+ PKINTERRUPT Interrupt;
+} TEST_CONTEXT, *PTEST_CONTEXT;
+
+static KSYNCHRONIZE_ROUTINE SynchronizeRoutine;
+
+static
+BOOLEAN
+NTAPI
+SynchronizeRoutine(
+ IN PVOID Context)
+{
+ PTEST_CONTEXT TestContext = Context;
+
+ ok_irql(TestContext->ExpectedIrql);
+
+ CheckSpinLock(TestContext->Interrupt->ActualLock, TRUE);
+
+ return TestContext->ReturnValue;
+}
+
+static
+VOID
+TestSynchronizeExecution(VOID)
+{
+ KINTERRUPT Interrupt;
+ TEST_CONTEXT TestContext;
+ KIRQL SynchIrql;
+ KIRQL OriginalIrql;
+ KIRQL Irql;
+ KSPIN_LOCK ActualLock;
+ BOOLEAN Ret;
+
+ RtlFillMemory(&Interrupt, sizeof Interrupt, 0x55);
+ Interrupt.ActualLock = &ActualLock;
+ KeInitializeSpinLock(Interrupt.ActualLock);
+ CheckSpinLock(Interrupt.ActualLock, FALSE);
+
+ TestContext.Interrupt = &Interrupt;
+ TestContext.ReturnValue = TRUE;
+
+ for (TestContext.ReturnValue = 0; TestContext.ReturnValue <= 2;
++TestContext.ReturnValue)
+ {
+ for (OriginalIrql = PASSIVE_LEVEL; OriginalIrql <= HIGH_LEVEL;
++OriginalIrql)
+ {
+ /* TODO: don't hardcode this :| */
+ if (OriginalIrql == 3 || (OriginalIrql >= 11 && OriginalIrql <=
26) || OriginalIrql == 30)
+ continue;
+ KeRaiseIrql(OriginalIrql, &Irql);
+ for (SynchIrql = max(DISPATCH_LEVEL, OriginalIrql); SynchIrql <=
HIGH_LEVEL; ++SynchIrql)
+ {
+ if (SynchIrql == 3 || (SynchIrql >= 11 && SynchIrql <= 26)
|| SynchIrql == 30)
+ continue;
+ Interrupt.SynchronizeIrql = SynchIrql;
+ ok_irql(OriginalIrql);
+ CheckSpinLock(Interrupt.ActualLock, FALSE);
+ TestContext.ExpectedIrql = SynchIrql;
+ Ret = KeSynchronizeExecution(&Interrupt, SynchronizeRoutine,
&TestContext);
+ ok_eq_int(Ret, TestContext.ReturnValue);
+ ok_irql(OriginalIrql);
+ CheckSpinLock(Interrupt.ActualLock, FALSE);
+ /* TODO: Check that all other fields of the interrupt are untouched */
+ }
+ KeLowerIrql(Irql);
+ }
+ }
+}
+
+START_TEST(IoInterrupt)
+{
+ TestSynchronizeExecution();
+}
Propchange: branches/GSoC_2011/KMTestSuite/kmtests/ntos_io/IoInterrupt.c
------------------------------------------------------------------------------
svn:eol-style = native