ReactOS  0.4.15-dev-5606-gf34e425
ExSingleList.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 Singly-linked list test
5  * PROGRAMMER: Thomas Faber <thomas.faber@reactos.org>
6  */
7 
8 struct _SINGLE_LIST_ENTRY;
9 #ifdef _X86_
12 #endif
13 
14 #include <kmt_test.h>
15 
16 #define ok_eq_free2(Value, Expected) do \
17 { \
18  if (KmtIsCheckedBuild) \
19  ok_eq_pointer(Value, (PVOID)(ULONG_PTR)0xBADDD0FFBADDD0FFULL); \
20  else \
21  ok_eq_pointer(Value, Expected); \
22 } while (0)
23 
25 {
26  PSINGLE_LIST_ENTRY Ret = ListHead->Next;
27  ListHead->Next = NULL;
28  return Ret;
29 }
30 
32 {
33  USHORT Depth = 0;
34  while (ListHead->Next)
35  {
36  ++Depth;
37  ListHead = ListHead->Next;
38  }
39  return Depth;
40 }
41 
43 {
46  Ret = ListHead->Next;
47  PushEntryList(ListHead, Entry);
48  return Ret;
49 }
50 
51 #define CheckListHeader(ListHead, ExpectedPointer, ExpectedDepth) do \
52 { \
53  ok_eq_pointer((ListHead)->Next, ExpectedPointer); \
54  ok_eq_uint(QueryDepthList(ListHead), ExpectedDepth); \
55  ok_irql(HIGH_LEVEL); \
56  ok_bool_true(KmtAreInterruptsEnabled(), "Interrupts enabled:"); \
57 } while (0)
58 
59 #define PXLIST_HEADER PSINGLE_LIST_ENTRY
60 #define PXLIST_ENTRY PSINGLE_LIST_ENTRY
61 #define PushXList ExInterlockedPushEntryList
62 #define PopXList ExInterlockedPopEntryList
63 #define FlushXList FlushList
64 #define ok_free_xlist ok_eq_free2
65 #define CheckXListHeader CheckListHeader
66 #define TestXListFunctional TestListFunctional
67 #include "ExXList.h"
68 
69 #undef ExInterlockedPushEntryList
70 #undef ExInterlockedPopEntryList
71 #define TestXListFunctional TestListFunctionalExports
72 #include "ExXList.h"
73 
74 #undef PushXList
75 #define PushXList PushEntryListWrapper
76 #undef PopXList
77 #define PopXList(h, s) PopEntryList(h)
78 #undef ok_free_xlist
79 #define ok_free_xlist ok_eq_pointer
80 #define TestXListFunctional TestListFunctionalNoInterlocked
81 #include "ExXList.h"
82 
83 START_TEST(ExSingleList)
84 {
86  PSINGLE_LIST_ENTRY ListHead;
88  SIZE_T EntriesSize = 5 * sizeof *Entries;
89  PCHAR Buffer;
90  KIRQL Irql;
91 
93 
94  /* make sure stuff is as un-aligned as possible ;) */
95  Buffer = ExAllocatePoolWithTag(NonPagedPool, sizeof *ListHead + EntriesSize + 1, 'TLiS');
96  ListHead = (PVOID)&Buffer[1];
97  Entries = (PVOID)&ListHead[1];
99 
100  RtlFillMemory(Entries, sizeof(*Entries), 0x55);
101  ListHead->Next = NULL;
102  TestListFunctional(ListHead, Entries, &SpinLock);
103 
104  RtlFillMemory(Entries, sizeof(*Entries), 0x55);
105  ListHead->Next = NULL;
106  TestListFunctionalExports(ListHead, Entries, &SpinLock);
107 
108  RtlFillMemory(Entries, sizeof(*Entries), 0x55);
109  ListHead->Next = NULL;
110  TestListFunctionalNoInterlocked(ListHead, Entries, &SpinLock);
111 
112  KeLowerIrql(Irql);
113  ExFreePoolWithTag(Buffer, 'TLiS');
114 }
signed char * PCHAR
Definition: retypes.h:7
_In_opt_ PALLOCATE_FUNCTION _In_opt_ PFREE_FUNCTION _In_ ULONG _In_ SIZE_T _In_ ULONG _In_ USHORT Depth
Definition: exfuncs.h:814
PSINGLE_LIST_ENTRY NTAPI ExInterlockedPopEntryList(IN OUT PSINGLE_LIST_ENTRY ListHead, IN OUT PKSPIN_LOCK Lock)
Definition: interlocked.c:201
Definition: ntbasedef.h:628
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
KSPIN_LOCK * PKSPIN_LOCK
Definition: env_spec_w32.h:73
_Out_ PKIRQL Irql
Definition: csq.h:179
FORCEINLINE VOID PushEntryList(_Inout_ PSINGLE_LIST_ENTRY ListHead, _Inout_ __drv_aliasesMem PSINGLE_LIST_ENTRY Entry)
Definition: rtlfuncs.h:253
UCHAR KIRQL
Definition: env_spec_w32.h:591
PSINGLE_LIST_ENTRY NTAPI ExInterlockedPushEntryList(IN OUT PSINGLE_LIST_ENTRY ListHead, IN OUT PSINGLE_LIST_ENTRY ListEntry, IN OUT PKSPIN_LOCK Lock)
Definition: interlocked.c:227
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFSPINLOCK * SpinLock
Definition: wdfsync.h:225
FORCEINLINE VOID KeInitializeSpinLock(_Out_ PKSPIN_LOCK SpinLock)
Definition: kefuncs.h:240
START_TEST(ExSingleList)
Definition: ExSingleList.c:83
Definition: bufpool.h:45
void * PVOID
Definition: retypes.h:9
#define RtlFillMemory(Dest, Length, Fill)
Definition: winternl.h:593
#define __stdcall
Definition: typedefs.h:25
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
struct _SINGLE_LIST_ENTRY * Next
Definition: ntbasedef.h:629
PSINGLE_LIST_ENTRY FlushList(PSINGLE_LIST_ENTRY ListHead)
Definition: ExSingleList.c:24
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#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 NULL
Definition: types.h:112
VOID NTAPI KeRaiseIrql(KIRQL NewIrql, PKIRQL OldIrql)
Definition: spinlock.c:27
USHORT QueryDepthList(PSINGLE_LIST_ENTRY ListHead)
Definition: ExSingleList.c:31
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWAITLOCK * Lock
Definition: wdfsync.h:124
VOID NTAPI KeLowerIrql(KIRQL NewIrql)
Definition: spinlock.c:39
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
base of all file and directory entries
Definition: entries.h:82
PSINGLE_LIST_ENTRY PushEntryListWrapper(PSINGLE_LIST_ENTRY ListHead, PSINGLE_LIST_ENTRY Entry, PKSPIN_LOCK Lock)
Definition: ExSingleList.c:42