ReactOS 0.4.16-dev-1946-g52006dd
IoInterrupt.c File Reference
#include <kmt_test.h>
#include <debug.h>
Include dependency graph for IoInterrupt.c:

Go to the source code of this file.

Classes

struct  TEST_CONTEXT
 

Macros

#define NDEBUG
 
#define CheckSpinLock(Lock, Locked)
 

Typedefs

typedef struct TEST_CONTEXTPTEST_CONTEXT
 

Functions

static BOOLEAN NTAPI SynchronizeRoutine (IN PVOID Context)
 
static VOID TestSynchronizeExecution (VOID)
 
static VOID TestConnectInterrupt (VOID)
 
 START_TEST (IoInterrupt)
 

Variables

static KSYNCHRONIZE_ROUTINE SynchronizeRoutine
 

Macro Definition Documentation

◆ CheckSpinLock

#define CheckSpinLock (   Lock,
  Locked 
)
Value:
do \
{ \
ok_eq_ulongptr(*(Lock), (Locked) != 0); \
else if (KmtIsCheckedBuild) \
ok_eq_bool(*(Lock) != 0, (Locked) != 0); \
else \
ok_eq_ulongptr(*(Lock), 0); \
} while (0)
BOOLEAN KmtIsCheckedBuild
BOOLEAN KmtIsMultiProcessorBuild
_In_ PMEMORY_AREA _In_ PVOID _In_ BOOLEAN Locked
Definition: newmm.h:209
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWAITLOCK * Lock
Definition: wdfsync.h:127

Definition at line 13 of file IoInterrupt.c.

◆ NDEBUG

#define NDEBUG

Definition at line 10 of file IoInterrupt.c.

Typedef Documentation

◆ PTEST_CONTEXT

Function Documentation

◆ START_TEST()

START_TEST ( IoInterrupt  )

Definition at line 123 of file IoInterrupt.c.

124{
127}
static VOID TestConnectInterrupt(VOID)
Definition: IoInterrupt.c:99
static VOID TestSynchronizeExecution(VOID)
Definition: IoInterrupt.c:49

◆ SynchronizeRoutine()

static BOOLEAN NTAPI SynchronizeRoutine ( IN PVOID  Context)
static

Definition at line 35 of file IoInterrupt.c.

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}
#define CheckSpinLock(Lock, Locked)
Definition: IoInterrupt.c:13
#define TRUE
Definition: types.h:120

◆ TestConnectInterrupt()

static VOID TestConnectInterrupt ( VOID  )
static

Definition at line 99 of file IoInterrupt.c.

100{
103
104 /* If the IoConnectInterrupt() fails, the interrupt object should be set to NULL */
106
107 /* Test for invalid interrupt */
110 NULL,
111 NULL,
112 0,
113 0,
114 0,
116 TRUE,
117 (KAFFINITY)-1,
118 FALSE);
121}
#define ok_eq_pointer(value, expected)
Definition: apitest.h:116
#define ok_eq_hex(value, expected)
Definition: apitest.h:134
LONG NTSTATUS
Definition: precomp.h:26
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
ULONG_PTR KAFFINITY
Definition: compat.h:85
Status
Definition: gdiplustypes.h:25
#define KmtInvalidPointer
Definition: kmt_test.h:283
@ 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
@ LevelSensitive
Definition: miniport.h:80
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
KSERVICE_ROUTINE * PKSERVICE_ROUTINE
Definition: ketypes.h:564

Referenced by START_TEST(), and TestConnectInterrupt().

◆ TestSynchronizeExecution()

static VOID TestSynchronizeExecution ( VOID  )
static

Definition at line 49 of file IoInterrupt.c.

50{
52 TEST_CONTEXT TestContext;
53 KIRQL SynchIrql;
54 KIRQL OriginalIrql;
55 KIRQL Irql;
56 KSPIN_LOCK ActualLock;
57 BOOLEAN Ret;
58
59 if (skip(GetNTVersion() < _WIN32_WINNT_VISTA, "We can't create fake interrupts on Vista+.\n"))
60 return;
61
62 RtlFillMemory(&Interrupt, sizeof Interrupt, 0x55);
63 Interrupt.ActualLock = &ActualLock;
65 CheckSpinLock(Interrupt.ActualLock, FALSE);
66
67 TestContext.Interrupt = &Interrupt;
68 TestContext.ReturnValue = TRUE;
69
70 for (TestContext.ReturnValue = 0; TestContext.ReturnValue <= 2; ++TestContext.ReturnValue)
71 {
72 for (OriginalIrql = PASSIVE_LEVEL; OriginalIrql <= HIGH_LEVEL; ++OriginalIrql)
73 {
74 /* TODO: don't hardcode this :| */
75 if (OriginalIrql == 3 || (OriginalIrql >= 11 && OriginalIrql <= 26) || OriginalIrql == 30)
76 continue;
77 KeRaiseIrql(OriginalIrql, &Irql);
78 for (SynchIrql = max(DISPATCH_LEVEL, OriginalIrql); SynchIrql <= HIGH_LEVEL; ++SynchIrql)
79 {
80 if (SynchIrql == 3 || (SynchIrql >= 11 && SynchIrql <= 26) || SynchIrql == 30)
81 continue;
82 Interrupt.SynchronizeIrql = SynchIrql;
83 ok_irql(OriginalIrql);
84 CheckSpinLock(Interrupt.ActualLock, FALSE);
85 TestContext.ExpectedIrql = SynchIrql;
87 ok_eq_int(Ret, TestContext.ReturnValue);
88 ok_irql(OriginalIrql);
89 CheckSpinLock(Interrupt.ActualLock, FALSE);
90 /* TODO: Check that all other fields of the interrupt are untouched */
91 }
93 }
94 }
95}
static KSYNCHRONIZE_ROUTINE SynchronizeRoutine
Definition: IoInterrupt.c:30
unsigned char BOOLEAN
#define GetNTVersion()
Definition: apitest.h:17
#define ok_eq_int(value, expected)
Definition: apitest.h:117
#define skip(...)
Definition: atltest.h:64
_Out_ PKIRQL Irql
Definition: csq.h:179
#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
#define RtlFillMemory(Dest, Length, Fill)
Definition: winternl.h:603
BOOLEAN NTAPI KeSynchronizeExecution(IN OUT PKINTERRUPT Interrupt, IN PKSYNCHRONIZE_ROUTINE SynchronizeRoutine, IN PVOID SynchronizeContext OPTIONAL)
Definition: interrupt.c:237
#define _WIN32_WINNT_VISTA
Definition: sdkddkver.h:25
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
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_INTERRUPT_CONFIG _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFINTERRUPT * Interrupt
Definition: wdfinterrupt.h:379

Referenced by START_TEST().

Variable Documentation

◆ SynchronizeRoutine

KSYNCHRONIZE_ROUTINE SynchronizeRoutine
static