VirtualBox

Changeset 38462 in vbox for trunk/src


Ignore:
Timestamp:
Aug 15, 2011 4:23:31 PM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
73512
Message:

tstVDIo: Updates

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Storage/testcase/tstVDIo.cpp

    r38204 r38462  
    302302static DECLCALLBACK(int) vdScriptHandlerCopy(PVDTESTGLOB pGlob, PVDSCRIPTARG paScriptArgs, unsigned cScriptArgs);
    303303static DECLCALLBACK(int) vdScriptHandlerClose(PVDTESTGLOB pGlob, PVDSCRIPTARG paScriptArgs, unsigned cScriptArgs);
     304static DECLCALLBACK(int) vdScriptHandlerPrintFileSize(PVDTESTGLOB pGlob, PVDSCRIPTARG paScriptArgs, unsigned cScriptArgs);
    304305static DECLCALLBACK(int) vdScriptHandlerIoRngCreate(PVDTESTGLOB pGlob, PVDSCRIPTARG paScriptArgs, unsigned cScriptArgs);
    305306static DECLCALLBACK(int) vdScriptHandlerIoRngDestroy(PVDTESTGLOB pGlob, PVDSCRIPTARG paScriptArgs, unsigned cScriptArgs);
     
    334335    {"name",       'n', VDSCRIPTARGTYPE_STRING,          VDSCRIPTARGDESC_FLAG_MANDATORY},
    335336    {"backend",    'b', VDSCRIPTARGTYPE_STRING,          VDSCRIPTARGDESC_FLAG_MANDATORY},
     337    {"async",      'a', VDSCRIPTARGTYPE_BOOL,            0},
    336338    {"shareable",  's', VDSCRIPTARGTYPE_BOOL,            0},
    337339    {"readonly",   'r', VDSCRIPTARGTYPE_BOOL,            0}
     
    402404};
    403405
     406/* print file size action */
     407const 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
    404414/* I/O RNG create action */
    405415const VDSCRIPTARGDESC g_aArgIoRngCreate[] =
     
    495505    {"flush",                      g_aArgFlush,                       RT_ELEMENTS(g_aArgFlush),                      vdScriptHandlerFlush},
    496506    {"close",                      g_aArgClose,                       RT_ELEMENTS(g_aArgClose),                      vdScriptHandlerClose},
     507    {"printfilesize",              g_aArgPrintFileSize,               RT_ELEMENTS(g_aArgPrintFileSize),              vdScriptHandlerPrintFileSize},
    497508    {"merge",                      g_aArgMerge,                       RT_ELEMENTS(g_aArgMerge),                      vdScriptHandlerMerge},
    498509    {"compact",                    g_aArgCompact,                     RT_ELEMENTS(g_aArgCompact),                    vdScriptHandlerCompact},
     
    646657    bool fShareable = false;
    647658    bool fReadonly = false;
     659    bool fAsyncIo  = true;
    648660
    649661    for (unsigned i = 0; i < cScriptArgs; i++)
     
    674686            {
    675687                fReadonly = paScriptArgs[i].u.fFlag;
     688                break;
     689            }
     690            case 'a':
     691            {
     692                fAsyncIo = paScriptArgs[i].u.fFlag;
    676693                break;
    677694            }
     
    689706        if (pDisk)
    690707        {
    691             unsigned fOpenFlags = VD_OPEN_FLAGS_ASYNC_IO;
    692 
     708            unsigned fOpenFlags = 0;
     709
     710            if (fAsyncIo)
     711                fOpenFlags |= VD_OPEN_FLAGS_ASYNC_IO;
    693712            if (fShareable)
    694713                fOpenFlags |= VD_OPEN_FLAGS_SHAREABLE;
     
    788807            break;
    789808    }
     809
     810    if (   RT_SUCCESS(rc)
     811        && fAsync
     812        && !cMaxReqs)
     813        rc = VERR_INVALID_PARAMETER;
    790814
    791815    if (RT_SUCCESS(rc))
     
    13661390            rc = VERR_NOT_FOUND;
    13671391    }
     1392    return rc;
     1393}
     1394
     1395
     1396static 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
    13681428    return rc;
    13691429}
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette