Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

tmcb.c

Go to the documentation of this file.
00001 /*++ 00002 00003 Copyright (c) 1989 Microsoft Corporation 00004 00005 Module Name: 00006 00007 TMcbSup.c 00008 00009 Abstract: 00010 00011 This module tests the Pinball Map Control Block support routines 00012 00013 Author: 00014 00015 Gary Kimura [GaryKi] 5-Feb-1990 00016 00017 Revision History: 00018 00019 --*/ 00020 00021 #include <stdio.h> 00022 #include <string.h> 00023 00024 #include "PbProcs.h" 00025 00026 VOID 00027 PbDumpMcb ( 00028 IN PMCB Mcb 00029 ); 00030 00031 00032 00033 #ifndef SIMULATOR 00034 ULONG IoInitIncludeDevices; 00035 #endif // SIMULATOR 00036 00037 BOOLEAN McbTest(); 00038 00039 int 00040 main( 00041 int argc, 00042 char *argv[] 00043 ) 00044 { 00045 extern ULONG IoInitIncludeDevices; 00046 VOID KiSystemStartup(); 00047 00048 DbgPrint("sizeof(MCB) = %d\n", sizeof(MCB)); 00049 00050 IoInitIncludeDevices = 0; // IOINIT_FATFS | 00051 // IOINIT_PINBALLFS | 00052 // IOINIT_DDFS; 00053 TestFunction = McbTest; 00054 00055 KiSystemStartup(); 00056 00057 return( 0 ); 00058 } 00059 00060 BOOLEAN 00061 McbTest() 00062 { 00063 BOOLEAN TestAddEntry(); 00064 BOOLEAN TestRemoveEntry(); 00065 BOOLEAN TestLookupEntry(); 00066 BOOLEAN TestGetEntry(); 00067 BOOLEAN TestLookupLastEntry(); 00068 00069 if (!TestAddEntry()) { 00070 return FALSE; 00071 } 00072 00073 if (!TestRemoveEntry()) { 00074 return FALSE; 00075 } 00076 00077 if (!TestLookupEntry()) { 00078 return FALSE; 00079 } 00080 00081 if (!TestGetEntry()) { 00082 return FALSE; 00083 } 00084 00085 if (!TestLookupLastEntry()) { 00086 return FALSE; 00087 } 00088 00089 return TRUE; 00090 00091 } 00092 00093 BOOLEAN 00094 TestAddEntry() 00095 { 00096 MCB Mcb; 00097 ULONG i; 00098 ULONG Vbn,Lbn,Length; 00099 00100 DbgPrint("\n\n\n>>>> Test PbAddMcbEntry <<<<\n"); 00101 00102 // 00103 // Build the following runs 00104 // 00105 // [0-9|10-19][20-29] [40-49] 00106 // 00107 00108 PbInitializeMcb(Mcb, NonPagedPool); 00109 00110 DbgPrint("\nTest 0:|--NewRun--|\n"); 00111 if (!PbAddMcbEntry(Mcb, 0, 1000, 10)) {DbgPrint("Error\n");return FALSE;} 00112 PbDumpMcb( Mcb ); 00113 00114 DbgPrint("\nTest --LastRun--|--NewRun--|\n"); 00115 if (!PbAddMcbEntry(Mcb, 10, 1010, 10)) {DbgPrint("Error\n");return FALSE;} 00116 PbDumpMcb( Mcb ); 00117 00118 DbgPrint("\nTest --LastRun--||--NewRun--|\n"); 00119 if (!PbAddMcbEntry(Mcb, 20, 2020, 10)) {DbgPrint("Error\n");return FALSE;} 00120 PbDumpMcb( Mcb ); 00121 00122 DbgPrint("\nTest --LastRun--| hole |--NewRun--|\n"); 00123 if (!PbAddMcbEntry(Mcb, 40, 1040, 10)) {DbgPrint("Error\n");return FALSE;} 00124 PbDumpMcb( Mcb ); 00125 00126 DbgPrint("\nTest over writing an existing run\n"); 00127 if (PbAddMcbEntry(Mcb, 40, 1190, 5)) {DbgPrint("Error\n");return FALSE;} 00128 if (PbAddMcbEntry(Mcb, 25, 1190, 10)) {DbgPrint("Error\n");return FALSE;} 00129 if (PbAddMcbEntry(Mcb, 15, 1190, 10)) {DbgPrint("Error\n");return FALSE;} 00130 00131 PbUninitializeMcb(Mcb); 00132 00133 // 00134 // Build the following runs 00135 // 00136 // [0-9] [30-39][40-49|50-59|60-64] [70-79][80-84] [90-99] 00137 // 00138 00139 PbInitializeMcb(Mcb, NonPagedPool); 00140 00141 DbgPrint("\nTest 0: hole |--NewRun--|\n"); 00142 if (!PbAddMcbEntry(Mcb, 90, 1090, 10)) {DbgPrint("Error\n");return FALSE;} 00143 PbDumpMcb( Mcb ); 00144 00145 DbgPrint("\nTest 0: hole |--NewRun--| hole |--FollowingRun--\n"); 00146 if (!PbAddMcbEntry(Mcb, 50, 1050, 10)) {DbgPrint("Error\n");return FALSE;} 00147 PbDumpMcb( Mcb ); 00148 00149 DbgPrint("\nTest --PreviousRun--| hole |--NewRun--| hole |--FollowingRun--\n"); 00150 if (!PbAddMcbEntry(Mcb, 70, 1070, 10)) {DbgPrint("Error\n");return FALSE;} 00151 PbDumpMcb( Mcb ); 00152 00153 DbgPrint("\nTest --PreviousRun--|--NewRun--| hole |--FollowingRun--\n"); 00154 if (!PbAddMcbEntry(Mcb, 60, 1060, 5)) {DbgPrint("Error\n");return FALSE;} 00155 PbDumpMcb( Mcb ); 00156 00157 DbgPrint("\nTest --PreviousRun--||--NewRun--| hole |--FollowingRun--\n"); 00158 if (!PbAddMcbEntry(Mcb, 80, 1180, 5)) {DbgPrint("Error\n");return FALSE;} 00159 PbDumpMcb( Mcb ); 00160 00161 DbgPrint("\nTest 0:|--NewRun--| hole |--FollowingRun--\n"); 00162 if (!PbAddMcbEntry(Mcb, 0, 1000, 10)) {DbgPrint("Error\n");return FALSE;} 00163 PbDumpMcb( Mcb ); 00164 00165 DbgPrint("\nTest --PreviousRun--| hole |--NewRun--|--FollowingRun--\n"); 00166 if (!PbAddMcbEntry(Mcb, 40, 1040, 10)) {DbgPrint("Error\n");return FALSE;} 00167 PbDumpMcb( Mcb ); 00168 00169 DbgPrint("\nTest --PreviousRun--| hole |--NewRun--||--FollowingRun--\n"); 00170 if (!PbAddMcbEntry(Mcb, 30, 1130, 10)) {DbgPrint("Error\n");return FALSE;} 00171 PbDumpMcb( Mcb ); 00172 00173 PbUninitializeMcb(Mcb); 00174 00175 // 00176 // Build the following runs 00177 // 00178 // [0-9|10-19|20-29][30-39][40-49|50-59|60-69|70-79][80-89|90-99] 00179 // 00180 00181 PbInitializeMcb(Mcb, NonPagedPool); 00182 if (!PbAddMcbEntry(Mcb, 90, 1090, 10)) {DbgPrint("Error\n");return FALSE;} 00183 00184 DbgPrint("\nTest 0: hole |--NewRun--|--FollowingRun--\n"); 00185 if (!PbAddMcbEntry(Mcb, 80, 1080, 10)) {DbgPrint("Error\n");return FALSE;} 00186 PbDumpMcb( Mcb ); 00187 00188 DbgPrint("\nTest 0: hole |--NewRun--||--FollowingRun--\n"); 00189 if (!PbAddMcbEntry(Mcb, 70, 1170, 10)) {DbgPrint("Error\n");return FALSE;} 00190 PbDumpMcb( Mcb ); 00191 00192 if (!PbAddMcbEntry(Mcb, 50, 1150, 10)) {DbgPrint("Error\n");return FALSE;} 00193 DbgPrint("\nTest --PreviousRun--|--NewRun--|--FollowingRun--\n"); 00194 if (!PbAddMcbEntry(Mcb, 60, 1160, 10)) {DbgPrint("Error\n");return FALSE;} 00195 PbDumpMcb( Mcb ); 00196 00197 if (!PbAddMcbEntry(Mcb, 30, 1030, 10)) {DbgPrint("Error\n");return FALSE;} 00198 DbgPrint("\nTest --PreviousRun--||--NewRun--|--FollowingRun--\n"); 00199 if (!PbAddMcbEntry(Mcb, 40, 1140, 10)) {DbgPrint("Error\n");return FALSE;} 00200 PbDumpMcb( Mcb ); 00201 00202 if (!PbAddMcbEntry(Mcb, 10, 1110, 10)) {DbgPrint("Error\n");return FALSE;} 00203 DbgPrint("\nTest --PreviousRun--|--NewRun--||--FollowingRun--\n"); 00204 if (!PbAddMcbEntry(Mcb, 20, 1120, 10)) {DbgPrint("Error\n");return FALSE;} 00205 PbDumpMcb( Mcb ); 00206 00207 DbgPrint("\nTest 0:|--NewRun--|--FollowingRun--\n"); 00208 if (!PbAddMcbEntry(Mcb, 0, 1100, 10)) {DbgPrint("Error\n");return FALSE;} 00209 PbDumpMcb( Mcb ); 00210 00211 PbUninitializeMcb(Mcb); 00212 00213 // 00214 // Build the following runs 00215 // 00216 // [0-69][80-79|80-89|90-99] 00217 // 00218 00219 PbInitializeMcb(Mcb, NonPagedPool); 00220 if (!PbAddMcbEntry(Mcb, 90, 1090, 10)) {DbgPrint("Error\n");return FALSE;} 00221 00222 if (!PbAddMcbEntry(Mcb, 70, 1070, 10)) {DbgPrint("Error\n");return FALSE;} 00223 DbgPrint("\nTest --PreviousRun--||--NewRun--||--FollowingRun--\n"); 00224 if (!PbAddMcbEntry(Mcb, 80, 1010, 10)) {DbgPrint("Error\n");return FALSE;} 00225 PbDumpMcb( Mcb ); 00226 00227 DbgPrint("\nTest 0:|--NewRun--||--FollowingRun--\n"); 00228 if (!PbAddMcbEntry(Mcb, 0, 1100, 70)) {DbgPrint("Error\n");return FALSE;} 00229 PbDumpMcb( Mcb ); 00230 00231 PbUninitializeMcb(Mcb); 00232 00233 return TRUE; 00234 00235 } 00236 00237 00238 BOOLEAN 00239 TestRemoveEntry() 00240 { 00241 MCB Mcb; 00242 ULONG i; 00243 ULONG Vbn,Lbn,Length; 00244 00245 DbgPrint("\n\n\n>>>> Test PbRemoveMcbEntry <<<<\n"); 00246 00247 PbInitializeMcb(Mcb, NonPagedPool); 00248 if (!PbAddMcbEntry(Mcb, 0, 1000, 100)) {DbgPrint("Error\n");return FALSE;} 00249 00250 DbgPrint("\nTest --Previous--| Hole\n"); 00251 PbRemoveMcbEntry(Mcb, 90, 10); 00252 PbDumpMcb( Mcb ); 00253 00254 DbgPrint("\nTest --Previous--| Hole |--Following--\n"); 00255 PbRemoveMcbEntry(Mcb, 50, 10); 00256 PbDumpMcb( Mcb ); 00257 00258 DbgPrint("\nTest --Previous--| Hole |--Hole--\n"); 00259 PbRemoveMcbEntry(Mcb, 40, 10); 00260 PbDumpMcb( Mcb ); 00261 00262 DbgPrint("\nTest --hole--| Hole |--Following--\n"); 00263 PbRemoveMcbEntry(Mcb, 60, 10); 00264 PbDumpMcb( Mcb ); 00265 00266 DbgPrint("\nTest --hole--| Hole\n"); 00267 PbRemoveMcbEntry(Mcb, 70, 20); 00268 PbDumpMcb( Mcb ); 00269 00270 DbgPrint("\nTest 0: Hole |--Following--\n"); 00271 PbRemoveMcbEntry(Mcb, 0, 10); 00272 PbDumpMcb( Mcb ); 00273 00274 DbgPrint("\nTest over remove\n"); 00275 PbRemoveMcbEntry(Mcb, 0, 100); 00276 PbDumpMcb( Mcb ); 00277 00278 PbUninitializeMcb(Mcb); 00279 00280 00281 00282 PbInitializeMcb(Mcb, NonPagedPool); 00283 if (!PbAddMcbEntry(Mcb, 0, 1000, 100)) {DbgPrint("Error\n");return FALSE;} 00284 00285 PbRemoveMcbEntry(Mcb, 10, 10); 00286 DbgPrint("\nTest 0: Hole |--Hole--\n"); 00287 PbRemoveMcbEntry(Mcb, 0, 10); 00288 PbDumpMcb( Mcb ); 00289 00290 PbRemoveMcbEntry(Mcb, 30, 10); 00291 DbgPrint("\nTest --Hole--| Hole |--Hole--\n"); 00292 PbRemoveMcbEntry(Mcb, 20, 10); 00293 PbDumpMcb( Mcb ); 00294 00295 DbgPrint("\nTest over remove\n"); 00296 PbRemoveMcbEntry(Mcb, 0, 100); 00297 PbDumpMcb( Mcb ); 00298 00299 PbUninitializeMcb(Mcb); 00300 00301 00302 00303 PbInitializeMcb(Mcb, NonPagedPool); 00304 if (!PbAddMcbEntry(Mcb, 0, 1000, 100)){DbgPrint("Error\n");return FALSE;} 00305 00306 DbgPrint("\nTest 0: Hole\n"); 00307 PbRemoveMcbEntry(Mcb, 0, 100); 00308 PbDumpMcb( Mcb ); 00309 00310 if (!PbAddMcbEntry(Mcb, 0, 1000, 30)) {DbgPrint("Error\n");return FALSE;} 00311 if (!PbAddMcbEntry(Mcb, 30, 1130, 30)) {DbgPrint("Error\n");return FALSE;} 00312 if (!PbAddMcbEntry(Mcb, 60, 1060, 30)) {DbgPrint("Error\n");return FALSE;} 00313 if (!PbAddMcbEntry(Mcb, 90, 1190, 10)) {DbgPrint("Error\n");return FALSE;} 00314 00315 DbgPrint("\nTest --Previous--| Hole |--Index--||--Following--\n"); 00316 PbRemoveMcbEntry(Mcb, 30, 10); 00317 PbDumpMcb( Mcb ); 00318 00319 DbgPrint("\nTest --Hole--| Hole |--Index--||--Following--\n"); 00320 PbRemoveMcbEntry(Mcb, 40, 10); 00321 PbDumpMcb( Mcb ); 00322 00323 DbgPrint("\nTest --Previous--||--Index--| Hole |--Following--\n"); 00324 PbRemoveMcbEntry(Mcb, 80, 10); 00325 PbDumpMcb( Mcb ); 00326 00327 DbgPrint("\nTest --Previous--||--Index--| Hole |--Hole--\n"); 00328 PbRemoveMcbEntry(Mcb, 70, 10); 00329 PbDumpMcb( Mcb ); 00330 00331 DbgPrint("\nTest 0:|--Index--| Hole |--Index--||--Following--\n"); 00332 PbRemoveMcbEntry(Mcb, 10, 10); 00333 PbDumpMcb( Mcb ); 00334 00335 DbgPrint("\nTest over remove\n"); 00336 PbRemoveMcbEntry(Mcb, 0, 100); 00337 PbDumpMcb( Mcb ); 00338 00339 00340 00341 if (!PbAddMcbEntry(Mcb, 0, 1000, 30)) {DbgPrint("Error\n");return FALSE;} 00342 if (!PbAddMcbEntry(Mcb, 30, 1130, 30)) {DbgPrint("Error\n");return FALSE;} 00343 if (!PbAddMcbEntry(Mcb, 60, 1060, 30)) {DbgPrint("Error\n");return FALSE;} 00344 if (!PbAddMcbEntry(Mcb, 90, 1190, 10)) {DbgPrint("Error\n");return FALSE;} 00345 00346 DbgPrint("\nTest --Previous--||--Index--| Hole |--Index--||--Following--\n"); 00347 PbRemoveMcbEntry(Mcb, 40, 10); 00348 PbDumpMcb( Mcb ); 00349 00350 DbgPrint("\nTest 0:|--Index--| Hole |--Following--\n"); 00351 PbRemoveMcbEntry(Mcb, 20, 10); 00352 PbDumpMcb( Mcb ); 00353 00354 DbgPrint("\nTest --Previous--||--Index--| Hole\n"); 00355 PbRemoveMcbEntry(Mcb, 80, 20); 00356 PbDumpMcb( Mcb ); 00357 00358 DbgPrint("\nTest over remove\n"); 00359 PbRemoveMcbEntry(Mcb, 0, 100); 00360 PbDumpMcb( Mcb ); 00361 00362 00363 if (!PbAddMcbEntry(Mcb, 0, 1000, 100)){DbgPrint("Error\n");return FALSE;} 00364 00365 DbgPrint("\nTest 0:--Index--| Hole\n"); 00366 PbRemoveMcbEntry(Mcb, 50, 50); 00367 PbDumpMcb( Mcb ); 00368 00369 DbgPrint("\nTest over remove\n"); 00370 PbRemoveMcbEntry(Mcb, 0, 100); 00371 PbDumpMcb( Mcb ); 00372 00373 00374 00375 if (!PbAddMcbEntry(Mcb, 0, 1000, 50)) {DbgPrint("Error\n");return FALSE;} 00376 if (!PbAddMcbEntry(Mcb, 50, 1150, 50)) {DbgPrint("Error\n");return FALSE;} 00377 00378 DbgPrint("\nTest 0: hole |--Index--||--Following--\n"); 00379 PbRemoveMcbEntry(Mcb, 0, 20); 00380 PbDumpMcb( Mcb ); 00381 00382 PbUninitializeMcb(Mcb); 00383 00384 return TRUE; 00385 00386 } 00387 00388 00389 BOOLEAN 00390 TestLookupEntry() 00391 { 00392 MCB Mcb; 00393 ULONG i; 00394 ULONG Vbn,Lbn,Length; 00395 00396 DbgPrint("\n\n\n>>>> Test PbLookupMcbEntry <<<<\n"); 00397 00398 PbInitializeMcb(Mcb, NonPagedPool); 00399 00400 for (i = 0; i < 100; i += 30) { 00401 if (!PbAddMcbEntry(Mcb, i, 1000+i, 10)) 00402 {DbgPrint("Add1Error\n");return FALSE;} 00403 } 00404 for (i = 10; i < 100; i += 30) { 00405 if (!PbAddMcbEntry(Mcb, i, 1100+i, 10)) 00406 {DbgPrint("Add2Error\n");return FALSE;} 00407 } 00408 00409 PbDumpMcb( Mcb ); 00410 00411 for (i = 0; i < 100; i += 30) { 00412 if (!PbLookupMcbEntry(Mcb,i,&Lbn,&Length)) 00413 {DbgPrint("Lookup1Error %d\n", i);return FALSE;} 00414 if ((Lbn != 1000+i) || (Length != 10)) 00415 {DbgPrint("Result1Error %d, %d, %d\n", i, Lbn, Length);return FALSE;} 00416 if (!PbLookupMcbEntry(Mcb,i+5,&Lbn,&Length)) 00417 {DbgPrint("Lookup2Error %d\n", i);return FALSE;} 00418 if ((Lbn != 1000+i+5) || (Length != 5)) 00419 {DbgPrint("Result2Error %d, %d, %d\n", i, Lbn, Length);return FALSE;} 00420 } 00421 00422 for (i = 20; i < 100; i += 30) { 00423 if (!PbLookupMcbEntry(Mcb,i,&Lbn,&Length)) 00424 {DbgPrint("Lookup3Error %d\n", i);return FALSE;} 00425 if ((Lbn != 0) || (Length != 10)) 00426 {DbgPrint("Result3Error %d, %d, %d\n", i, Lbn, Length);return FALSE;} 00427 00428 if (!PbLookupMcbEntry(Mcb,i+5,&Lbn,&Length)) 00429 {DbgPrint("Lookup4Error %d\n", i);return FALSE;} 00430 if ((Lbn != 0) || (Length != 5)) { 00431 DbgPrint("Result4Error %d", i+5); 00432 DbgPrint(", %08lx", Lbn); 00433 DbgPrint(", %08lx\n", Length); 00434 return FALSE; 00435 } 00436 } 00437 00438 PbUninitializeMcb(Mcb); 00439 00440 return TRUE; 00441 00442 } 00443 00444 00445 BOOLEAN 00446 TestGetEntry() 00447 { 00448 MCB Mcb; 00449 ULONG i; 00450 ULONG Vbn,Lbn,Length; 00451 00452 DbgPrint("\n\n\n>>>> TestPbNumberOfRunsInMcb <<<<\n"); 00453 00454 PbInitializeMcb(Mcb, NonPagedPool); 00455 00456 for (i = 0; i < 100; i += 30) { 00457 if (!PbAddMcbEntry(Mcb, i, 1000+i, 10)) 00458 {DbgPrint("Add1Error\n");return FALSE;} 00459 } 00460 for (i = 10; i < 100; i += 30) { 00461 if (!PbAddMcbEntry(Mcb, i, 1100+i, 10)) 00462 {DbgPrint("Add2Error\n");return FALSE;} 00463 } 00464 00465 PbDumpMcb( Mcb ); 00466 00467 i = PbNumberOfRunsInMcb(Mcb); 00468 if (i != 10) {DbgPrint("Error\n");return FALSE;} 00469 for (i = 0; i < 10; i += 1) { 00470 if (!PbGetNextMcbEntry(Mcb,i,&Vbn,&Lbn,&Length)) 00471 {DbgPrint("Error\n");return FALSE;} 00472 DbgPrint("%d", i); 00473 DbgPrint(", %ld", Vbn); 00474 DbgPrint(", %ld", Lbn); 00475 DbgPrint(", %ld\n", Length); 00476 } 00477 00478 PbUninitializeMcb(Mcb); 00479 00480 return TRUE; 00481 00482 } 00483 00484 00485 BOOLEAN 00486 TestLookupLastEntry() 00487 { 00488 MCB Mcb; 00489 ULONG i; 00490 ULONG Vbn,Lbn,Length; 00491 00492 00493 DbgPrint("\n\n\n>>>> Test PbLookupLastMcbEntry <<<<\n"); 00494 00495 PbInitializeMcb(Mcb, NonPagedPool); 00496 00497 if (!PbAddMcbEntry(Mcb, 0, 1000, 100)) {DbgPrint("Error\n");return FALSE;} 00498 00499 if (!PbLookupLastMcbEntry(Mcb, &Vbn, &Lbn)) {DbgPrint("Error\n");return FALSE;} 00500 if ((Vbn != 99) && (Lbn != 1099)) {DbgPrint("Lookup Error\n");return FALSE;} 00501 00502 PbUninitializeMcb(Mcb); 00503 00504 return TRUE; 00505 } 00506

Generated on Sat May 15 19:42:00 2004 for test by doxygen 1.3.7