[KMTESTS:FSRTL]
[reactos.git] / rostests / kmtests / ntos_fsrtl / FsRtlMcb.c
1 /*
2 * PROJECT: ReactOS kernel-mode tests
3 * LICENSE: LGPLv2+ - See COPYING.LIB in the top level directory
4 * PURPOSE: Kernel-Mode Test Suite FsRtl Test
5 * PROGRAMMER: Pierre Schweitzer <pierre.schweitzer@reactos.org>
6 */
7
8 #include <kmt_test.h>
9
10 #define NDEBUG
11 #include <debug.h>
12
13 static VOID FsRtlMcbTest()
14 {
15 }
16
17 static VOID DumpAllRuns(PLARGE_MCB Mcb)
18 {
19 ULONG i;
20 LONGLONG Vbn, Lbn, Count;
21
22 trace("MCB %p:\n", Mcb);
23
24 for (i = 0; FsRtlGetNextLargeMcbEntry(Mcb, i, &Vbn, &Lbn, &Count); i++)
25 {
26 // print out vbn, lbn, and count
27 trace("\t[%I64d,%I64d,%I64d]\n", Vbn, Lbn, Count);
28 }
29 trace("\n");
30 }
31
32 static VOID FsRtlLargeMcbTest()
33 {
34 LARGE_MCB LargeMcb;
35 ULONG NbRuns, Index;
36 LONGLONG Vbn, Lbn, SectorCount, StartingLbn, CountFromStartingLbn;
37
38 FsRtlInitializeLargeMcb(&LargeMcb, PagedPool);
39
40 ok(FsRtlLookupLastLargeMcbEntry(&LargeMcb, &Vbn, &Lbn) == FALSE, "expected FALSE, got TRUE\n");
41 ok(FsRtlLookupLastLargeMcbEntryAndIndex(&LargeMcb, &Vbn, &Lbn, &Index) == FALSE, "expected FALSE, got TRUE\n");
42
43 ok(FsRtlAddLargeMcbEntry(&LargeMcb, 1, 1, 1024) == TRUE, "expected TRUE, got FALSE\n");
44 NbRuns = FsRtlNumberOfRunsInLargeMcb(&LargeMcb);
45 ok(NbRuns == 2, "Expected 2 runs, got: %lu\n", NbRuns);
46 DumpAllRuns(&LargeMcb); // [0,-1,1][1,1,1024] [vbn,lbn,sc]
47 ok(FsRtlLookupLastLargeMcbEntry(&LargeMcb, &Vbn, &Lbn) == TRUE, "expected TRUE, got FALSE\n");
48 ok(Vbn == 1024, "Expected Vbn 1024, got: %I64d\n", Vbn);
49 ok(Lbn == 1024, "Expected Lbn 1024, got: %I64d\n", Lbn);
50 ok(FsRtlLookupLastLargeMcbEntryAndIndex(&LargeMcb, &Vbn, &Lbn, &Index) == TRUE, "expected TRUE, got FALSE\n");
51 ok(Vbn == 1024, "Expected Vbn 1024, got: %I64d\n", Vbn);
52 ok(Lbn == 1024, "Expected Lbn 1024, got: %I64d\n", Lbn);
53 ok(Index == 1, "Expected Index 1, got: %lu\n", Index);
54
55 ok(FsRtlAddLargeMcbEntry(&LargeMcb, 2048, 2, 1024) == TRUE, "expected TRUE, got FALSE\n");
56 NbRuns = FsRtlNumberOfRunsInLargeMcb(&LargeMcb);
57 ok(NbRuns == 4, "Expected 4 runs, got: %lu\n", NbRuns);
58 DumpAllRuns(&LargeMcb); // [0,-1,1][1,1,1024][1025,-1,1023][2048,2,1024] ======= [(0,1) hole] [(1,1025)=>(1,1025)] [(1025, 2048) hole] [(2048,3072)=>(2,1026)]
59 ok(FsRtlLookupLastLargeMcbEntry(&LargeMcb, &Vbn, &Lbn) == TRUE, "expected TRUE, got FALSE\n");
60 ok(Vbn == 3071, "Expected Vbn 3071, got: %I64d\n", Vbn);
61 ok(Lbn == 1025, "Expected Lbn 1025, got: %I64d\n", Lbn);
62 ok(FsRtlLookupLastLargeMcbEntryAndIndex(&LargeMcb, &Vbn, &Lbn, &Index) == TRUE, "expected TRUE, got FALSE\n");
63 ok(Vbn == 3071, "Expected Vbn 3071, got: %I64d\n", Vbn);
64 ok(Lbn == 1025, "Expected Lbn 1025, got: %I64d\n", Lbn);
65 ok(Index == 3, "Expected Index 3, got: %lu\n", Index);
66
67 ok(FsRtlGetNextLargeMcbEntry(&LargeMcb, 0, &Vbn, &Lbn, &SectorCount) == TRUE, "expected TRUE, got FALSE\n");
68 ok(Vbn == 0, "Expected Vbn 0, got: %I64d\n", Vbn);
69 ok(Lbn == -1, "Expected Lbn -1, got: %I64d\n", Lbn);
70 ok(SectorCount == 1, "Expected SectorCount 1, got: %I64d\n", SectorCount);
71
72 ok(FsRtlGetNextLargeMcbEntry(&LargeMcb, 1, &Vbn, &Lbn, &SectorCount) == TRUE, "expected TRUE, got FALSE\n");
73 ok(Vbn == 1, "Expected Vbn 1, got: %I64d\n", Vbn);
74 ok(Lbn == 1, "Expected Lbn 1, got: %I64d\n", Lbn);
75 ok(SectorCount == 1024, "Expected SectorCount 1024, got: %I64d\n", SectorCount);
76
77 ok(FsRtlGetNextLargeMcbEntry(&LargeMcb, 2, &Vbn, &Lbn, &SectorCount) == TRUE, "expected TRUE, got FALSE\n");
78 ok(Vbn == 1025, "Expected Vbn 1025, got: %I64d\n", Vbn);
79 ok(Lbn == -1, "Expected Lbn -1, got: %I64d\n", Lbn);
80 ok(SectorCount == 1023, "Expected SectorCount 1023, got: %I64d\n", SectorCount);
81
82 ok(FsRtlGetNextLargeMcbEntry(&LargeMcb, 3, &Vbn, &Lbn, &SectorCount) == TRUE, "expected TRUE, got FALSE\n");
83 ok(Vbn == 2048, "Expected Vbn 2048, got: %I64d\n", Vbn);
84 ok(Lbn == 2, "Expected Lbn 2, got: %I64d\n", Lbn);
85 ok(SectorCount == 1024, "Expected SectorCount 1024, got: %I64d\n", SectorCount);
86
87 ok(FsRtlGetNextLargeMcbEntry(&LargeMcb, 4, &Vbn, &Lbn, &SectorCount) == FALSE, "expected FALSE, got TRUE\n");
88
89 ok(FsRtlLookupLargeMcbEntry(&LargeMcb, 1, &Lbn, &SectorCount, &StartingLbn, &CountFromStartingLbn, &Index) == TRUE, "expected TRUE, got FALSE\n");
90 ok(Lbn == 1, "Expected Lbn 1, got: %I64d\n", Lbn);
91 ok(SectorCount == 1024, "Expected SectorCount 1024, got: %I64d\n", SectorCount);
92 ok(StartingLbn == 1, "Expected StartingLbn 1, got: %I64d\n", StartingLbn);
93 ok(CountFromStartingLbn == 1024, "Expected CountFromStartingLbn 1024, got: %I64d\n", CountFromStartingLbn);
94 ok(Index == 1, "Expected Index 1, got: %lu\n", Index);
95
96 ok(FsRtlLookupLargeMcbEntry(&LargeMcb, 2048, &Lbn, &SectorCount, &StartingLbn, &CountFromStartingLbn, &Index) == TRUE, "expected TRUE, got FALSE\n");
97 ok(Lbn == 2, "Expected Lbn 2, got: %I64d\n", Lbn);
98 ok(SectorCount == 1024, "Expected SectorCount 1024, got: %I64d\n", SectorCount);
99 ok(StartingLbn == 2, "Expected StartingLbn 2, got: %I64d\n", StartingLbn);
100 ok(CountFromStartingLbn == 1024, "Expected CountFromStartingLbn 1024, got: %I64d\n", CountFromStartingLbn);
101 ok(Index == 3, "Expected Index 3, got: %lu\n", Index);
102
103 ok(FsRtlLookupLargeMcbEntry(&LargeMcb, 3073, &Lbn, &SectorCount, &StartingLbn, &CountFromStartingLbn, &Index) == FALSE, "expected FALSE, got TRUE\n");
104
105 FsRtlRemoveLargeMcbEntry(&LargeMcb, 1, 1024);
106 NbRuns = FsRtlNumberOfRunsInLargeMcb(&LargeMcb);
107 ok(NbRuns == 2, "Expected 2 runs, got: %lu\n", NbRuns);
108 DumpAllRuns(&LargeMcb); // [0,-1,2048][2048,2,1024]
109 ok(FsRtlLookupLargeMcbEntry(&LargeMcb, 512, &Lbn, &SectorCount, &StartingLbn, &CountFromStartingLbn, &Index) == TRUE, "expected TRUE, got FALSE\n");
110 ok(Lbn == -1, "Expected Lbn -1, got: %I64d\n", Lbn);
111 ok(SectorCount == 1536, "Expected SectorCount 1536, got: %I64d\n", SectorCount);
112 ok(StartingLbn == -1, "Expected StartingLbn -1, got: %I64d\n", StartingLbn);
113 ok(CountFromStartingLbn == 2048, "Expected CountFromStartingLbn 2048, got: %I64d\n", CountFromStartingLbn);
114 ok(Index == 0, "Expected Index 0, got: %lu\n", Index);
115 ok(FsRtlLookupLastLargeMcbEntryAndIndex(&LargeMcb, &Vbn, &Lbn, &Index) == TRUE, "expected TRUE, got FALSE\n");
116 ok(Vbn == 3071, "Expected Vbn 3071, got: %I64d\n", Vbn);
117 ok(Lbn == 1025, "Expected Lbn 1025, got: %I64d\n", Lbn);
118 ok(Index == 1, "Expected Index 1, got: %lu\n", Index);
119
120 ok(FsRtlSplitLargeMcb(&LargeMcb, 2048, 1024) == TRUE, "expected TRUE, got FALSE\n");
121 NbRuns = FsRtlNumberOfRunsInLargeMcb(&LargeMcb);
122 ok(NbRuns == 2, "Expected 2 runs, got: %lu\n", NbRuns);
123 DumpAllRuns(&LargeMcb); // [0,-1,3072][3072,2,1024]
124 ok(FsRtlLookupLastLargeMcbEntryAndIndex(&LargeMcb, &Vbn, &Lbn, &Index) == TRUE, "expected TRUE, got FALSE\n");
125 ok(Vbn == 4095, "Expected Vbn 4095, got: %I64d\n", Vbn);
126 ok(Lbn == 1025, "Expected Lbn 1025, got: %I64d\n", Lbn);
127 ok(Index == 1, "Expected Index 1, got: %lu\n", Index);
128 ok(FsRtlLookupLargeMcbEntry(&LargeMcb, 2048, &Lbn, &SectorCount, &StartingLbn, &CountFromStartingLbn, &Index) == TRUE, "expected TRUE, got FALSE\n");
129 ok(Lbn == -1, "Expected Lbn -1, got: %I64d\n", Lbn);
130 ok(SectorCount == 1024, "Expected SectorCount 1024, got: %I64d\n", SectorCount);
131 ok(StartingLbn == -1, "Expected StartingLbn -1, got: %I64d\n", StartingLbn);
132 ok(CountFromStartingLbn == 3072, "Expected CountFromStartingLbn 3072, got: %I64d\n", CountFromStartingLbn);
133 ok(Index == 0, "Expected Index 0, got: %lu\n", Index);
134 ok(FsRtlLookupLargeMcbEntry(&LargeMcb, 3072, &Lbn, &SectorCount, &StartingLbn, &CountFromStartingLbn, &Index) == TRUE, "expected TRUE, got FALSE\n");
135 ok(Lbn == 2, "Expected Lbn 2, got: %I64d\n", Lbn);
136 ok(SectorCount == 1024, "Expected SectorCount 1024, got: %I64d\n", SectorCount);
137 ok(StartingLbn == 2, "Expected StartingLbn 2, got: %I64d\n", StartingLbn);
138 ok(CountFromStartingLbn == 1024, "Expected CountFromStartingLbn 1024, got: %I64d\n", CountFromStartingLbn);
139 ok(Index == 1, "Expected Index 1, got: %lu\n", Index);
140
141 ok(FsRtlAddLargeMcbEntry(&LargeMcb, 3584, 3, 1024) == FALSE, "expected FALSE, got TRUE\n");
142
143 ok(FsRtlAddLargeMcbEntry(&LargeMcb, 4095, 1025, 1024) == TRUE, "expected TRUE, got FALSE\n");
144 NbRuns = FsRtlNumberOfRunsInLargeMcb(&LargeMcb);
145 ok(NbRuns == 2, "Expected 2 runs, got: %lu\n", NbRuns);
146 DumpAllRuns(&LargeMcb); // [0,-1,3072][3072,2,2047]
147 ok(FsRtlLookupLastLargeMcbEntry(&LargeMcb, &Vbn, &Lbn) == TRUE, "expected TRUE, got FALSE\n");
148 ok(Vbn == 5118, "Expected Vbn 5118, got: %I64d\n", Vbn);
149 ok(Lbn == 2048, "Expected Lbn 2048, got: %I64d\n", Lbn);
150 ok(FsRtlLookupLastLargeMcbEntryAndIndex(&LargeMcb, &Vbn, &Lbn, &Index) == TRUE, "expected TRUE, got FALSE\n");
151 ok(Vbn == 5118, "Expected Vbn 5118, got: %I64d\n", Vbn);
152 ok(Lbn == 2048, "Expected Lbn 2048, got: %I64d\n", Lbn);
153 ok(Index == 1, "Expected Index 1, got: %lu\n", Index);
154
155 FsRtlTruncateLargeMcb(&LargeMcb, 4607);
156 DumpAllRuns(&LargeMcb); // [0,-1,3072][3072,2,1535]
157 ok(FsRtlLookupLargeMcbEntry(&LargeMcb, 4095, &Lbn, &SectorCount, &StartingLbn, &CountFromStartingLbn, &Index) == TRUE, "expected TRUE, got FALSE\n");
158 ok(Lbn == 1025, "Expected Lbn 1025, got: %I64d\n", Lbn);
159 ok(SectorCount == 512, "Expected SectorCount 512, got: %I64d\n", SectorCount);
160 ok(StartingLbn == 2, "Expected StartingLbn 2, got: %I64d\n", StartingLbn);
161 ok(CountFromStartingLbn == 1535, "Expected CountFromStartingLbn 1535, got: %I64d\n", CountFromStartingLbn);
162 ok(Index == 1, "Expected Index 1, got: %lu\n", Index);
163
164 FsRtlUninitializeLargeMcb(&LargeMcb);
165
166 FsRtlInitializeLargeMcb(&LargeMcb, PagedPool);
167 NbRuns = FsRtlNumberOfRunsInLargeMcb(&LargeMcb);
168 ok(NbRuns == 0, "Expected 0 runs, got: %lu\n", NbRuns);
169
170 /* Create a mapping with three holes between each mapping
171 * It looks like that:
172 * ----//////-----/////-----///////
173 */
174 ok(FsRtlAddLargeMcbEntry(&LargeMcb, 1024, 1025, 1024) == TRUE, "expected TRUE, got FALSE\n");
175 DumpAllRuns(&LargeMcb); // [0,-1,1024][1024,1024,1024]
176 ok(FsRtlAddLargeMcbEntry(&LargeMcb, 3072, 3072, 1024) == TRUE, "expected TRUE, got FALSE\n");
177 DumpAllRuns(&LargeMcb); // [0,-1,1024][1024,1024,1024][2048,-1,1024][3072,3072,1024]
178 ok(FsRtlAddLargeMcbEntry(&LargeMcb, 5120, 5120, 1024) == TRUE, "expected TRUE, got FALSE\n");
179 DumpAllRuns(&LargeMcb); // [0,-1,1024][1024,1024,1024][2048,-1,1024][3072,3072,1024][4096,-1,1024][5120,5120,1024]
180
181 NbRuns = FsRtlNumberOfRunsInLargeMcb(&LargeMcb);
182 ok(NbRuns == 6, "Expected 6 runs, got: %lu\n", NbRuns);
183
184 ok(FsRtlGetNextLargeMcbEntry(&LargeMcb, 0, &Vbn, &Lbn, &SectorCount) == TRUE, "expected TRUE, got FALSE\n");
185 ok(Vbn == 0, "Expected Vbn 0, got: %I64d\n", Vbn);
186 ok(Lbn == -1, "Expected Lbn -1, got: %I64d\n", Lbn);
187 ok(SectorCount == 1024, "Expected SectorCount 1024, got: %I64d\n", SectorCount);
188
189 ok(FsRtlGetNextLargeMcbEntry(&LargeMcb, 1, &Vbn, &Lbn, &SectorCount) == TRUE, "expected TRUE, got FALSE\n");
190 ok(Vbn == 1024, "Expected Vbn 1024, got: %I64d\n", Vbn);
191 ok(Lbn == 1025, "Expected Lbn 1024, got: %I64d\n", Lbn);
192 ok(SectorCount == 1024, "Expected SectorCount 1024, got: %I64d\n", SectorCount);
193
194 ok(FsRtlGetNextLargeMcbEntry(&LargeMcb, 2, &Vbn, &Lbn, &SectorCount) == TRUE, "expected TRUE, got FALSE\n");
195 ok(Vbn == 2048, "Expected Vbn 2048, got: %I64d\n", Vbn);
196 ok(Lbn == -1, "Expected Lbn -1, got: %I64d\n", Lbn);
197 ok(SectorCount == 1024, "Expected SectorCount 1024, got: %I64d\n", SectorCount);
198
199 ok(FsRtlGetNextLargeMcbEntry(&LargeMcb, 3, &Vbn, &Lbn, &SectorCount) == TRUE, "expected TRUE, got FALSE\n");
200 ok(Vbn == 3072, "Expected Vbn 3072, got: %I64d\n", Vbn);
201 ok(Lbn == 3072, "Expected Lbn 3072, got: %I64d\n", Lbn);
202 ok(SectorCount == 1024, "Expected SectorCount 1024, got: %I64d\n", SectorCount);
203
204 ok(FsRtlGetNextLargeMcbEntry(&LargeMcb, 4, &Vbn, &Lbn, &SectorCount) == TRUE, "expected TRUE, got FALSE\n");
205 ok(Vbn == 4096, "Expected Vbn 4096, got: %I64d\n", Vbn);
206 ok(Lbn == -1, "Expected Lbn -1, got: %I64d\n", Lbn);
207 ok(SectorCount == 1024, "Expected SectorCount 1024, got: %I64d\n", SectorCount);
208
209 ok(FsRtlGetNextLargeMcbEntry(&LargeMcb, 5, &Vbn, &Lbn, &SectorCount) == TRUE, "expected TRUE, got FALSE\n");
210 ok(Vbn == 5120, "Expected Vbn 5120, got: %I64d\n", Vbn);
211 ok(Lbn == 5120, "Expected Lbn 5120, got: %I64d\n", Lbn);
212 ok(SectorCount == 1024, "Expected SectorCount 1024, got: %I64d\n", SectorCount);
213
214 /* Fill first hole */
215 ok(FsRtlAddLargeMcbEntry(&LargeMcb, 0, 1, 1024) == TRUE, "expected TRUE, got FALSE\n");
216 DumpAllRuns(&LargeMcb); // [0,1,2048][2048,-1,1024][3072,3072,1024][4096,-1,1024][5120,5120,1024]
217
218 NbRuns = FsRtlNumberOfRunsInLargeMcb(&LargeMcb);
219 ok(NbRuns == 5, "Expected 5 runs, got: %lu\n", NbRuns);
220
221 ok(FsRtlGetNextLargeMcbEntry(&LargeMcb, 0, &Vbn, &Lbn, &SectorCount) == TRUE, "expected TRUE, got FALSE\n");
222 ok(Vbn == 0, "Expected Vbn 0, got: %I64d\n", Vbn);
223 ok(Lbn == 1, "Expected Lbn 1, got: %I64d\n", Lbn);
224 ok(SectorCount == 2048, "Expected SectorCount 2048, got: %I64d\n", SectorCount);
225
226 ok(FsRtlGetNextLargeMcbEntry(&LargeMcb, 1, &Vbn, &Lbn, &SectorCount) == TRUE, "expected TRUE, got FALSE\n");
227 ok(Vbn == 2048, "Expected Vbn 2048, got: %I64d\n", Vbn);
228 ok(Lbn == -1, "Expected Lbn -1, got: %I64d\n", Lbn);
229 ok(SectorCount == 1024, "Expected SectorCount 1024, got: %I64d\n", SectorCount);
230
231 ok(FsRtlGetNextLargeMcbEntry(&LargeMcb, 2, &Vbn, &Lbn, &SectorCount) == TRUE, "expected TRUE, got FALSE\n");
232 ok(Vbn == 3072, "Expected Vbn 3072, got: %I64d\n", Vbn);
233 ok(Lbn == 3072, "Expected Lbn 3072, got: %I64d\n", Lbn);
234 ok(SectorCount == 1024, "Expected SectorCount 1024, got: %I64d\n", SectorCount);
235
236 ok(FsRtlGetNextLargeMcbEntry(&LargeMcb, 3, &Vbn, &Lbn, &SectorCount) == TRUE, "expected TRUE, got FALSE\n");
237 ok(Vbn == 4096, "Expected Vbn 4096, got: %I64d\n", Vbn);
238 ok(Lbn == -1, "Expected Lbn -1, got: %I64d\n", Lbn);
239 ok(SectorCount == 1024, "Expected SectorCount 1024, got: %I64d\n", SectorCount);
240
241 ok(FsRtlGetNextLargeMcbEntry(&LargeMcb, 4, &Vbn, &Lbn, &SectorCount) == TRUE, "expected TRUE, got FALSE\n");
242 ok(Vbn == 5120, "Expected Vbn 5120, got: %I64d\n", Vbn);
243 ok(Lbn == 5120, "Expected Lbn 5120, got: %I64d\n", Lbn);
244 ok(SectorCount == 1024, "Expected SectorCount 1024, got: %I64d\n", SectorCount);
245
246 /* Fill half of the last hole and overlap */
247 ok(FsRtlAddLargeMcbEntry(&LargeMcb, 4608, 4608, 1024) == TRUE, "expected TRUE, got FALSE\n");
248 DumpAllRuns(&LargeMcb); // [0,1,2048][2048,-1,1024][3072,3072,1024][4096,-1,512][4608,4608,1536]
249
250 NbRuns = FsRtlNumberOfRunsInLargeMcb(&LargeMcb);
251 ok(NbRuns == 5, "Expected 5 runs, got: %lu\n", NbRuns);
252
253 ok(FsRtlGetNextLargeMcbEntry(&LargeMcb, 0, &Vbn, &Lbn, &SectorCount) == TRUE, "expected TRUE, got FALSE\n");
254 ok(Vbn == 0, "Expected Vbn 0, got: %I64d\n", Vbn);
255 ok(Lbn == 1, "Expected Lbn 1, got: %I64d\n", Lbn);
256 ok(SectorCount == 2048, "Expected SectorCount 2048, got: %I64d\n", SectorCount);
257
258 ok(FsRtlGetNextLargeMcbEntry(&LargeMcb, 1, &Vbn, &Lbn, &SectorCount) == TRUE, "expected TRUE, got FALSE\n");
259 ok(Vbn == 2048, "Expected Vbn 2048, got: %I64d\n", Vbn);
260 ok(Lbn == -1, "Expected Lbn -1, got: %I64d\n", Lbn);
261 ok(SectorCount == 1024, "Expected SectorCount 1024, got: %I64d\n", SectorCount);
262
263 ok(FsRtlGetNextLargeMcbEntry(&LargeMcb, 2, &Vbn, &Lbn, &SectorCount) == TRUE, "expected TRUE, got FALSE\n");
264 ok(Vbn == 3072, "Expected Vbn 3072, got: %I64d\n", Vbn);
265 ok(Lbn == 3072, "Expected Lbn 3072, got: %I64d\n", Lbn);
266 ok(SectorCount == 1024, "Expected SectorCount 1024, got: %I64d\n", SectorCount);
267
268 ok(FsRtlGetNextLargeMcbEntry(&LargeMcb, 3, &Vbn, &Lbn, &SectorCount) == TRUE, "expected TRUE, got FALSE\n");
269 ok(Vbn == 4096, "Expected Vbn 4096, got: %I64d\n", Vbn);
270 ok(Lbn == -1, "Expected Lbn -1, got: %I64d\n", Lbn);
271 ok(SectorCount == 512, "Expected SectorCount 512, got: %I64d\n", SectorCount);
272
273 ok(FsRtlGetNextLargeMcbEntry(&LargeMcb, 4, &Vbn, &Lbn, &SectorCount) == TRUE, "expected TRUE, got FALSE\n");
274 ok(Vbn == 4608, "Expected Vbn 4608, got: %I64d\n", Vbn);
275 ok(Lbn == 4608, "Expected Lbn 4608, got: %I64d\n", Lbn);
276 ok(SectorCount == 1536, "Expected SectorCount 1536, got: %I64d\n", SectorCount);
277
278 FsRtlUninitializeLargeMcb(&LargeMcb);
279
280 FsRtlInitializeLargeMcb(&LargeMcb, PagedPool);
281 NbRuns = FsRtlNumberOfRunsInLargeMcb(&LargeMcb);
282 ok(NbRuns == 0, "Expected 0 runs, got: %lu\n", NbRuns);
283
284 ok(FsRtlAddLargeMcbEntry(&LargeMcb, 0, 1, 1024) == TRUE, "expected TRUE, got FALSE\n");
285 NbRuns = FsRtlNumberOfRunsInLargeMcb(&LargeMcb);
286 ok(NbRuns == 1, "Expected 1 runs, got: %lu\n", NbRuns);
287 ok(FsRtlGetNextLargeMcbEntry(&LargeMcb, 0, &Vbn, &Lbn, &SectorCount) == TRUE, "expected TRUE, got FALSE\n");
288 ok(Vbn == 0, "Expected Vbn 0, got: %I64d\n", Vbn);
289 ok(Lbn == 1, "Expected Lbn 1, got: %I64d\n", Lbn);
290 ok(SectorCount == 1024, "Expected SectorCount 1024, got: %I64d\n", SectorCount);
291 DumpAllRuns(&LargeMcb);
292
293 ok(FsRtlAddLargeMcbEntry(&LargeMcb, 0, 2, 1024) == FALSE, "expected FALSE, got TRUE\n");
294 NbRuns = FsRtlNumberOfRunsInLargeMcb(&LargeMcb);
295 ok(NbRuns == 1, "Expected 1 runs, got: %lu\n", NbRuns);
296 ok(FsRtlGetNextLargeMcbEntry(&LargeMcb, 0, &Vbn, &Lbn, &SectorCount) == TRUE, "expected TRUE, got FALSE\n");
297 ok(Vbn == 0, "Expected Vbn 0, got: %I64d\n", Vbn);
298 ok(Lbn == 1, "Expected Lbn 1, got: %I64d\n", Lbn);
299 ok(SectorCount == 1024, "Expected SectorCount 1024, got: %I64d\n", SectorCount);
300 DumpAllRuns(&LargeMcb);
301
302 ok(FsRtlAddLargeMcbEntry(&LargeMcb, 0, 0, 1024) == FALSE, "expected FALSE, got TRUE\n");
303 NbRuns = FsRtlNumberOfRunsInLargeMcb(&LargeMcb);
304 ok(NbRuns == 1, "Expected 1 runs, got: %lu\n", NbRuns);
305 ok(FsRtlGetNextLargeMcbEntry(&LargeMcb, 0, &Vbn, &Lbn, &SectorCount) == TRUE, "expected TRUE, got FALSE\n");
306 ok(Vbn == 0, "Expected Vbn 0, got: %I64d\n", Vbn);
307 ok(Lbn == 1, "Expected Lbn 1, got: %I64d\n", Lbn);
308 ok(SectorCount == 1024, "Expected SectorCount 1024, got: %I64d\n", SectorCount);
309 DumpAllRuns(&LargeMcb);
310
311 ok(FsRtlAddLargeMcbEntry(&LargeMcb, 1, 2, 1023) == TRUE, "expected TRUE, got FALSE\n");
312 NbRuns = FsRtlNumberOfRunsInLargeMcb(&LargeMcb);
313 ok(NbRuns == 1, "Expected 1 runs, got: %lu\n", NbRuns);
314 ok(FsRtlGetNextLargeMcbEntry(&LargeMcb, 0, &Vbn, &Lbn, &SectorCount) == TRUE, "expected TRUE, got FALSE\n");
315 ok(Vbn == 0, "Expected Vbn 0, got: %I64d\n", Vbn);
316 ok(Lbn == 1, "Expected Lbn 1, got: %I64d\n", Lbn);
317 ok(SectorCount == 1024, "Expected SectorCount 1024, got: %I64d\n", SectorCount);
318 DumpAllRuns(&LargeMcb);
319
320 FsRtlUninitializeLargeMcb(&LargeMcb);
321 }
322
323 static VOID FsRtlLargeMcbTestsExt2()
324 {
325 LARGE_MCB FirstMcb, SecondMcb;
326 LONGLONG Lbn, SectorCountFromLbn, StartingLbn, SectorCountFromStartingLbn, Vbn, SectorCount;
327 ULONG Index, NbRuns;
328 BOOLEAN Result;
329
330 FsRtlInitializeLargeMcb(&FirstMcb, PagedPool);
331 FsRtlInitializeLargeMcb(&SecondMcb, PagedPool);
332
333 FsRtlTruncateLargeMcb(&FirstMcb, 0);
334 FsRtlTruncateLargeMcb(&SecondMcb, 0);
335
336 Result = FsRtlLookupLargeMcbEntry(&FirstMcb, 1, &Lbn, &SectorCountFromLbn, NULL, NULL, NULL);
337 ok(Result == FALSE, "Expected FALSE, got TRUE\n");
338
339 Result = FsRtlAddLargeMcbEntry(&FirstMcb, 1, 198657, 1);
340 ok(Result == TRUE, "Expected TRUE, got FALSE\n");
341
342 DumpAllRuns(&FirstMcb);
343
344 NbRuns = FsRtlNumberOfRunsInLargeMcb(&FirstMcb);
345 ok(NbRuns == 2, "Expected 2 runs, got: %lu\n", NbRuns);
346
347 Result = FsRtlLookupLargeMcbEntry(&FirstMcb, 1, &Lbn, &SectorCountFromLbn, &StartingLbn, &SectorCountFromStartingLbn, &Index);
348 ok(Result == TRUE, "Expected TRUE, got FALSE\n");
349 ok(Lbn == 198657LL, "Expected Lbn 198657, got: %I64d\n", Lbn);
350 ok(SectorCountFromLbn == 1LL, "Expected SectorCountFromLbn 1, got: %I64d\n", SectorCountFromLbn);
351 ok(StartingLbn == 198657LL, "Expected StartingLbn 198657, got: %I64d\n", StartingLbn);
352 ok(SectorCountFromStartingLbn == 1LL, "Expected SectorCountFromStartingLbn 1, got: %I64d\n", SectorCountFromStartingLbn);
353 ok(Index == 1, "Expected Index 1, got: %d\n", Index);
354
355 Result = FsRtlLookupLargeMcbEntry(&FirstMcb, 2, &Lbn, &SectorCountFromLbn, NULL, NULL, NULL);
356 ok(Result == FALSE, "Expected FALSE, got TRUE\n");
357
358 Result = FsRtlAddLargeMcbEntry(&FirstMcb, 2, 199169, 11);
359 ok(Result == TRUE, "Expected TRUE, got FALSE\n");
360
361 DumpAllRuns(&FirstMcb);
362
363 NbRuns = FsRtlNumberOfRunsInLargeMcb(&FirstMcb);
364 ok(NbRuns == 3, "Expected 3 runs, got: %lu\n", NbRuns);
365
366 Result = FsRtlLookupLargeMcbEntry(&FirstMcb, 2, &Lbn, &SectorCountFromLbn, &StartingLbn, &SectorCountFromStartingLbn, &Index);
367 ok(Result == TRUE, "Expected TRUE, got FALSE\n");
368 ok(Lbn == 199169LL, "Expected Lbn 199169, got: %I64d\n", Lbn);
369 ok(SectorCountFromLbn == 11LL, "Expected SectorCountFromLbn 11, got: %I64d\n", SectorCountFromLbn);
370 ok(StartingLbn == 199169LL, "Expected StartingLbn 199169, got: %I64d\n", StartingLbn);
371 ok(SectorCountFromStartingLbn == 11LL, "Expected SectorCountFromStartingLbn 11, got: %I64d\n", SectorCountFromStartingLbn);
372 ok(Index == 2, "Expected Index 2, got: %d\n", Index);
373
374 Result = FsRtlGetNextLargeMcbEntry(&FirstMcb, 0, &Vbn, &Lbn, &SectorCount);
375 ok(Result == TRUE, "Expected TRUE, got FALSE\n");
376 ok(Vbn == 0LL, "Expected Vbn 0, got: %I64d\n", Vbn);
377 ok(Lbn == -1LL, "Expected Lbn -1, got: %I64d\n", Lbn);
378 ok(SectorCount == 1LL, "Expected SectorCount 1, got: %I64d\n", SectorCount);
379
380 Result = FsRtlGetNextLargeMcbEntry(&FirstMcb, 1, &Vbn, &Lbn, &SectorCount);
381 ok(Result == TRUE, "Expected TRUE, got FALSE\n");
382 ok(Vbn == 1LL, "Expected Vbn 1, got: %I64d\n", Vbn);
383 ok(Lbn == 198657LL, "Expected Lbn 198657, got: %I64d\n", Lbn);
384 ok(SectorCount == 1LL, "Expected SectorCount 1, got: %I64d\n", SectorCount);
385
386 Result = FsRtlGetNextLargeMcbEntry(&FirstMcb, 2, &Vbn, &Lbn, &SectorCount);
387 ok(Result == TRUE, "Expected TRUE, got FALSE\n");
388 ok(Vbn == 2LL, "Expected Vbn 2, got: %I64d\n", Vbn);
389 ok(Lbn == 199169LL, "Expected Lbn 199169, got: %I64d\n", Lbn);
390 ok(SectorCount == 11LL, "Expected SectorCount 11, got: %I64d\n", SectorCount);
391
392 Result = FsRtlGetNextLargeMcbEntry(&FirstMcb, 3, &Vbn, &Lbn, &SectorCount);
393 ok(Result == FALSE, "Expected FALSE, got TRUE\n");
394
395 Result = FsRtlAddLargeMcbEntry(&SecondMcb, 197128, 197128, 1);
396 ok(Result == TRUE, "Expected TRUE, got FALSE\n");
397
398 Result = FsRtlLookupLargeMcbEntry(&SecondMcb, 197128, &Lbn, &SectorCountFromLbn, &StartingLbn, &SectorCountFromStartingLbn, &Index);
399 ok(Result == TRUE, "Expected TRUE, got FALSE\n");
400 ok(Lbn == 197128LL, "Expected Lbn 197128, got: %I64d\n", Lbn);
401 ok(SectorCountFromLbn == 1LL, "Expected SectorCountFromLbn 1, got: %I64d\n", SectorCountFromLbn);
402 ok(StartingLbn == 197128LL, "Expected StartingLbn 197128, got: %I64d\n", StartingLbn);
403 ok(SectorCountFromStartingLbn == 1LL, "Expected SectorCountFromStartingLbn 1, got: %I64d\n", SectorCountFromStartingLbn);
404 ok(Index == 1, "Expected Index 1, got: %d\n", Index);
405
406 Result = FsRtlLookupLargeMcbEntry(&FirstMcb, 13, &Lbn, &SectorCountFromLbn, NULL, NULL, NULL);
407 ok(Result == FALSE, "Expected FALSE, got TRUE\n");
408
409 Result = FsRtlAddLargeMcbEntry(&FirstMcb, 13, 199180, 4);
410 ok(Result == TRUE, "Expected TRUE, got FALSE\n");
411
412 DumpAllRuns(&FirstMcb);
413
414 NbRuns = FsRtlNumberOfRunsInLargeMcb(&FirstMcb);
415 ok(NbRuns == 3, "Expected 3 runs, got: %lu\n", NbRuns);
416
417 Result = FsRtlLookupLargeMcbEntry(&FirstMcb, 13, &Lbn, &SectorCountFromLbn, &StartingLbn, &SectorCountFromStartingLbn, &Index);
418 ok(Result == TRUE, "Expected TRUE, got FALSE\n");
419 ok(Lbn == 199180LL, "Expected Lbn 199180, got: %I64d\n", Lbn);
420 ok(SectorCountFromLbn == 4LL, "Expected SectorCountFromLbn 4, got: %I64d\n", SectorCountFromLbn);
421 ok(StartingLbn == 199169LL, "Expected StartingLbn 199169, got: %I64d\n", StartingLbn);
422 ok(SectorCountFromStartingLbn == 15LL, "Expected SectorCountFromStartingLbn 15, got: %I64d\n", SectorCountFromStartingLbn);
423 ok(Index == 2, "Expected Index 2, got: %d\n", Index);
424
425 Result = FsRtlGetNextLargeMcbEntry(&FirstMcb, 0, &Vbn, &Lbn, &SectorCount);
426 ok(Result == TRUE, "Expected TRUE, got FALSE\n");
427 ok(Vbn == 0LL, "Expected Vbn 0, got: %I64d\n", Vbn);
428 ok(Lbn == -1LL, "Expected Lbn -1, got: %I64d\n", Lbn);
429 ok(SectorCount == 1LL, "Expected SectorCount 1, got: %I64d\n", SectorCount);
430
431 Result = FsRtlGetNextLargeMcbEntry(&FirstMcb, 1, &Vbn, &Lbn, &SectorCount);
432 ok(Result == TRUE, "Expected TRUE, got FALSE\n");
433 ok(Vbn == 1LL, "Expected Vbn 1, got: %I64d\n", Vbn);
434 ok(Lbn == 198657LL, "Expected Lbn 198657, got: %I64d\n", Lbn);
435 ok(SectorCount == 1LL, "Expected SectorCount 1, got: %I64d\n", SectorCount);
436
437 Result = FsRtlGetNextLargeMcbEntry(&FirstMcb, 2, &Vbn, &Lbn, &SectorCount);
438 ok(Result == TRUE, "Expected TRUE, got FALSE\n");
439 ok(Vbn == 2LL, "Expected Vbn 2, got: %I64d\n", Vbn);
440 ok(Lbn == 199169LL, "Expected Lbn 199169, got: %I64d\n", Lbn);
441 ok(SectorCount == 15LL, "Expected SectorCount 15, got: %I64d\n", SectorCount);
442
443 Result = FsRtlGetNextLargeMcbEntry(&FirstMcb, 3, &Vbn, &Lbn, &SectorCount);
444 ok(Result == FALSE, "Expected FALSE, got TRUE\n");
445
446 Result = FsRtlAddLargeMcbEntry(&SecondMcb, 197128, 197128, 1);
447 ok(Result == TRUE, "Expected TRUE, got FALSE\n");
448
449 Result = FsRtlLookupLargeMcbEntry(&SecondMcb, 197128, &Lbn, &SectorCountFromLbn, &StartingLbn, &SectorCountFromStartingLbn, &Index);
450 ok(Result == TRUE, "Expected TRUE, got FALSE\n");
451 ok(Lbn == 197128LL, "Expected Lbn 197128, got: %I64d\n", Lbn);
452 ok(SectorCountFromLbn == 1LL, "Expected SectorCountFromLbn 1, got: %I64d\n", SectorCountFromLbn);
453 ok(StartingLbn == 197128LL, "Expected StartingLbn 197128, got: %I64d\n", StartingLbn);
454 ok(SectorCountFromStartingLbn == 1LL, "Expected SectorCountFromStartingLbn 1, got: %I64d\n", SectorCountFromStartingLbn);
455 ok(Index == 1, "Expected Index 1, got: %d\n", Index);
456
457 Result = FsRtlLookupLargeMcbEntry(&FirstMcb, 17, &Lbn, &SectorCountFromLbn, NULL, NULL, NULL);
458 ok(Result == FALSE, "Expected FALSE, got TRUE\n");
459
460 Result = FsRtlAddLargeMcbEntry(&FirstMcb, 17, 1105, 16);
461 ok(Result == TRUE, "Expected TRUE, got FALSE\n");
462
463 DumpAllRuns(&FirstMcb);
464
465 NbRuns = FsRtlNumberOfRunsInLargeMcb(&FirstMcb);
466 ok(NbRuns == 4, "Expected 4 runs, got: %lu\n", NbRuns);
467
468 Result = FsRtlLookupLargeMcbEntry(&FirstMcb, 17, &Lbn, &SectorCountFromLbn, &StartingLbn, &SectorCountFromStartingLbn, &Index);
469 ok(Result == TRUE, "Expected TRUE, got FALSE\n");
470 ok(Lbn == 1105LL, "Expected Lbn 1105, got: %I64d\n", Lbn);
471 ok(SectorCountFromLbn == 16LL, "Expected SectorCountFromLbn 16, got: %I64d\n", SectorCountFromLbn);
472 ok(StartingLbn == 1105LL, "Expected StartingLbn 1105, got: %I64d\n", StartingLbn);
473 ok(SectorCountFromStartingLbn == 16LL, "Expected SectorCountFromStartingLbn 16, got: %I64d\n", SectorCountFromStartingLbn);
474 ok(Index == 3, "Expected Index 3, got: %d\n", Index);
475
476 Result = FsRtlGetNextLargeMcbEntry(&FirstMcb, 0, &Vbn, &Lbn, &SectorCount);
477 ok(Result == TRUE, "Expected TRUE, got FALSE\n");
478 ok(Vbn == 0LL, "Expected Vbn 0, got: %I64d\n", Vbn);
479 ok(Lbn == -1LL, "Expected Lbn -1, got: %I64d\n", Lbn);
480 ok(SectorCount == 1LL, "Expected SectorCount 1, got: %I64d\n", SectorCount);
481
482 Result = FsRtlGetNextLargeMcbEntry(&FirstMcb, 1, &Vbn, &Lbn, &SectorCount);
483 ok(Result == TRUE, "Expected TRUE, got FALSE\n");
484 ok(Vbn == 1LL, "Expected Vbn 1, got: %I64d\n", Vbn);
485 ok(Lbn == 198657LL, "Expected Lbn 198657, got: %I64d\n", Lbn);
486 ok(SectorCount == 1LL, "Expected SectorCount 1, got: %I64d\n", SectorCount);
487
488 Result = FsRtlGetNextLargeMcbEntry(&FirstMcb, 2, &Vbn, &Lbn, &SectorCount);
489 ok(Result == TRUE, "Expected TRUE, got FALSE\n");
490 ok(Vbn == 2LL, "Expected Vbn 2, got: %I64d\n", Vbn);
491 ok(Lbn == 199169LL, "Expected Lbn 199169, got: %I64d\n", Lbn);
492 ok(SectorCount == 15LL, "Expected SectorCount 15, got: %I64d\n", SectorCount);
493
494 Result = FsRtlGetNextLargeMcbEntry(&FirstMcb, 3, &Vbn, &Lbn, &SectorCount);
495 ok(Result == TRUE, "Expected TRUE, got FALSE\n");
496 ok(Vbn == 17LL, "Expected Vbn 17, got: %I64d\n", Vbn);
497 ok(Lbn == 1105LL, "Expected Lbn 1105, got: %I64d\n", Lbn);
498 ok(SectorCount == 16LL, "Expected SectorCount 16, got: %I64d\n", SectorCount);
499
500 Result = FsRtlGetNextLargeMcbEntry(&FirstMcb, 4, &Vbn, &Lbn, &SectorCount);
501 ok(Result == FALSE, "Expected FALSE, got TRUE\n");
502
503 Result = FsRtlAddLargeMcbEntry(&SecondMcb, 197128, 197128, 1);
504 ok(Result == TRUE, "Expected TRUE, got FALSE\n");
505
506 Result = FsRtlLookupLargeMcbEntry(&SecondMcb, 197128, &Lbn, &SectorCountFromLbn, &StartingLbn, &SectorCountFromStartingLbn, &Index);
507 ok(Result == TRUE, "Expected TRUE, got FALSE\n");
508 ok(Lbn == 197128LL, "Expected Lbn 197128, got: %I64d\n", Lbn);
509 ok(SectorCountFromLbn == 1LL, "Expected SectorCountFromLbn 1, got: %I64d\n", SectorCountFromLbn);
510 ok(StartingLbn == 197128LL, "Expected StartingLbn 197128, got: %I64d\n", StartingLbn);
511 ok(SectorCountFromStartingLbn == 1LL, "Expected SectorCountFromStartingLbn 1, got: %I64d\n", SectorCountFromStartingLbn);
512 ok(Index == 1, "Expected Index 1, got: %d\n", Index);
513
514 Result = FsRtlLookupLargeMcbEntry(&FirstMcb, 33, &Lbn, &SectorCountFromLbn, NULL, NULL, NULL);
515 ok(Result == FALSE, "Expected FALSE, got TRUE\n");
516
517 Result = FsRtlAddLargeMcbEntry(&FirstMcb, 33, 1185, 32);
518 ok(Result == TRUE, "Expected TRUE, got FALSE\n");
519
520 DumpAllRuns(&FirstMcb);
521
522 NbRuns = FsRtlNumberOfRunsInLargeMcb(&FirstMcb);
523 ok(NbRuns == 5, "Expected 5 runs, got: %lu\n", NbRuns);
524
525 Result = FsRtlLookupLargeMcbEntry(&FirstMcb, 33, &Lbn, &SectorCountFromLbn, &StartingLbn, &SectorCountFromStartingLbn, &Index);
526 ok(Result == TRUE, "Expected TRUE, got FALSE\n");
527 ok(Lbn == 1185LL, "Expected Lbn 1185, got: %I64d\n", Lbn);
528 ok(SectorCountFromLbn == 32LL, "Expected SectorCountFromLbn 32, got: %I64d\n", SectorCountFromLbn);
529 ok(StartingLbn == 1185LL, "Expected StartingLbn 1185, got: %I64d\n", StartingLbn);
530 ok(SectorCountFromStartingLbn == 32LL, "Expected SectorCountFromStartingLbn 32, got: %I64d\n", SectorCountFromStartingLbn);
531 ok(Index == 4, "Expected Index 4, got: %d\n", Index);
532
533 Result = FsRtlGetNextLargeMcbEntry(&FirstMcb, 0, &Vbn, &Lbn, &SectorCount);
534 ok(Result == TRUE, "Expected TRUE, got FALSE\n");
535 ok(Vbn == 0LL, "Expected Vbn 0, got: %I64d\n", Vbn);
536 ok(Lbn == -1LL, "Expected Lbn -1, got: %I64d\n", Lbn);
537 ok(SectorCount == 1LL, "Expected SectorCount 1, got: %I64d\n", SectorCount);
538
539 Result = FsRtlGetNextLargeMcbEntry(&FirstMcb, 1, &Vbn, &Lbn, &SectorCount);
540 ok(Result == TRUE, "Expected TRUE, got FALSE\n");
541 ok(Vbn == 1LL, "Expected Vbn 1, got: %I64d\n", Vbn);
542 ok(Lbn == 198657LL, "Expected Lbn 198657, got: %I64d\n", Lbn);
543 ok(SectorCount == 1LL, "Expected SectorCount 1, got: %I64d\n", SectorCount);
544
545 Result = FsRtlGetNextLargeMcbEntry(&FirstMcb, 2, &Vbn, &Lbn, &SectorCount);
546 ok(Result == TRUE, "Expected TRUE, got FALSE\n");
547 ok(Vbn == 2LL, "Expected Vbn 2, got: %I64d\n", Vbn);
548 ok(Lbn == 199169LL, "Expected Lbn 199169, got: %I64d\n", Lbn);
549 ok(SectorCount == 15LL, "Expected SectorCount 15, got: %I64d\n", SectorCount);
550
551 Result = FsRtlGetNextLargeMcbEntry(&FirstMcb, 3, &Vbn, &Lbn, &SectorCount);
552 ok(Result == TRUE, "Expected TRUE, got FALSE\n");
553 ok(Vbn == 17LL, "Expected Vbn 17, got: %I64d\n", Vbn);
554 ok(Lbn == 1105LL, "Expected Lbn 1105, got: %I64d\n", Lbn);
555 ok(SectorCount == 16LL, "Expected SectorCount 16, got: %I64d\n", SectorCount);
556
557 Result = FsRtlGetNextLargeMcbEntry(&FirstMcb, 4, &Vbn, &Lbn, &SectorCount);
558 ok(Result == TRUE, "Expected TRUE, got FALSE\n");
559 ok(Vbn == 33LL, "Expected Vbn 33, got: %I64d\n", Vbn);
560 ok(Lbn == 1185LL, "Expected Lbn 1185, got: %I64d\n", Lbn);
561 ok(SectorCount == 32LL, "Expected SectorCount 32, got: %I64d\n", SectorCount);
562
563 Result = FsRtlGetNextLargeMcbEntry(&FirstMcb, 5, &Vbn, &Lbn, &SectorCount);
564 ok(Result == FALSE, "Expected FALSE, got TRUE\n");
565
566 Result = FsRtlAddLargeMcbEntry(&SecondMcb, 197128, 197128, 1);
567 ok(Result == TRUE, "Expected TRUE, got FALSE\n");
568
569 Result = FsRtlLookupLargeMcbEntry(&SecondMcb, 197128, &Lbn, &SectorCountFromLbn, &StartingLbn, &SectorCountFromStartingLbn, &Index);
570 ok(Result == TRUE, "Expected TRUE, got FALSE\n");
571 ok(Lbn == 197128LL, "Expected Lbn 197128, got: %I64d\n", Lbn);
572 ok(SectorCountFromLbn == 1LL, "Expected SectorCountFromLbn 1, got: %I64d\n", SectorCountFromLbn);
573 ok(StartingLbn == 197128LL, "Expected StartingLbn 197128, got: %I64d\n", StartingLbn);
574 ok(SectorCountFromStartingLbn == 1LL, "Expected SectorCountFromStartingLbn 1, got: %I64d\n", SectorCountFromStartingLbn);
575 ok(Index == 1, "Expected Index 1, got: %d\n", Index);
576
577 Result = FsRtlLookupLargeMcbEntry(&FirstMcb, 65, &Lbn, &SectorCountFromLbn, NULL, NULL, NULL);
578 ok(Result == FALSE, "Expected FALSE, got TRUE\n");
579
580 Result = FsRtlAddLargeMcbEntry(&FirstMcb, 65, 1249, 44);
581 ok(Result == TRUE, "Expected TRUE, got FALSE\n");
582
583 DumpAllRuns(&FirstMcb);
584
585 NbRuns = FsRtlNumberOfRunsInLargeMcb(&FirstMcb);
586 ok(NbRuns == 6, "Expected 6 runs, got: %lu\n", NbRuns);
587
588 Result = FsRtlLookupLargeMcbEntry(&FirstMcb, 65, &Lbn, &SectorCountFromLbn, &StartingLbn, &SectorCountFromStartingLbn, &Index);
589 ok(Result == TRUE, "Expected TRUE, got FALSE\n");
590 ok(Lbn == 1249LL, "Expected Lbn 1249, got: %I64d\n", Lbn);
591 ok(SectorCountFromLbn == 44LL, "Expected SectorCountFromLbn 44, got: %I64d\n", SectorCountFromLbn);
592 ok(StartingLbn == 1249LL, "Expected StartingLbn 1249, got: %I64d\n", StartingLbn);
593 ok(SectorCountFromStartingLbn == 44LL, "Expected SectorCountFromStartingLbn 44, got: %I64d\n", SectorCountFromStartingLbn);
594 ok(Index == 5, "Expected Index 1, got: %d\n", Index);
595
596 Result = FsRtlGetNextLargeMcbEntry(&FirstMcb, 0, &Vbn, &Lbn, &SectorCount);
597 ok(Result == TRUE, "Expected TRUE, got FALSE\n");
598 ok(Vbn == 0LL, "Expected Vbn 0, got: %I64d\n", Vbn);
599 ok(Lbn == -1LL, "Expected Lbn -1, got: %I64d\n", Lbn);
600 ok(SectorCount == 1LL, "Expected SectorCount 1, got: %I64d\n", SectorCount);
601
602 Result = FsRtlGetNextLargeMcbEntry(&FirstMcb, 1, &Vbn, &Lbn, &SectorCount);
603 ok(Result == TRUE, "Expected TRUE, got FALSE\n");
604 ok(Vbn == 1LL, "Expected Vbn 1, got: %I64d\n", Vbn);
605 ok(Lbn == 198657LL, "Expected Lbn 198657, got: %I64d\n", Lbn);
606 ok(SectorCount == 1LL, "Expected SectorCount 1, got: %I64d\n", SectorCount);
607
608 Result = FsRtlGetNextLargeMcbEntry(&FirstMcb, 2, &Vbn, &Lbn, &SectorCount);
609 ok(Result == TRUE, "Expected TRUE, got FALSE\n");
610 ok(Vbn == 2LL, "Expected Vbn 2, got: %I64d\n", Vbn);
611 ok(Lbn == 199169LL, "Expected Lbn 199169, got: %I64d\n", Lbn);
612 ok(SectorCount == 15LL, "Expected SectorCount 15, got: %I64d\n", SectorCount);
613
614 Result = FsRtlGetNextLargeMcbEntry(&FirstMcb, 3, &Vbn, &Lbn, &SectorCount);
615 ok(Result == TRUE, "Expected TRUE, got FALSE\n");
616 ok(Vbn == 17LL, "Expected Vbn 17, got: %I64d\n", Vbn);
617 ok(Lbn == 1105LL, "Expected Lbn 1105, got: %I64d\n", Lbn);
618 ok(SectorCount == 16LL, "Expected SectorCount 16, got: %I64d\n", SectorCount);
619
620 Result = FsRtlGetNextLargeMcbEntry(&FirstMcb, 4, &Vbn, &Lbn, &SectorCount);
621 ok(Result == TRUE, "Expected TRUE, got FALSE\n");
622 ok(Vbn == 33LL, "Expected Vbn 33, got: %I64d\n", Vbn);
623 ok(Lbn == 1185LL, "Expected Lbn 1185, got: %I64d\n", Lbn);
624 ok(SectorCount == 32LL, "Expected SectorCount 32, got: %I64d\n", SectorCount);
625
626 Result = FsRtlGetNextLargeMcbEntry(&FirstMcb, 5, &Vbn, &Lbn, &SectorCount);
627 ok(Result == TRUE, "Expected TRUE, got FALSE\n");
628 ok(Vbn == 65LL, "Expected Vbn 65, got: %I64d\n", Vbn);
629 ok(Lbn == 1249LL, "Expected Lbn 1249, got: %I64d\n", Lbn);
630 ok(SectorCount == 44LL, "Expected SectorCount 44, got: %I64d\n", SectorCount);
631
632 Result = FsRtlGetNextLargeMcbEntry(&FirstMcb, 6, &Vbn, &Lbn, &SectorCount);
633 ok(Result == FALSE, "Expected FALSE, got TRUE\n");
634
635 Result = FsRtlLookupLargeMcbEntry(&FirstMcb, 1, &Lbn, &SectorCountFromLbn, NULL, NULL, NULL);
636 ok(Result == TRUE, "Expected TRUE, got FALSE\n");
637 ok(Lbn == 198657LL, "Expected Lbn 198657, got: %I64d\n", Lbn);
638 ok(SectorCountFromLbn == 1LL, "Expected SectorCountFromLbn 108, got: %I64d\n", SectorCountFromLbn);
639
640 FsRtlUninitializeLargeMcb(&SecondMcb);
641 FsRtlUninitializeLargeMcb(&FirstMcb);
642 }
643
644 START_TEST(FsRtlMcb)
645 {
646 FsRtlMcbTest();
647 FsRtlLargeMcbTest();
648 FsRtlLargeMcbTestsExt2();
649 }