1 /* used by ExSingleList and ExSequencedList tests */
2 static
3 VOID
4 TestXListFunctional(
5     IN PXLIST_HEADER ListHead,
6     IN PXLIST_ENTRY Entries,
7     IN PKSPIN_LOCK pSpinLock)
8 {
9     USHORT ExpectedSequence = 0;
10     PXLIST_ENTRY Ret;
11 
12     Ret = FlushXList(ListHead);
13     ok_eq_pointer(Ret, NULL);
14     CheckXListHeader(ListHead, NULL, 0);
15 
16     Ret = PopXList(ListHead, pSpinLock);
17     ok_eq_pointer(Ret, NULL);
18     CheckXListHeader(ListHead, NULL, 0);
19 
20     Ret = PushXList(ListHead, &Entries[0], pSpinLock);
21     ++ExpectedSequence;
22     ok_eq_pointer(Ret, NULL);
23     ok_eq_pointer(Entries[0].Next, NULL);
24     CheckXListHeader(ListHead, &Entries[0], 1);
25 
26     Ret = PushXList(ListHead, &Entries[1], pSpinLock);
27     ++ExpectedSequence;
28     ok_eq_pointer(Ret, &Entries[0]);
29     ok_eq_pointer(Entries[0].Next, NULL);
30     ok_eq_pointer(Entries[1].Next, &Entries[0]);
31     CheckXListHeader(ListHead, &Entries[1], 2);
32 
33     Ret = PopXList(ListHead, pSpinLock);
34     ok_eq_pointer(Ret, &Entries[1]);
35     ok_eq_pointer(Entries[0].Next, NULL);
36     ok_free_xlist(Entries[1].Next, &Entries[0]);
37     CheckXListHeader(ListHead, &Entries[0], 1);
38 
39     Ret = PopXList(ListHead, pSpinLock);
40     ok_eq_pointer(Ret, &Entries[0]);
41     ok_free_xlist(Entries[0].Next, NULL);
42     ok_free_xlist(Entries[1].Next, &Entries[0]);
43     CheckXListHeader(ListHead, NULL, 0);
44 
45     Ret = PopXList(ListHead, pSpinLock);
46     ok_eq_pointer(Ret, NULL);
47     ok_free_xlist(Entries[0].Next, NULL);
48     ok_free_xlist(Entries[1].Next, &Entries[0]);
49     CheckXListHeader(ListHead, NULL, 0);
50 
51     /* add entries again */
52     Ret = PushXList(ListHead, &Entries[0], pSpinLock);
53     ++ExpectedSequence;
54     ok_eq_pointer(Ret, NULL);
55     ok_eq_pointer(Entries[0].Next, NULL);
56     CheckXListHeader(ListHead, &Entries[0], 1);
57 
58     Ret = PushXList(ListHead, &Entries[1], pSpinLock);
59     ++ExpectedSequence;
60     ok_eq_pointer(Ret, &Entries[0]);
61     ok_eq_pointer(Entries[0].Next, NULL);
62     ok_eq_pointer(Entries[1].Next, &Entries[0]);
63     CheckXListHeader(ListHead, &Entries[1], 2);
64 
65     Ret = PopXList(ListHead, pSpinLock);
66     ok_eq_pointer(Ret, &Entries[1]);
67     ok_eq_pointer(Entries[0].Next, NULL);
68     ok_free_xlist(Entries[1].Next, &Entries[0]);
69     CheckXListHeader(ListHead, &Entries[0], 1);
70 
71     Ret = PushXList(ListHead, &Entries[1], pSpinLock);
72     ++ExpectedSequence;
73     ok_eq_pointer(Ret, &Entries[0]);
74     ok_eq_pointer(Entries[0].Next, NULL);
75     ok_eq_pointer(Entries[1].Next, &Entries[0]);
76     CheckXListHeader(ListHead, &Entries[1], 2);
77 
78     Ret = PushXList(ListHead, &Entries[2], pSpinLock);
79     ++ExpectedSequence;
80     ok_eq_pointer(Ret, &Entries[1]);
81     ok_eq_pointer(Entries[0].Next, NULL);
82     ok_eq_pointer(Entries[1].Next, &Entries[0]);
83     ok_eq_pointer(Entries[2].Next, &Entries[1]);
84     CheckXListHeader(ListHead, &Entries[2], 3);
85 
86     Ret = FlushXList(ListHead);
87     ok_eq_pointer(Ret, &Entries[2]);
88     CheckXListHeader(ListHead, NULL, 0);
89 }
90 
91 #undef TestXListFunctional
92