ReactOS  0.4.14-dev-376-gaedba84
ExSequencedList.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 sequenced singly-linked list test
5  * PROGRAMMER: Thomas Faber <thomas.faber@reactos.org>
6  */
7 
8 struct _SINGLE_LIST_ENTRY;
9 union _SLIST_HEADER;
12 
13 #include <kmt_test.h>
14 
15 /* TODO: SLIST_HEADER is a lot different for x64 */
16 #ifndef _M_AMD64
17 #define CheckSListHeader(ListHead, ExpectedPointer, ExpectedDepth) do \
18 { \
19  ok_eq_pointer((ListHead)->Next.Next, ExpectedPointer); \
20  /*ok_eq_pointer(FirstEntrySList(ListHead), ExpectedPointer);*/ \
21  ok_eq_uint((ListHead)->Depth, ExpectedDepth); \
22  ok_eq_uint((ListHead)->Sequence, ExpectedSequence); \
23  ok_eq_uint(ExQueryDepthSList(ListHead), ExpectedDepth); \
24  ok_irql(HIGH_LEVEL); \
25  ok_bool_true(KmtAreInterruptsEnabled(), "Interrupts enabled:"); \
26 } while (0)
27 
28 #define PXLIST_HEADER PSLIST_HEADER
29 #define PXLIST_ENTRY PSLIST_ENTRY
30 #define PushXList ExInterlockedPushEntrySList
31 #define PopXList ExInterlockedPopEntrySList
32 #define FlushXList ExInterlockedFlushSList
33 #define ok_free_xlist ok_eq_pointer
34 #define CheckXListHeader CheckSListHeader
35 #define TestXListFunctional TestSListFunctional
36 #include "ExXList.h"
37 
38 #undef ExInterlockedPushEntrySList
39 #undef ExInterlockedPopEntrySList
40 #define TestXListFunctional TestSListFunctionalExports
41 #include "ExXList.h"
42 #endif
43 
44 START_TEST(ExSequencedList)
45 {
46 #ifndef _M_AMD64
47  PSLIST_HEADER ListHead;
49  USHORT ExpectedSequence = 0;
50  PKSPIN_LOCK pSpinLock = &SpinLock;
51  PCHAR Buffer;
53  SIZE_T EntriesSize = 5 * sizeof *Entries;
54  KIRQL Irql;
55 
57 #ifdef _M_IX86
58  pSpinLock = NULL;
59 #endif
60 
61  /* make sure stuff is as un-aligned as possible ;) */
62  Buffer = ExAllocatePoolWithTag(NonPagedPool, sizeof *ListHead + EntriesSize + 1, 'TLqS');
63  ListHead = (PVOID)&Buffer[1];
64  Entries = (PVOID)&ListHead[1];
66 
67  RtlFillMemory(Entries, EntriesSize, 0x55);
68  RtlFillMemory(ListHead, sizeof *ListHead, 0x55);
69  InitializeSListHead(ListHead);
70  CheckSListHeader(ListHead, NULL, 0);
71  TestSListFunctional(ListHead, Entries, pSpinLock);
72 
73  RtlFillMemory(Entries, EntriesSize, 0x55);
74  RtlFillMemory(ListHead, sizeof *ListHead, 0x55);
75  ExInitializeSListHead(ListHead);
76  CheckSListHeader(ListHead, NULL, 0);
77  TestSListFunctionalExports(ListHead, Entries, pSpinLock);
78 
80  ExFreePoolWithTag(Buffer, 'TLqS');
81 #endif
82 }
signed char * PCHAR
Definition: retypes.h:7
#define KeRaiseIrql(irql, oldIrql)
Definition: env_spec_w32.h:597
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
Definition: ntbasedef.h:635
#define __fastcall
Definition: sync.c:41
START_TEST(ExSequencedList)
struct _SINGLE_LIST_ENTRY *__fastcall ExInterlockedPushEntrySList(union _SLIST_HEADER *, struct _SINGLE_LIST_ENTRY *, unsigned long *)
KSPIN_LOCK * PKSPIN_LOCK
Definition: env_spec_w32.h:73
_Out_ PKIRQL Irql
Definition: csq.h:179
_In_ PKSERVICE_ROUTINE _In_opt_ PVOID _In_opt_ PKSPIN_LOCK SpinLock
Definition: iofuncs.h:798
UCHAR KIRQL
Definition: env_spec_w32.h:591
struct _SINGLE_LIST_ENTRY *__fastcall ExInterlockedPopEntrySList(union _SLIST_HEADER *, unsigned long *)
FORCEINLINE VOID KeInitializeSpinLock(_Out_ PKSPIN_LOCK SpinLock)
Definition: kefuncs.h:251
smooth NULL
Definition: ftsmooth.c:416
#define CheckSListHeader(ListHead, ExpectedPointer, ExpectedDepth)
Definition: bufpool.h:45
void * PVOID
Definition: retypes.h:9
FORCEINLINE VOID InitializeSListHead(_Out_ PSLIST_HEADER SListHead)
Definition: rtlfuncs.h:3353
#define PSLIST_ENTRY
Definition: rtltypes.h:130
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
ULONG_PTR SIZE_T
Definition: typedefs.h:78
#define HIGH_LEVEL
Definition: env_spec_w32.h:703
LIST_ENTRY Entries[5]
Definition: ExDoubleList.c:8
unsigned short USHORT
Definition: pedump.c:61
ULONG KSPIN_LOCK
Definition: env_spec_w32.h:72
#define ExInitializeSListHead
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
#define RtlFillMemory(Dest, Length, Fill)
Definition: winternl.h:593