VirtualBox

source: vbox/trunk/src/VBox/VMM/testcase/tstPDMAsyncCompletionStress.cpp@ 49885

Last change on this file since 49885 was 44528, checked in by vboxsync, 12 years ago

header (C) fixes

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 20.4 KB
Line 
1/* $Id: tstPDMAsyncCompletionStress.cpp 44528 2013-02-04 14:27:54Z vboxsync $ */
2/** @file
3 * PDM Asynchronous Completion Stresstest.
4 *
5 * This testcase is for stress testing the async completion interface.
6 */
7
8/*
9 * Copyright (C) 2008-2013 Oracle Corporation
10 *
11 * This file is part of VirtualBox Open Source Edition (OSE), as
12 * available from http://www.virtualbox.org. This file is free software;
13 * you can redistribute it and/or modify it under the terms of the GNU
14 * General Public License (GPL) as published by the Free Software
15 * Foundation, in version 2 as it comes in the "COPYING" file of the
16 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
17 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
18 */
19
20/*******************************************************************************
21* Header Files *
22*******************************************************************************/
23#define LOG_GROUP LOG_GROUP_PDM_ASYNC_COMPLETION
24
25#include "VMInternal.h" /* UVM */
26#include <VBox/vmm/vm.h>
27#include <VBox/vmm/uvm.h>
28#include <VBox/vmm/pdmasynccompletion.h>
29#include <VBox/vmm/vmm.h>
30#include <VBox/vmm/cpum.h>
31#include <VBox/err.h>
32#include <VBox/log.h>
33#include <VBox/vmm/pdmapi.h>
34#include <VBox/vmm/pdmthread.h>
35#include <iprt/alloc.h>
36#include <iprt/asm.h>
37#include <iprt/assert.h>
38#include <iprt/file.h>
39#include <iprt/initterm.h>
40#include <iprt/semaphore.h>
41#include <iprt/rand.h>
42#include <iprt/string.h>
43#include <iprt/path.h>
44#include <iprt/stream.h>
45#include <iprt/thread.h>
46#include <iprt/param.h>
47#include <iprt/message.h>
48
49#define TESTCASE "tstPDMAsyncCompletionStress"
50
51#if 0
52/** Number of simultaneous open endpoints for reading and writing. */
53#define NR_OPEN_ENDPOINTS 10
54/** Test pattern size. */
55#define TEST_PATTERN_SIZE (100*_1M)
56/** Minimum file size. */
57#define FILE_SIZE_MIN (100 * _1M)
58/** Maximum file size. */
59#define FILE_SIZE_MAX (10000UL * _1M)
60/** Minimum segment size. */
61#define SEGMENT_SIZE_MIN (512)
62/** Maximum segment size. */
63#define SEGMENT_SIZE_MAX (TEST_PATTERN_SIZE)
64/** Maximum number of active tasks. */
65#define TASK_ACTIVE_MAX (1024)
66/** Maximum size of a transfer. */
67#define TASK_TRANSFER_SIZE_MAX (10*_1M)
68#else
69/** Number of simultaneous open endpoints for reading and writing. */
70#define NR_OPEN_ENDPOINTS 5
71/** Test pattern size. */
72#define TEST_PATTERN_SIZE (10*_1M)
73/** Minimum file size. */
74#define FILE_SIZE_MIN (100 * _1M)
75/** Maximum file size. */
76#define FILE_SIZE_MAX (1000UL * _1M)
77/** Minimum segment size. */
78#define SEGMENT_SIZE_MIN (512)
79/** Maximum segment size. */
80#define SEGMENT_SIZE_MAX (TEST_PATTERN_SIZE)
81/** Maximum number of active tasks. */
82#define TASK_ACTIVE_MAX (1)
83/** Maximum size of a transfer. */
84#define TASK_TRANSFER_SIZE_MAX (_1M)
85#endif
86
87/**
88 * Structure defining a file segment.
89 */
90typedef struct PDMACTESTFILESEG
91{
92 /** Start offset in the file. */
93 RTFOFF off;
94 /** Size of the segment. */
95 size_t cbSegment;
96 /** Pointer to the start of the data in the test pattern used for the segment. */
97 uint8_t *pbData;
98} PDMACTESTFILESEG, *PPDMACTESTFILESEG;
99
100/**
101 * Structure defining a I/O task.
102 */
103typedef struct PDMACTESTFILETASK
104{
105 /** Flag whether the task is currently active. */
106 bool fActive;
107 /** Flag whether this is a write. */
108 bool fWrite;
109 /** Start offset. */
110 RTFOFF off;
111 /** Data segment */
112 RTSGSEG DataSeg;
113 /** Task handle. */
114 PPDMASYNCCOMPLETIONTASK hTask;
115} PDMACTESTFILETASK, *PPDMACTESTFILETASK;
116
117/**
118 * Structure defining a test file.
119 */
120typedef struct PDMACTESTFILE
121{
122 /** The PDM async completion endpoint handle. */
123 PPDMASYNCCOMPLETIONENDPOINT hEndpoint;
124 /** Template used for this file. */
125 PPDMASYNCCOMPLETIONTEMPLATE pTemplate;
126 /** Maximum size of the file. */
127 uint64_t cbFileMax;
128 /** Current size of the file. */
129 uint64_t cbFileCurr;
130 /** Size of a file segment. */
131 size_t cbFileSegment;
132 /** Maximum number of segments. */
133 unsigned cSegments;
134 /** Pointer to the array describing how the file is assembled
135 * of the test pattern. Used for comparing read data to ensure
136 * that no corruption occurred.
137 */
138 PPDMACTESTFILESEG paSegs;
139 /** Maximum number of active tasks for this endpoint. */
140 uint32_t cTasksActiveMax;
141 /** Number of current active tasks. */
142 volatile uint32_t cTasksActiveCurr;
143 /** Pointer to the array of task. */
144 PPDMACTESTFILETASK paTasks;
145 /** I/O thread handle. */
146 PPDMTHREAD hThread;
147 /** Flag whether the thread should terminate. */
148 bool fRunning;
149} PDMACTESTFILE, *PPDMACTESTFILE;
150
151/** Buffer storing the random test pattern. */
152uint8_t *g_pbTestPattern = NULL;
153/** Size of the test pattern. */
154size_t g_cbTestPattern;
155/** Array holding test files. */
156PDMACTESTFILE g_aTestFiles[NR_OPEN_ENDPOINTS];
157
158static void tstPDMACStressTestFileTaskCompleted(PVM pVM, void *pvUser, void *pvUser2, int rcReq);
159
160static void tstPDMACStressTestFileVerify(PPDMACTESTFILE pTestFile, PPDMACTESTFILETASK pTestTask)
161{
162 size_t cbLeft = pTestTask->DataSeg.cbSeg;
163 RTFOFF off = pTestTask->off;
164 uint8_t *pbBuf = (uint8_t *)pTestTask->DataSeg.pvSeg;
165
166 while (cbLeft)
167 {
168 size_t cbCompare;
169 unsigned iSeg = off / pTestFile->cbFileSegment;
170 PPDMACTESTFILESEG pSeg = &pTestFile->paSegs[iSeg];
171 uint8_t *pbTestPattern;
172 unsigned offSeg = off - pSeg->off;
173
174 cbCompare = RT_MIN(cbLeft, pSeg->cbSegment - offSeg);
175 pbTestPattern = pSeg->pbData + offSeg;
176
177 if (memcmp(pbBuf, pbTestPattern, cbCompare))
178 {
179 unsigned idx = 0;
180
181 while ( (pbBuf[idx] == pbTestPattern[idx])
182 && (idx < cbCompare))
183 idx++;
184
185 RTMsgError("Unexpected data for off=%RTfoff size=%u\n"
186 "Expected %c got %c\n",
187 pTestTask->off + idx, pTestTask->DataSeg.cbSeg,
188 pbTestPattern[idx], pbBuf[idx]);
189 RTAssertDebugBreak();
190 }
191
192 pbBuf += cbCompare;
193 off += cbCompare;
194 cbLeft -= cbCompare;
195 }
196}
197
198static void tstPDMACStressTestFileFillBuffer(PPDMACTESTFILE pTestFile, PPDMACTESTFILETASK pTestTask)
199{
200 uint8_t *pbBuf = (uint8_t *)pTestTask->DataSeg.pvSeg;
201 size_t cbLeft = pTestTask->DataSeg.cbSeg;
202 RTFOFF off = pTestTask->off;
203
204 Assert(pTestTask->fWrite && pTestTask->fActive);
205
206 while (cbLeft)
207 {
208 size_t cbFill;
209 unsigned iSeg = off / pTestFile->cbFileSegment;
210 PPDMACTESTFILESEG pSeg = &pTestFile->paSegs[iSeg];
211 uint8_t *pbTestPattern;
212 unsigned offSeg = off - pSeg->off;
213
214 cbFill = RT_MIN(cbLeft, pSeg->cbSegment - offSeg);
215 pbTestPattern = pSeg->pbData + offSeg;
216
217 memcpy(pbBuf, pbTestPattern, cbFill);
218
219 pbBuf += cbFill;
220 off += cbFill;
221 cbLeft -= cbFill;
222 }
223}
224
225static int tstPDMACStressTestFileWrite(PPDMACTESTFILE pTestFile, PPDMACTESTFILETASK pTestTask)
226{
227 int rc = VINF_SUCCESS;
228
229 Assert(!pTestTask->fActive);
230
231 pTestTask->fActive = true;
232 pTestTask->fWrite = true;
233 pTestTask->DataSeg.cbSeg = RTRandU32Ex(512, TASK_TRANSFER_SIZE_MAX) & ~511;
234
235 uint64_t offMax;
236
237 /* Did we reached the maximum file size */
238 if (pTestFile->cbFileCurr < pTestFile->cbFileMax)
239 {
240 offMax = (pTestFile->cbFileMax - pTestFile->cbFileCurr) < pTestTask->DataSeg.cbSeg
241 ? pTestFile->cbFileMax - pTestTask->DataSeg.cbSeg
242 : pTestFile->cbFileCurr;
243 }
244 else
245 offMax = pTestFile->cbFileMax - pTestTask->DataSeg.cbSeg;
246
247 uint64_t offMin;
248
249 /*
250 * If we reached the maximum file size write in the whole file
251 * otherwise we will enforce the range for random offsets to let it grow
252 * more quickly.
253 */
254 if (pTestFile->cbFileCurr == pTestFile->cbFileMax)
255 offMin = 0;
256 else
257 offMin = RT_MIN(pTestFile->cbFileCurr, offMax);
258
259
260 pTestTask->off = RTRandU64Ex(offMin, offMax) & ~511;
261
262 /* Set new file size of required */
263 if ((uint64_t)pTestTask->off + pTestTask->DataSeg.cbSeg > pTestFile->cbFileCurr)
264 pTestFile->cbFileCurr = pTestTask->off + pTestTask->DataSeg.cbSeg;
265
266 AssertMsg(pTestFile->cbFileCurr <= pTestFile->cbFileMax,
267 ("Current file size (%llu) exceeds final size (%llu)\n",
268 pTestFile->cbFileCurr, pTestFile->cbFileMax));
269
270 /* Allocate data buffer. */
271 pTestTask->DataSeg.pvSeg = RTMemAlloc(pTestTask->DataSeg.cbSeg);
272 if (!pTestTask->DataSeg.pvSeg)
273 return VERR_NO_MEMORY;
274
275 /* Fill data into buffer. */
276 tstPDMACStressTestFileFillBuffer(pTestFile, pTestTask);
277
278 /* Engage */
279 rc = PDMR3AsyncCompletionEpWrite(pTestFile->hEndpoint, pTestTask->off,
280 &pTestTask->DataSeg, 1,
281 pTestTask->DataSeg.cbSeg,
282 pTestTask,
283 &pTestTask->hTask);
284
285 return rc;
286}
287
288static int tstPDMACStressTestFileRead(PPDMACTESTFILE pTestFile, PPDMACTESTFILETASK pTestTask)
289{
290 int rc = VINF_SUCCESS;
291
292 Assert(!pTestTask->fActive);
293
294 pTestTask->fActive = true;
295 pTestTask->fWrite = false;
296 pTestTask->DataSeg.cbSeg = RTRandU32Ex(1, RT_MIN(pTestFile->cbFileCurr, TASK_TRANSFER_SIZE_MAX));
297
298 AssertMsg(pTestFile->cbFileCurr >= pTestTask->DataSeg.cbSeg, ("Impossible\n"));
299 pTestTask->off = RTRandU64Ex(0, pTestFile->cbFileCurr - pTestTask->DataSeg.cbSeg);
300
301 /* Allocate data buffer. */
302 pTestTask->DataSeg.pvSeg = RTMemAlloc(pTestTask->DataSeg.cbSeg);
303 if (!pTestTask->DataSeg.pvSeg)
304 return VERR_NO_MEMORY;
305
306 /* Engage */
307 rc = PDMR3AsyncCompletionEpRead(pTestFile->hEndpoint, pTestTask->off,
308 &pTestTask->DataSeg, 1,
309 pTestTask->DataSeg.cbSeg,
310 pTestTask,
311 &pTestTask->hTask);
312
313 return rc;
314}
315
316/**
317 * Returns true with the given chance in percent.
318 *
319 * @returns true or false
320 * @param iPercentage The percentage of the chance to return true.
321 */
322static bool tstPDMACTestIsTrue(int iPercentage)
323{
324 int uRnd = RTRandU32Ex(0, 100);
325
326 return (uRnd <= iPercentage); /* This should be enough for our purpose */
327}
328
329static int tstPDMACTestFileThread(PVM pVM, PPDMTHREAD pThread)
330{
331 PPDMACTESTFILE pTestFile = (PPDMACTESTFILE)pThread->pvUser;
332 int iWriteChance = 100; /* Chance to get a write task in percent. */
333 uint32_t cTasksStarted = 0;
334 int rc = VINF_SUCCESS;
335
336 if (pThread->enmState == PDMTHREADSTATE_INITIALIZING)
337 return VINF_SUCCESS;
338
339 while (pTestFile->fRunning)
340 {
341 unsigned iTaskCurr = 0;
342
343
344 /* Fill all tasks */
345 while ( (pTestFile->cTasksActiveCurr < pTestFile->cTasksActiveMax)
346 && (iTaskCurr < pTestFile->cTasksActiveMax))
347 {
348 PPDMACTESTFILETASK pTask = &pTestFile->paTasks[iTaskCurr];
349
350 if (!pTask->fActive)
351 {
352 /* Read or write task? */
353 bool fWrite = tstPDMACTestIsTrue(iWriteChance);
354
355 ASMAtomicIncU32(&pTestFile->cTasksActiveCurr);
356
357 if (fWrite)
358 rc = tstPDMACStressTestFileWrite(pTestFile, pTask);
359 else
360 rc = tstPDMACStressTestFileRead(pTestFile, pTask);
361
362 if (rc != VINF_AIO_TASK_PENDING)
363 tstPDMACStressTestFileTaskCompleted(pVM, pTask, pTestFile, rc);
364
365 cTasksStarted++;
366 }
367
368 iTaskCurr++;
369 }
370
371 /*
372 * Recalc write chance. The bigger the file the lower the chance to have a write.
373 * The minimum chance is 33 percent.
374 */
375 iWriteChance = 100 - (int)(((float)100.0 / pTestFile->cbFileMax) * (float)pTestFile->cbFileCurr);
376 iWriteChance = RT_MAX(33, iWriteChance);
377
378 /* Wait a random amount of time. (1ms - 100ms) */
379 RTThreadSleep(RTRandU32Ex(1, 100));
380 }
381
382 /* Wait for the rest to complete. */
383 while (pTestFile->cTasksActiveCurr)
384 RTThreadSleep(250);
385
386 RTPrintf("Thread exiting: processed %u tasks\n", cTasksStarted);
387 return rc;
388}
389
390static void tstPDMACStressTestFileTaskCompleted(PVM pVM, void *pvUser, void *pvUser2, int rcReq)
391{
392 PPDMACTESTFILE pTestFile = (PPDMACTESTFILE)pvUser2;
393 PPDMACTESTFILETASK pTestTask = (PPDMACTESTFILETASK)pvUser;
394 NOREF(pVM); NOREF(rcReq);
395
396 if (pTestTask->fWrite)
397 {
398 /* @todo Do something sensible here. */
399 }
400 else
401 {
402 tstPDMACStressTestFileVerify(pTestFile, pTestTask); /* Will assert if it fails */
403 }
404
405 RTMemFree(pTestTask->DataSeg.pvSeg);
406 pTestTask->fActive = false;
407 AssertMsg(pTestFile->cTasksActiveCurr > 0, ("Trying to complete a non active task\n"));
408 ASMAtomicDecU32(&pTestFile->cTasksActiveCurr);
409}
410
411/**
412 * Sets up a test file creating the I/O thread.
413 *
414 * @returns VBox status code.
415 * @param pVM Pointer to the shared VM instance structure.
416 * @param pTestFile Pointer to the uninitialized test file structure.
417 * @param iTestId Unique test id.
418 */
419static int tstPDMACStressTestFileOpen(PVM pVM, PPDMACTESTFILE pTestFile, unsigned iTestId)
420{
421 int rc = VERR_NO_MEMORY;
422
423 /* Size is a multiple of 512 */
424 pTestFile->cbFileMax = RTRandU64Ex(FILE_SIZE_MIN, FILE_SIZE_MAX) & ~(511UL);
425 pTestFile->cbFileCurr = 0;
426 pTestFile->cbFileSegment = RTRandU32Ex(SEGMENT_SIZE_MIN, RT_MIN(pTestFile->cbFileMax, SEGMENT_SIZE_MAX)) & ~((size_t)511);
427
428 Assert(pTestFile->cbFileMax >= pTestFile->cbFileSegment);
429
430 /* Set up the segments array. */
431 pTestFile->cSegments = pTestFile->cbFileMax / pTestFile->cbFileSegment;
432 pTestFile->cSegments += ((pTestFile->cbFileMax % pTestFile->cbFileSegment) > 0) ? 1 : 0;
433
434 pTestFile->paSegs = (PPDMACTESTFILESEG)RTMemAllocZ(pTestFile->cSegments * sizeof(PDMACTESTFILESEG));
435 if (pTestFile->paSegs)
436 {
437 /* Init the segments */
438 for (unsigned i = 0; i < pTestFile->cSegments; i++)
439 {
440 PPDMACTESTFILESEG pSeg = &pTestFile->paSegs[i];
441
442 pSeg->off = (RTFOFF)i * pTestFile->cbFileSegment;
443 pSeg->cbSegment = pTestFile->cbFileSegment;
444
445 /* Let the buffer point to a random position in the test pattern. */
446 uint32_t offTestPattern = RTRandU64Ex(0, g_cbTestPattern - pSeg->cbSegment);
447
448 pSeg->pbData = g_pbTestPattern + offTestPattern;
449 }
450
451 /* Init task array. */
452 pTestFile->cTasksActiveMax = RTRandU32Ex(1, TASK_ACTIVE_MAX);
453 pTestFile->paTasks = (PPDMACTESTFILETASK)RTMemAllocZ(pTestFile->cTasksActiveMax * sizeof(PDMACTESTFILETASK));
454 if (pTestFile->paTasks)
455 {
456 /* Create the template */
457 char szDesc[256];
458
459 RTStrPrintf(szDesc, sizeof(szDesc), "Template-%d", iTestId);
460 rc = PDMR3AsyncCompletionTemplateCreateInternal(pVM, &pTestFile->pTemplate, tstPDMACStressTestFileTaskCompleted, pTestFile, szDesc);
461 if (RT_SUCCESS(rc))
462 {
463 /* Open the endpoint now. Because async completion endpoints cannot create files we have to do it before. */
464 char szFile[RTPATH_MAX];
465
466 RTStrPrintf(szFile, sizeof(szFile), "tstPDMAsyncCompletionStress-%d.tmp", iTestId);
467
468 RTFILE FileTmp;
469 rc = RTFileOpen(&FileTmp, szFile, RTFILE_O_READWRITE | RTFILE_O_CREATE | RTFILE_O_DENY_NONE);
470 if (RT_SUCCESS(rc))
471 {
472 RTFileClose(FileTmp);
473
474 rc = PDMR3AsyncCompletionEpCreateForFile(&pTestFile->hEndpoint, szFile, 0, pTestFile->pTemplate);
475 if (RT_SUCCESS(rc))
476 {
477 char szThreadDesc[256];
478
479 pTestFile->fRunning = true;
480
481 /* Create the thread creating the I/O for the given file. */
482 RTStrPrintf(szThreadDesc, sizeof(szThreadDesc), "PDMACThread-%d", iTestId);
483 rc = PDMR3ThreadCreate(pVM, &pTestFile->hThread, pTestFile, tstPDMACTestFileThread,
484 NULL, 0, RTTHREADTYPE_IO, szThreadDesc);
485 if (RT_SUCCESS(rc))
486 {
487 rc = PDMR3ThreadResume(pTestFile->hThread);
488 AssertRC(rc);
489
490 RTPrintf(TESTCASE ": Created test file %s cbFileMax=%llu cbFileSegment=%u cSegments=%u cTasksActiveMax=%u\n",
491 szFile, pTestFile->cbFileMax, pTestFile->cbFileSegment, pTestFile->cSegments, pTestFile->cTasksActiveMax);
492 return VINF_SUCCESS;
493 }
494
495 PDMR3AsyncCompletionEpClose(pTestFile->hEndpoint);
496 }
497
498 RTFileDelete(szFile);
499 }
500
501 PDMR3AsyncCompletionTemplateDestroy(pTestFile->pTemplate);
502 }
503
504 RTMemFree(pTestFile->paTasks);
505 }
506 else
507 rc = VERR_NO_MEMORY;
508
509 RTMemFree(pTestFile->paSegs);
510 }
511 else
512 rc = VERR_NO_MEMORY;
513
514 RTPrintf(TESTCASE ": Opening test file with id %d failed rc=%Rrc\n", iTestId, rc);
515
516 return rc;
517}
518
519/**
520 * Closes a test file.
521 *
522 * @returns nothing.
523 * @param pTestFile Pointer to the test file.
524 */
525static void tstPDMACStressTestFileClose(PPDMACTESTFILE pTestFile)
526{
527 int rcThread;
528 int rc;
529
530 RTPrintf("Terminating I/O thread, please wait...\n");
531
532 /* Let the thread know that it should terminate. */
533 pTestFile->fRunning = false;
534
535 /* Wait for the thread to terminate. */
536 rc = PDMR3ThreadDestroy(pTestFile->hThread, &rcThread);
537
538 RTPrintf("Thread terminated with status code rc=%Rrc\n", rcThread);
539
540 /* Free resources */
541 RTMemFree(pTestFile->paTasks);
542 RTMemFree(pTestFile->paSegs);
543 PDMR3AsyncCompletionEpClose(pTestFile->hEndpoint);
544 PDMR3AsyncCompletionTemplateDestroy(pTestFile->pTemplate);
545}
546
547/**
548 * Inits the test pattern.
549 *
550 * @returns VBox status code.
551 */
552static int tstPDMACStressTestPatternInit(void)
553{
554 RTPrintf(TESTCASE ": Creating test pattern. Please wait...\n");
555 g_cbTestPattern = TEST_PATTERN_SIZE;
556 g_pbTestPattern = (uint8_t *)RTMemAlloc(g_cbTestPattern);
557 if (!g_pbTestPattern)
558 return VERR_NO_MEMORY;
559
560 RTRandBytes(g_pbTestPattern, g_cbTestPattern);
561 return VINF_SUCCESS;
562}
563
564static void tstPDMACStressTestPatternDestroy(void)
565{
566 RTPrintf(TESTCASE ": Destroying test pattern\n");
567 RTMemFree(g_pbTestPattern);
568}
569
570int main(int argc, char *argv[])
571{
572 int rcRet = 0; /* error count */
573
574 RTR3InitExe(argc, &argv, RTR3INIT_FLAGS_SUPLIB);
575
576 PVM pVM;
577 PUVM pUVM;
578 int rc = VMR3Create(1, NULL, NULL, NULL, NULL, NULL, &pVM, &pUVM);
579 if (RT_SUCCESS(rc))
580 {
581 /*
582 * Little hack to avoid the VM_ASSERT_EMT assertion.
583 */
584 RTTlsSet(pVM->pUVM->vm.s.idxTLS, &pVM->pUVM->aCpus[0]);
585 pVM->pUVM->aCpus[0].pUVM = pVM->pUVM;
586 pVM->pUVM->aCpus[0].vm.s.NativeThreadEMT = RTThreadNativeSelf();
587
588 rc = tstPDMACStressTestPatternInit();
589 if (RT_SUCCESS(rc))
590 {
591 unsigned cFilesOpened = 0;
592
593 /* Open the endpoints. */
594 for (cFilesOpened = 0; cFilesOpened < NR_OPEN_ENDPOINTS; cFilesOpened++)
595 {
596 rc = tstPDMACStressTestFileOpen(pVM, &g_aTestFiles[cFilesOpened], cFilesOpened);
597 if (RT_FAILURE(rc))
598 break;
599 }
600
601 if (RT_SUCCESS(rc))
602 {
603 /* Tests are running now. */
604 RTPrintf(TESTCASE ": Successfully opened all files. Running tests forever now or until an error is hit :)\n");
605 RTThreadSleep(RT_INDEFINITE_WAIT);
606 }
607
608 /* Close opened endpoints. */
609 for (unsigned i = 0; i < cFilesOpened; i++)
610 tstPDMACStressTestFileClose(&g_aTestFiles[i]);
611
612 tstPDMACStressTestPatternDestroy();
613 }
614 else
615 {
616 RTPrintf(TESTCASE ": failed to init test pattern!! rc=%Rrc\n", rc);
617 rcRet++;
618 }
619
620 rc = VMR3Destroy(pUVM);
621 AssertMsg(rc == VINF_SUCCESS, ("%s: Destroying VM failed rc=%Rrc!!\n", __FUNCTION__, rc));
622 }
623 else
624 {
625 RTPrintf(TESTCASE ": failed to create VM!! rc=%Rrc\n", rc);
626 rcRet++;
627 }
628
629 return rcRet;
630}
631
Note: See TracBrowser for help on using the repository browser.

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