ReactOS 0.4.16-dev-303-g11d5cb8
IoInterrupt.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS kernel-mode tests
3 * LICENSE: GPLv2+ - See COPYING in the top level directory
4 * PURPOSE: Kernel-Mode Test Suite Interrupt test
5 * PROGRAMMER: Thomas Faber <thomas.faber@reactos.org>
6 */
7
8#include <kmt_test.h>
9
10#define NDEBUG
11#include <debug.h>
12
13#define CheckSpinLock(Lock, Locked) do \
14{ \
15 if (KmtIsMultiProcessorBuild) \
16 ok_eq_ulongptr(*(Lock), (Locked) != 0); \
17 else if (KmtIsCheckedBuild) \
18 ok_eq_bool(*(Lock) != 0, (Locked) != 0); \
19 else \
20 ok_eq_ulongptr(*(Lock), 0); \
21} while (0)
22
23typedef struct
24{
29
30static KSYNCHRONIZE_ROUTINE SynchronizeRoutine;
31
32static
37{
38 PTEST_CONTEXT TestContext = Context;
39
40 ok_irql(TestContext->ExpectedIrql);
41
42 CheckSpinLock(TestContext->Interrupt->ActualLock, TRUE);
43
44 return TestContext->ReturnValue;
45}
46
47static
48VOID
50{
52 TEST_CONTEXT TestContext;
53 KIRQL SynchIrql;
54 KIRQL OriginalIrql;
55 KIRQL Irql;
56 KSPIN_LOCK ActualLock;
57 BOOLEAN Ret;
58
59 RtlFillMemory(&Interrupt, sizeof Interrupt, 0x55);
60 Interrupt.ActualLock = &ActualLock;
62 CheckSpinLock(Interrupt.ActualLock, FALSE);
63
64 TestContext.Interrupt = &Interrupt;
65 TestContext.ReturnValue = TRUE;
66
67 for (TestContext.ReturnValue = 0; TestContext.ReturnValue <= 2; ++TestContext.ReturnValue)
68 {
69 for (OriginalIrql = PASSIVE_LEVEL; OriginalIrql <= HIGH_LEVEL; ++OriginalIrql)
70 {
71 /* TODO: don't hardcode this :| */
72 if (OriginalIrql == 3 || (OriginalIrql >= 11 && OriginalIrql <= 26) || OriginalIrql == 30)
73 continue;
74 KeRaiseIrql(OriginalIrql, &Irql);
75 for (SynchIrql = max(DISPATCH_LEVEL, OriginalIrql); SynchIrql <= HIGH_LEVEL; ++SynchIrql)
76 {
77 if (SynchIrql == 3 || (SynchIrql >= 11 && SynchIrql <= 26) || SynchIrql == 30)
78 continue;
79 Interrupt.SynchronizeIrql = SynchIrql;
80 ok_irql(OriginalIrql);
81 CheckSpinLock(Interrupt.ActualLock, FALSE);
82 TestContext.ExpectedIrql = SynchIrql;
84 ok_eq_int(Ret, TestContext.ReturnValue);
85 ok_irql(OriginalIrql);
86 CheckSpinLock(Interrupt.ActualLock, FALSE);
87 /* TODO: Check that all other fields of the interrupt are untouched */
88 }
90 }
91 }
92}
93
94static
95VOID
97{
100
101 /* If the IoConnectInterrupt() fails, the interrupt object should be set to NULL */
103
104 /* Test for invalid interrupt */
107 NULL,
108 NULL,
109 0,
110 0,
111 0,
113 TRUE,
114 (KAFFINITY)-1,
115 FALSE);
118}
119
120START_TEST(IoInterrupt)
121{
124}
static VOID TestConnectInterrupt(VOID)
Definition: IoInterrupt.c:96
#define CheckSpinLock(Lock, Locked)
Definition: IoInterrupt.c:13
static KSYNCHRONIZE_ROUTINE SynchronizeRoutine
Definition: IoInterrupt.c:30
struct TEST_CONTEXT * PTEST_CONTEXT
static VOID TestSynchronizeExecution(VOID)
Definition: IoInterrupt.c:49
unsigned char BOOLEAN
#define ok_eq_pointer(value, expected)
Definition: apitest.h:59
#define ok_eq_hex(value, expected)
Definition: apitest.h:77
#define ok_eq_int(value, expected)
Definition: apitest.h:60
#define START_TEST(x)
Definition: atltest.h:75
LONG NTSTATUS
Definition: precomp.h:26
_Out_ PKIRQL Irql
Definition: csq.h:179
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
ULONG_PTR KAFFINITY
Definition: compat.h:85
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
UCHAR KIRQL
Definition: env_spec_w32.h:591
ULONG KSPIN_LOCK
Definition: env_spec_w32.h:72
#define KeRaiseIrql(irql, oldIrql)
Definition: env_spec_w32.h:597
#define HIGH_LEVEL
Definition: env_spec_w32.h:703
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
#define KeInitializeSpinLock(sl)
Definition: env_spec_w32.h:604
Status
Definition: gdiplustypes.h:25
#define RtlFillMemory(Dest, Length, Fill)
Definition: winternl.h:599
#define KmtInvalidPointer
Definition: kmt_test.h:280
@ InterruptObject
Definition: ketypes.h:428
NTSTATUS NTAPI IoConnectInterrupt(OUT PKINTERRUPT *InterruptObject, IN PKSERVICE_ROUTINE ServiceRoutine, IN PVOID ServiceContext, IN PKSPIN_LOCK SpinLock, IN ULONG Vector, IN KIRQL Irql, IN KIRQL SynchronizeIrql, IN KINTERRUPT_MODE InterruptMode, IN BOOLEAN ShareVector, IN KAFFINITY ProcessorEnableMask, IN BOOLEAN FloatingSave)
Definition: irq.c:23
BOOLEAN NTAPI KeSynchronizeExecution(IN OUT PKINTERRUPT Interrupt, IN PKSYNCHRONIZE_ROUTINE SynchronizeRoutine, IN PVOID SynchronizeContext OPTIONAL)
Definition: interrupt.c:237
@ LevelSensitive
Definition: miniport.h:80
PKINTERRUPT Interrupt
Definition: IoInterrupt.c:27
BOOLEAN ReturnValue
Definition: IoInterrupt.c:25
KIRQL ExpectedIrql
Definition: IoInterrupt.c:26
#define max(a, b)
Definition: svc.c:63
#define NTAPI
Definition: typedefs.h:36
#define IN
Definition: typedefs.h:39
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_INTERRUPT_CONFIG _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFINTERRUPT * Interrupt
Definition: wdfinterrupt.h:379
KSERVICE_ROUTINE * PKSERVICE_ROUTINE
Definition: ketypes.h:512