- Timestamp:
- Mar 2, 2011 9:56:42 PM (14 years ago)
- svn:sync-xref-src-repo-rev:
- 70308
- Location:
- trunk/src/VBox/Storage/testcase
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Storage/testcase/VDIoBackendMem.cpp
r35663 r36131 54 54 } VDIOBACKENDREQ, *PVDIOBACKENDREQ; 55 55 56 typedef PVDIOBACKENDREQ *PPVDIOBACKENDREQ; 57 56 58 /** 57 59 * I/O memory backend … … 69 71 /** Flag whether the the server should be still running. */ 70 72 volatile bool fRunning; 73 /** Number of requests waiting in the request buffer. */ 74 volatile uint32_t cReqsWaiting; 71 75 } VDIOBACKENDMEM; 72 76 … … 93 97 if (pIoBackend) 94 98 { 95 rc = RTCircBufCreate(&pIoBackend->pRequestRing, VDMEMIOBACKEND_REQS * sizeof( VDIOBACKENDREQ));99 rc = RTCircBufCreate(&pIoBackend->pRequestRing, VDMEMIOBACKEND_REQS * sizeof(PVDIOBACKENDREQ)); 96 100 if (RT_SUCCESS(rc)) 97 101 { … … 143 147 { 144 148 PVDIOBACKENDREQ pReq = NULL; 149 PPVDIOBACKENDREQ ppReq = NULL; 145 150 size_t cbData; 146 151 147 RTCircBufAcquireWriteBlock(pIoBackend->pRequestRing, RT_OFFSETOF(VDIOBACKENDREQ, aSegs[cSegs]), (void **)&pReq, &cbData); 152 LogFlowFunc(("Queuing request\n")); 153 154 pReq = (PVDIOBACKENDREQ)RTMemAlloc(RT_OFFSETOF(VDIOBACKENDREQ, aSegs[cSegs])); 148 155 if (!pReq) 149 156 return VERR_NO_MEMORY; 150 157 151 Assert(cbData == (size_t)RT_OFFSETOF(VDIOBACKENDREQ, aSegs[cSegs])); 158 RTCircBufAcquireWriteBlock(pIoBackend->pRequestRing, sizeof(PVDIOBACKENDREQ), (void **)&ppReq, &cbData); 159 if (!pReq) 160 { 161 RTMemFree(pReq); 162 return VERR_NO_MEMORY; 163 } 164 165 Assert(cbData == sizeof(PVDIOBACKENDREQ)); 152 166 pReq->enmTxDir = enmTxDir; 153 167 pReq->cbTransfer = cbTransfer; … … 162 176 pReq->aSegs[i].cbSeg = paSegs[i].cbSeg; 163 177 } 164 RTCircBufReleaseWriteBlock(pIoBackend->pRequestRing, RT_OFFSETOF(VDIOBACKENDREQ, aSegs[cSegs])); 165 vdIoBackendMemThreadPoke(pIoBackend); 178 179 *ppReq = pReq; 180 RTCircBufReleaseWriteBlock(pIoBackend->pRequestRing, sizeof(PVDIOBACKENDREQ)); 181 uint32_t cReqsWaiting = ASMAtomicIncU32(&pIoBackend->cReqsWaiting); 182 if (cReqsWaiting == 1) 183 vdIoBackendMemThreadPoke(pIoBackend); 166 184 167 185 return VINF_SUCCESS; … … 187 205 188 206 PVDIOBACKENDREQ pReq; 207 PPVDIOBACKENDREQ ppReq; 189 208 size_t cbData; 190 191 RTCircBufAcquireReadBlock(pIoBackend->pRequestRing, sizeof(VDIOBACKENDREQ), (void **)&pReq, &cbData); 192 Assert(!pReq || cbData == sizeof(VDIOBACKENDREQ)); 193 194 while (pReq) 209 uint32_t cReqsWaiting = ASMAtomicXchgU32(&pIoBackend->cReqsWaiting, 0); 210 211 while (cReqsWaiting) 195 212 { 196 213 int rcReq = VINF_SUCCESS; 197 214 215 /* Do we have another request? */ 216 RTCircBufAcquireReadBlock(pIoBackend->pRequestRing, sizeof(PVDIOBACKENDREQ), (void **)&ppReq, &cbData); 217 Assert(!ppReq || cbData == sizeof(PVDIOBACKENDREQ)); 218 RTCircBufReleaseReadBlock(pIoBackend->pRequestRing, cbData); 219 220 pReq = *ppReq; 221 cReqsWaiting--; 222 223 LogFlowFunc(("Processing request\n")); 198 224 switch (pReq->enmTxDir) 199 225 { … … 220 246 /* Notify completion. */ 221 247 pReq->pfnComplete(pReq->pvUser, rcReq); 222 223 RTCircBufReleaseReadBlock(pIoBackend->pRequestRing, cbData); 224 225 /* Do we have another request? */ 226 RTCircBufAcquireReadBlock(pIoBackend->pRequestRing, sizeof(VDIOBACKENDREQ), (void **)&pReq, &cbData); 227 Assert(!pReq || cbData == sizeof(VDIOBACKENDREQ)); 248 RTMemFree(pReq); 228 249 } 229 250 } -
trunk/src/VBox/Storage/testcase/tstVDIo.cpp
r35789 r36131 17 17 */ 18 18 #define LOGGROUP LOGGROUP_DEFAULT 19 #define RTMEM_WRAP_TO_EF_APIS20 19 #include <VBox/vd.h> 21 20 #include <VBox/err.h> … … 31 30 #include <iprt/semaphore.h> 32 31 #include <iprt/thread.h> 32 #include <iprt/rand.h> 33 33 34 34 #include "VDMemDisk.h" … … 281 281 static DECLCALLBACK(int) vdScriptHandlerDestroyDisk(PVDTESTGLOB pGlob, PVDSCRIPTARG paScriptArgs, unsigned cScriptArgs); 282 282 static DECLCALLBACK(int) vdScriptHandlerCompareDisks(PVDTESTGLOB pGlob, PVDSCRIPTARG paScriptArgs, unsigned cScriptArgs); 283 static DECLCALLBACK(int) vdScriptHandlerDumpDiskInfo(PVDTESTGLOB pGlob, PVDSCRIPTARG paScriptArgs, unsigned cScriptArgs); 283 284 284 285 /* create action */ … … 349 350 /* pcszName chId enmType fFlags */ 350 351 {"size", 'd', VDSCRIPTARGTYPE_UNSIGNED_NUMBER, VDSCRIPTARGDESC_FLAG_MANDATORY | VDSCRIPTARGDESC_FLAG_SIZE_SUFFIX}, 351 {"seed", 's', VDSCRIPTARGTYPE_UNSIGNED_NUMBER, VDSCRIPTARGDESC_FLAG_MANDATORY} 352 {"mode", 'm', VDSCRIPTARGTYPE_STRING, VDSCRIPTARGDESC_FLAG_MANDATORY}, 353 {"seed", 's', VDSCRIPTARGTYPE_UNSIGNED_NUMBER, 0} 352 354 }; 353 355 … … 387 389 {"disk1", '1', VDSCRIPTARGTYPE_STRING, VDSCRIPTARGDESC_FLAG_MANDATORY}, 388 390 {"disk2", '2', VDSCRIPTARGTYPE_STRING, VDSCRIPTARGDESC_FLAG_MANDATORY} 391 }; 392 393 /* Dump disk info */ 394 const VDSCRIPTARGDESC g_aArgDumpDiskInfo[] = 395 { 396 /* pcszName chId enmType fFlags */ 397 {"disk", 'd', VDSCRIPTARGTYPE_STRING, VDSCRIPTARGDESC_FLAG_MANDATORY}, 389 398 }; 390 399 … … 404 413 {"createdisk", g_aArgCreateDisk, RT_ELEMENTS(g_aArgCreateDisk), vdScriptHandlerCreateDisk}, 405 414 {"destroydisk", g_aArgDestroyDisk, RT_ELEMENTS(g_aArgDestroyDisk), vdScriptHandlerDestroyDisk}, 406 {"comparedisks", g_aArgCompareDisks, RT_ELEMENTS(g_aArgCompareDisks), vdScriptHandlerCompareDisks} 415 {"comparedisks", g_aArgCompareDisks, RT_ELEMENTS(g_aArgCompareDisks), vdScriptHandlerCompareDisks}, 416 {"dumpdiskinfo", g_aArgDumpDiskInfo, RT_ELEMENTS(g_aArgDumpDiskInfo), vdScriptHandlerDumpDiskInfo}, 407 417 }; 408 418 … … 982 992 size_t cbPattern = 0; 983 993 uint64_t uSeed = 0; 994 const char *pcszSeeder = NULL; 984 995 985 996 for (unsigned i = 0; i < cScriptArgs; i++) … … 995 1006 { 996 1007 uSeed = paScriptArgs[i].u.u64; 1008 break; 1009 } 1010 case 'm': 1011 { 1012 pcszSeeder = paScriptArgs[i].u.pcszString; 997 1013 break; 998 1014 } … … 1008 1024 } 1009 1025 else 1010 rc = VDIoRndCreate(&pGlob->pIoRnd, cbPattern, uSeed); 1026 { 1027 uint64_t uSeedToUse = 0; 1028 1029 if (!RTStrICmp(pcszSeeder, "manual")) 1030 uSeedToUse = uSeed; 1031 else if (!RTStrICmp(pcszSeeder, "time")) 1032 uSeedToUse = RTTimeSystemMilliTS(); 1033 else if (!RTStrICmp(pcszSeeder, "system")) 1034 { 1035 RTRAND hRand; 1036 rc = RTRandAdvCreateSystemTruer(&hRand); 1037 if (RT_SUCCESS(rc)) 1038 { 1039 RTRandAdvBytes(hRand, &uSeedToUse, sizeof(uSeedToUse)); 1040 RTRandAdvDestroy(hRand); 1041 } 1042 } 1043 1044 if (RT_SUCCESS(rc)) 1045 rc = VDIoRndCreate(&pGlob->pIoRnd, cbPattern, uSeed); 1046 } 1011 1047 1012 1048 return rc; … … 1266 1302 } 1267 1303 } 1304 else 1305 rc = VERR_NOT_FOUND; 1306 1307 return rc; 1308 } 1309 1310 static DECLCALLBACK(int) vdScriptHandlerDumpDiskInfo(PVDTESTGLOB pGlob, PVDSCRIPTARG paScriptArgs, unsigned cScriptArgs) 1311 { 1312 int rc = VINF_SUCCESS; 1313 const char *pcszDisk = NULL; 1314 PVDDISK pDisk = NULL; 1315 1316 for (unsigned i = 0; i < cScriptArgs; i++) 1317 { 1318 switch (paScriptArgs[i].chId) 1319 { 1320 case 'd': 1321 { 1322 pcszDisk = paScriptArgs[i].u.pcszString; 1323 break; 1324 } 1325 default: 1326 AssertMsgFailed(("Invalid argument given!\n")); 1327 } 1328 } 1329 1330 pDisk = tstVDIoGetDiskByName(pGlob, pcszDisk); 1331 1332 if (pDisk) 1333 VDDumpImages(pDisk->pVD); 1268 1334 else 1269 1335 rc = VERR_NOT_FOUND; -
trunk/src/VBox/Storage/testcase/tstVDShareable.vd
r35789 r36131 17 17 18 18 # Init I/O RNG for generating random data for writes 19 iorngcreate size=10M seed=123456789019 iorngcreate size=10M mode=manual seed=1234567890 20 20 21 21 # Create disk containers.
Note:
See TracChangeset
for help on using the changeset viewer.