- Timestamp:
- Aug 15, 2011 4:23:31 PM (14 years ago)
- svn:sync-xref-src-repo-rev:
- 73512
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Storage/testcase/tstVDIo.cpp
r38204 r38462 302 302 static DECLCALLBACK(int) vdScriptHandlerCopy(PVDTESTGLOB pGlob, PVDSCRIPTARG paScriptArgs, unsigned cScriptArgs); 303 303 static DECLCALLBACK(int) vdScriptHandlerClose(PVDTESTGLOB pGlob, PVDSCRIPTARG paScriptArgs, unsigned cScriptArgs); 304 static DECLCALLBACK(int) vdScriptHandlerPrintFileSize(PVDTESTGLOB pGlob, PVDSCRIPTARG paScriptArgs, unsigned cScriptArgs); 304 305 static DECLCALLBACK(int) vdScriptHandlerIoRngCreate(PVDTESTGLOB pGlob, PVDSCRIPTARG paScriptArgs, unsigned cScriptArgs); 305 306 static DECLCALLBACK(int) vdScriptHandlerIoRngDestroy(PVDTESTGLOB pGlob, PVDSCRIPTARG paScriptArgs, unsigned cScriptArgs); … … 334 335 {"name", 'n', VDSCRIPTARGTYPE_STRING, VDSCRIPTARGDESC_FLAG_MANDATORY}, 335 336 {"backend", 'b', VDSCRIPTARGTYPE_STRING, VDSCRIPTARGDESC_FLAG_MANDATORY}, 337 {"async", 'a', VDSCRIPTARGTYPE_BOOL, 0}, 336 338 {"shareable", 's', VDSCRIPTARGTYPE_BOOL, 0}, 337 339 {"readonly", 'r', VDSCRIPTARGTYPE_BOOL, 0} … … 402 404 }; 403 405 406 /* print file size action */ 407 const VDSCRIPTARGDESC g_aArgPrintFileSize[] = 408 { 409 /* pcszName chId enmType fFlags */ 410 {"disk", 'd', VDSCRIPTARGTYPE_STRING, VDSCRIPTARGDESC_FLAG_MANDATORY}, 411 {"image", 'i', VDSCRIPTARGTYPE_UNSIGNED_NUMBER, VDSCRIPTARGDESC_FLAG_MANDATORY} 412 }; 413 404 414 /* I/O RNG create action */ 405 415 const VDSCRIPTARGDESC g_aArgIoRngCreate[] = … … 495 505 {"flush", g_aArgFlush, RT_ELEMENTS(g_aArgFlush), vdScriptHandlerFlush}, 496 506 {"close", g_aArgClose, RT_ELEMENTS(g_aArgClose), vdScriptHandlerClose}, 507 {"printfilesize", g_aArgPrintFileSize, RT_ELEMENTS(g_aArgPrintFileSize), vdScriptHandlerPrintFileSize}, 497 508 {"merge", g_aArgMerge, RT_ELEMENTS(g_aArgMerge), vdScriptHandlerMerge}, 498 509 {"compact", g_aArgCompact, RT_ELEMENTS(g_aArgCompact), vdScriptHandlerCompact}, … … 646 657 bool fShareable = false; 647 658 bool fReadonly = false; 659 bool fAsyncIo = true; 648 660 649 661 for (unsigned i = 0; i < cScriptArgs; i++) … … 674 686 { 675 687 fReadonly = paScriptArgs[i].u.fFlag; 688 break; 689 } 690 case 'a': 691 { 692 fAsyncIo = paScriptArgs[i].u.fFlag; 676 693 break; 677 694 } … … 689 706 if (pDisk) 690 707 { 691 unsigned fOpenFlags = VD_OPEN_FLAGS_ASYNC_IO; 692 708 unsigned fOpenFlags = 0; 709 710 if (fAsyncIo) 711 fOpenFlags |= VD_OPEN_FLAGS_ASYNC_IO; 693 712 if (fShareable) 694 713 fOpenFlags |= VD_OPEN_FLAGS_SHAREABLE; … … 788 807 break; 789 808 } 809 810 if ( RT_SUCCESS(rc) 811 && fAsync 812 && !cMaxReqs) 813 rc = VERR_INVALID_PARAMETER; 790 814 791 815 if (RT_SUCCESS(rc)) … … 1366 1390 rc = VERR_NOT_FOUND; 1367 1391 } 1392 return rc; 1393 } 1394 1395 1396 static DECLCALLBACK(int) vdScriptHandlerPrintFileSize(PVDTESTGLOB pGlob, PVDSCRIPTARG paScriptArgs, unsigned cScriptArgs) 1397 { 1398 int rc = VINF_SUCCESS; 1399 const char *pcszDisk = NULL; 1400 PVDDISK pDisk = NULL; 1401 unsigned nImage = 0; 1402 1403 for (unsigned i = 0; i < cScriptArgs; i++) 1404 { 1405 switch (paScriptArgs[i].chId) 1406 { 1407 case 'd': 1408 { 1409 pcszDisk = paScriptArgs[i].u.pcszString; 1410 break; 1411 } 1412 case 'i': 1413 { 1414 nImage = (unsigned)paScriptArgs[i].u.u64; 1415 break; 1416 } 1417 default: 1418 AssertMsgFailed(("Invalid argument given!\n")); 1419 } 1420 } 1421 1422 pDisk = tstVDIoGetDiskByName(pGlob, pcszDisk); 1423 if (pDisk) 1424 RTPrintf("%s: size of image %u is %llu\n", pcszDisk, nImage, VDGetFileSize(pDisk->pVD, nImage)); 1425 else 1426 rc = VERR_NOT_FOUND; 1427 1368 1428 return rc; 1369 1429 }
Note:
See TracChangeset
for help on using the changeset viewer.