mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 17:52:56 +00:00
[KMTESTS/IO]
- Add IoInterrupt test with a simple test for KeSynchronizeExecution svn path=/branches/GSoC_2011/KMTestSuite/; revision=53419
This commit is contained in:
parent
d496caa768
commit
097a8b8733
4 changed files with 99 additions and 0 deletions
|
@ -27,6 +27,7 @@ list(APPEND KMTEST_DRV_SOURCE
|
||||||
ntos_ex/ExTimer.c
|
ntos_ex/ExTimer.c
|
||||||
ntos_fsrtl/FsRtlExpression.c
|
ntos_fsrtl/FsRtlExpression.c
|
||||||
ntos_io/IoDeviceInterface.c
|
ntos_io/IoDeviceInterface.c
|
||||||
|
ntos_io/IoInterrupt.c
|
||||||
ntos_io/IoIrp.c
|
ntos_io/IoIrp.c
|
||||||
ntos_io/IoMdl.c
|
ntos_io/IoMdl.c
|
||||||
ntos_ke/KeApc.c
|
ntos_ke/KeApc.c
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
</directory>
|
</directory>
|
||||||
<directory name="ntos_io">
|
<directory name="ntos_io">
|
||||||
<file>IoDeviceInterface.c</file>
|
<file>IoDeviceInterface.c</file>
|
||||||
|
<file>IoInterrupt.c</file>
|
||||||
<file>IoIrp.c</file>
|
<file>IoIrp.c</file>
|
||||||
<file>IoMdl.c</file>
|
<file>IoMdl.c</file>
|
||||||
</directory>
|
</directory>
|
||||||
|
|
|
@ -20,6 +20,7 @@ KMT_TESTFUNC Test_ExSingleList;
|
||||||
KMT_TESTFUNC Test_ExTimer;
|
KMT_TESTFUNC Test_ExTimer;
|
||||||
KMT_TESTFUNC Test_FsRtlExpression;
|
KMT_TESTFUNC Test_FsRtlExpression;
|
||||||
KMT_TESTFUNC Test_IoDeviceInterface;
|
KMT_TESTFUNC Test_IoDeviceInterface;
|
||||||
|
KMT_TESTFUNC Test_IoInterrupt;
|
||||||
KMT_TESTFUNC Test_IoIrp;
|
KMT_TESTFUNC Test_IoIrp;
|
||||||
KMT_TESTFUNC Test_IoMdl;
|
KMT_TESTFUNC Test_IoMdl;
|
||||||
KMT_TESTFUNC Test_KeApc;
|
KMT_TESTFUNC Test_KeApc;
|
||||||
|
@ -51,6 +52,7 @@ const KMT_TEST TestList[] =
|
||||||
{ "Example", Test_Example },
|
{ "Example", Test_Example },
|
||||||
{ "FsRtlExpression", Test_FsRtlExpression },
|
{ "FsRtlExpression", Test_FsRtlExpression },
|
||||||
{ "IoDeviceInterface", Test_IoDeviceInterface },
|
{ "IoDeviceInterface", Test_IoDeviceInterface },
|
||||||
|
{ "IoInterrupt", Test_IoInterrupt },
|
||||||
{ "IoIrp", Test_IoIrp },
|
{ "IoIrp", Test_IoIrp },
|
||||||
{ "IoMdl", Test_IoMdl },
|
{ "IoMdl", Test_IoMdl },
|
||||||
{ "KeApc", Test_KeApc },
|
{ "KeApc", Test_KeApc },
|
||||||
|
|
95
kmtests/ntos_io/IoInterrupt.c
Normal file
95
kmtests/ntos_io/IoInterrupt.c
Normal file
|
@ -0,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@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();
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue