ReactOS 0.4.16-dev-297-gc569aee
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
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
83START_TEST(ExSingleList)
84{
86 PSINGLE_LIST_ENTRY ListHead;
88 SIZE_T EntriesSize = 5 * sizeof *Entries;
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
113 ExFreePoolWithTag(Buffer, 'TLiS');
114}
PSINGLE_LIST_ENTRY FlushList(PSINGLE_LIST_ENTRY ListHead)
Definition: ExSingleList.c:24
PSINGLE_LIST_ENTRY PushEntryListWrapper(PSINGLE_LIST_ENTRY ListHead, PSINGLE_LIST_ENTRY Entry, PKSPIN_LOCK Lock)
Definition: ExSingleList.c:42
USHORT QueryDepthList(PSINGLE_LIST_ENTRY ListHead)
Definition: ExSingleList.c:31
static const ENTRY Entries[]
#define START_TEST(x)
Definition: atltest.h:75
Definition: bufpool.h:45
_Out_ PKIRQL Irql
Definition: csq.h:179
#define NULL
Definition: types.h:112
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
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
KSPIN_LOCK * PKSPIN_LOCK
Definition: env_spec_w32.h:73
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
#define NonPagedPool
Definition: env_spec_w32.h:307
#define KeInitializeSpinLock(sl)
Definition: env_spec_w32.h:604
#define RtlFillMemory(Dest, Length, Fill)
Definition: winternl.h:599
PSINGLE_LIST_ENTRY NTAPI ExInterlockedPopEntryList(IN OUT PSINGLE_LIST_ENTRY ListHead, IN OUT PKSPIN_LOCK Lock)
Definition: interlocked.c:201
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
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:325
unsigned short USHORT
Definition: pedump.c:61
base of all file and directory entries
Definition: entries.h:83
Definition: ntbasedef.h:636
struct _SINGLE_LIST_ENTRY * Next
Definition: ntbasedef.h:637
void * PVOID
Definition: typedefs.h:50
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define __stdcall
Definition: typedefs.h:25
char * PCHAR
Definition: typedefs.h:51
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFSPINLOCK * SpinLock
Definition: wdfsync.h:228
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWAITLOCK * Lock
Definition: wdfsync.h:127
_In_opt_ PALLOCATE_FUNCTION _In_opt_ PFREE_FUNCTION _In_ ULONG _In_ SIZE_T _In_ ULONG _In_ USHORT Depth
Definition: exfuncs.h:819
FORCEINLINE VOID PushEntryList(_Inout_ PSINGLE_LIST_ENTRY ListHead, _Inout_ __drv_aliasesMem PSINGLE_LIST_ENTRY Entry)
Definition: rtlfuncs.h:256