Changeset 52371 in vbox for trunk/src/VBox/Storage/testcase/tstVDIo.cpp
- Timestamp:
- Aug 13, 2014 7:00:27 PM (11 years ago)
- svn:sync-xref-src-repo-rev:
- 95511
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Storage/testcase/tstVDIo.cpp
r52111 r52371 6 6 7 7 /* 8 * Copyright (C) 2011-201 3Oracle Corporation8 * Copyright (C) 2011-2014 Oracle Corporation 9 9 * 10 10 * This file is part of VirtualBox Open Source Edition (OSE), as … … 33 33 #include <iprt/rand.h> 34 34 #include <iprt/critsect.h> 35 #include <iprt/test.h> 35 36 36 37 #include "VDMemDisk.h" … … 40 41 #include "VDScript.h" 41 42 #include "BuiltinTests.h" 43 44 /** forward declaration for the global test data pointer. */ 45 typedef struct VDTESTGLOB *PVDTESTGLOB; 42 46 43 47 /** … … 100 104 /** Logical CHS geometry. */ 101 105 VDGEOMETRY LogicalGeom; 106 /** Global test data. */ 107 PVDTESTGLOB pTestGlob; 102 108 } VDDISK, *PVDDISK; 103 109 … … 142 148 /** Current storage backend to use. */ 143 149 char *pszIoBackend; 144 } VDTESTGLOB, *PVDTESTGLOB; 150 /** Testcase handle. */ 151 RTTEST hTest; 152 } VDTESTGLOB; 145 153 146 154 /** … … 256 264 VDSCRIPTTYPE_STRING, 257 265 VDSCRIPTTYPE_UINT64, 266 VDSCRIPTTYPE_BOOL, 258 267 VDSCRIPTTYPE_BOOL 259 268 }; … … 269 278 VDSCRIPTTYPE_BOOL, /* readonly */ 270 279 VDSCRIPTTYPE_BOOL, /* discard */ 271 VDSCRIPTTYPE_BOOL /* ignoreflush */ 280 VDSCRIPTTYPE_BOOL, /* ignoreflush */ 281 VDSCRIPTTYPE_BOOL, /* honorsame */ 272 282 }; 273 283 … … 533 543 bool fDynamic = true; 534 544 bool fIgnoreFlush = false; 545 bool fHonorSame = false; 535 546 PVDIOBACKEND pIoBackend = NULL; 536 547 … … 558 569 cbSize = paScriptArgs[5].u64; 559 570 fIgnoreFlush = paScriptArgs[6].f; 571 fHonorSame = paScriptArgs[7].f; 560 572 561 573 if (RT_SUCCESS(rc)) … … 572 584 if (fIgnoreFlush) 573 585 fOpenFlags |= VD_OPEN_FLAGS_IGNORE_FLUSH; 586 587 if (fHonorSame) 588 fOpenFlags |= VD_OPEN_FLAGS_HONOR_SAME; 574 589 575 590 if (fBase) … … 601 616 bool fDiscard = false; 602 617 bool fIgnoreFlush = false; 618 bool fHonorSame = false; 603 619 604 620 pcszDisk = paScriptArgs[0].psz; … … 609 625 fAsyncIo = paScriptArgs[5].f; 610 626 fDiscard = paScriptArgs[6].f; 627 fIgnoreFlush = paScriptArgs[7].f; 628 fHonorSame = paScriptArgs[8].f; 611 629 612 630 if (RT_SUCCESS(rc)) … … 627 645 if (fIgnoreFlush) 628 646 fOpenFlags |= VD_OPEN_FLAGS_IGNORE_FLUSH; 647 if (fHonorSame) 648 fOpenFlags |= VD_OPEN_FLAGS_HONOR_SAME; 629 649 630 650 rc = VDOpen(pDisk->pVD, pcszBackend, pcszImage, fOpenFlags, pGlob->pInterfacesImages); … … 713 733 VDIOTEST IoTest; 714 734 735 RTTestSub(pGlob->hTest, "Basic I/O"); 715 736 rc = tstVDIoTestInit(&IoTest, pGlob, fRandomAcc, cbIo, cbBlkSize, offStart, offEnd, uWriteChance, pPattern); 716 737 if (RT_SUCCESS(rc)) … … 771 792 if (VDMemDiskCmp(pDisk->pMemDiskVerify, paIoReq[idx].off, paIoReq[idx].cbReq, &SgBuf)) 772 793 { 773 RT Printf("Corrupted disk at offset %llu!\n", paIoReq[idx].off);794 RTTestFailed(pGlob->hTest, "Corrupted disk at offset %llu!\n", paIoReq[idx].off); 774 795 rc = VERR_INVALID_STATE; 775 796 } … … 850 871 &paIoReq[idx].SgBuf)) 851 872 { 852 RT Printf("Corrupted disk at offset %llu!\n", paIoReq[idx].off);873 RTTestFailed(pGlob->hTest, "Corrupted disk at offset %llu!\n", paIoReq[idx].off); 853 874 rc = VERR_INVALID_STATE; 854 875 } … … 924 945 NanoTS = RTTimeNanoTS() - NanoTS; 925 946 uint64_t SpeedKBs = (uint64_t)(cbIo / (NanoTS / 1000000000.0) / 1024); 926 RTPrintf("I/O Test: Throughput %lld kb/s\n", SpeedKBs); 947 RTTestValue(pGlob->hTest, "Throughput", SpeedKBs, RTTESTUNIT_KILOBYTES_PER_SEC); 948 949 for (unsigned i = 0; i < cMaxTasksOutstanding; i++) 950 { 951 if (paIoReq[i].pvBufRead) 952 RTMemFree(paIoReq[i].pvBufRead); 953 } 927 954 928 955 RTSemEventDestroy(EventSem); … … 1746 1773 if (pDisk) 1747 1774 { 1775 pDisk->pTestGlob = pGlob; 1748 1776 pDisk->pszName = RTStrDup(pcszDisk); 1749 1777 if (pDisk->pszName) … … 1846 1874 cbDisk2 = VDGetSize(pDisk2->pVD, VD_LAST_IMAGE); 1847 1875 1876 RTTestSub(pGlob->hTest, "Comparing two disks for equal content"); 1848 1877 if (cbDisk1 != cbDisk2) 1849 RT Printf("Disks differ in size %llu vs %llu\n", cbDisk1, cbDisk2);1878 RTTestFailed(pGlob->hTest, "Disks differ in size %llu vs %llu\n", cbDisk1, cbDisk2); 1850 1879 else 1851 1880 { … … 1862 1891 if (memcmp(pbBuf1, pbBuf2, cbRead)) 1863 1892 { 1864 RT Printf("Disks differ at offset %llu\n", uOffCur);1893 RTTestFailed(pGlob->hTest, "Disks differ at offset %llu\n", uOffCur); 1865 1894 rc = VERR_DEV_IO_ERROR; 1866 1895 break; … … 1869 1898 else 1870 1899 { 1871 RT Printf("Reading one disk at offset %llu failed\n", uOffCur);1900 RTTestFailed(pGlob->hTest, "Reading one disk at offset %llu failed\n", uOffCur); 1872 1901 break; 1873 1902 } … … 2517 2546 if (VDMemDiskCmp(pDisk->pMemDiskVerify, pIoReq->off, pIoReq->cbReq, 2518 2547 &pIoReq->SgBuf)) 2519 RT Printf("Corrupted disk at offset %llu!\n", pIoReq->off);2548 RTTestFailed(pDisk->pTestGlob->hTest, "Corrupted disk at offset %llu!\n", pIoReq->off); 2520 2549 RTCritSectLeave(&pDisk->CritSectVerify); 2521 2550 } … … 2697 2726 AssertRC(rc); 2698 2727 2699 /* Init I/O backend. */ 2700 rc = VDIoBackendCreate(&GlobTest.pIoBackend); 2728 rc = RTTestCreate("tstVDIo", &GlobTest.hTest); 2701 2729 if (RT_SUCCESS(rc)) 2702 2730 { 2703 VDSCRIPTCTX hScriptCtx = NULL;2704 rc = VD ScriptCtxCreate(&hScriptCtx);2731 /* Init I/O backend. */ 2732 rc = VDIoBackendCreate(&GlobTest.pIoBackend); 2705 2733 if (RT_SUCCESS(rc)) 2706 2734 { 2707 rc = VDScriptCtxCallbacksRegister(hScriptCtx, g_aScriptActions, g_cScriptActions, &GlobTest); 2708 AssertRC(rc); 2709 2710 rc = VDScriptCtxLoadScript(hScriptCtx, pszScript); 2711 if (RT_FAILURE(rc)) 2735 VDSCRIPTCTX hScriptCtx = NULL; 2736 rc = VDScriptCtxCreate(&hScriptCtx); 2737 if (RT_SUCCESS(rc)) 2712 2738 { 2713 RTPrintf("Loading the script failed rc=%Rrc\n", rc); 2739 RTTEST_CHECK_RC_OK(GlobTest.hTest, 2740 VDScriptCtxCallbacksRegister(hScriptCtx, g_aScriptActions, g_cScriptActions, &GlobTest)); 2741 2742 RTTestBanner(GlobTest.hTest); 2743 rc = VDScriptCtxLoadScript(hScriptCtx, pszScript); 2744 if (RT_FAILURE(rc)) 2745 { 2746 RTPrintf("Loading the script failed rc=%Rrc\n", rc); 2747 } 2748 else 2749 rc = VDScriptCtxCallFn(hScriptCtx, "main", NULL, 0); 2750 VDScriptCtxDestroy(hScriptCtx); 2714 2751 } 2715 else 2716 rc = VDScriptCtxCallFn(hScriptCtx, "main", NULL, 0); 2717 VDScriptCtxDestroy(hScriptCtx); 2718 } 2719 VDIoBackendDestroy(GlobTest.pIoBackend); 2720 } 2721 else 2722 RTPrintf("Creating the I/O backend failed rc=%Rrc\n"); 2752 VDIoBackendDestroy(GlobTest.pIoBackend); 2753 } 2754 else 2755 RTPrintf("Creating the I/O backend failed rc=%Rrc\n"); 2756 2757 RTTestSummaryAndDestroy(GlobTest.hTest); 2758 } 2759 else 2760 RTStrmPrintf(g_pStdErr, "tstVDIo: fatal error: RTTestCreate failed with rc=%Rrc\n", rc); 2723 2761 2724 2762 RTStrFree(GlobTest.pszIoBackend); … … 2746 2784 AssertPtr(pszScript); 2747 2785 tstVDIoScriptExec(pszScript); 2786 RTStrFree(pszScript); 2748 2787 } 2749 2788 else
Note:
See TracChangeset
for help on using the changeset viewer.