Changeset 89575 in vbox for trunk/src/VBox/ValidationKit/utils
- Timestamp:
- Jun 9, 2021 9:16:59 AM (4 years ago)
- svn:sync-xref-src-repo-rev:
- 145012
- Location:
- trunk/src/VBox/ValidationKit/utils/audio
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/utils/audio/vkat.cpp
r89544 r89575 139 139 VKAT_TEST_OPT_COUNT = 900, 140 140 VKAT_TEST_OPT_DEV, 141 VKAT_TEST_OPT_ATS_ADDR, 142 VKAT_TEST_OPT_ATS_PORT, 141 VKAT_TEST_OPT_GUEST_ATS_ADDR, 142 VKAT_TEST_OPT_GUEST_ATS_PORT, 143 VKAT_TEST_OPT_HOST_ATS_ADDR, 144 VKAT_TEST_OPT_HOST_ATS_PORT, 143 145 VKAT_TEST_OPT_MODE, 144 146 VKAT_TEST_OPT_OUTDIR, … … 188 190 static const RTGETOPTDEF g_aCmdTestOptions[] = 189 191 { 190 { "--backend", 'b', RTGETOPT_REQ_STRING }, 191 { "--drvaudio", 'd', RTGETOPT_REQ_NOTHING }, 192 { "--exclude", 'e', RTGETOPT_REQ_UINT32 }, 193 { "--exclude-all", 'a', RTGETOPT_REQ_NOTHING }, 194 { "--mode", VKAT_TEST_OPT_MODE, RTGETOPT_REQ_STRING }, 195 { "--ats-address", VKAT_TEST_OPT_ATS_ADDR, RTGETOPT_REQ_STRING }, 196 { "--ats-port", VKAT_TEST_OPT_ATS_PORT, RTGETOPT_REQ_UINT32 }, 197 { "--include", 'i', RTGETOPT_REQ_UINT32 }, 198 { "--outdir", VKAT_TEST_OPT_OUTDIR, RTGETOPT_REQ_STRING }, 199 { "--count", VKAT_TEST_OPT_COUNT, RTGETOPT_REQ_UINT32 }, 200 { "--device", VKAT_TEST_OPT_DEV, RTGETOPT_REQ_STRING }, 201 { "--pause", VKAT_TEST_OPT_PAUSE, RTGETOPT_REQ_UINT32 }, 202 { "--pcm-bit", VKAT_TEST_OPT_PCM_BIT, RTGETOPT_REQ_UINT8 }, 203 { "--pcm-chan", VKAT_TEST_OPT_PCM_CHAN, RTGETOPT_REQ_UINT8 }, 204 { "--pcm-hz", VKAT_TEST_OPT_PCM_HZ, RTGETOPT_REQ_UINT16 }, 205 { "--pcm-signed", VKAT_TEST_OPT_PCM_SIGNED, RTGETOPT_REQ_BOOL }, 206 { "--tag", VKAT_TEST_OPT_TAG, RTGETOPT_REQ_STRING }, 207 { "--tempdir", VKAT_TEST_OPT_TEMPDIR, RTGETOPT_REQ_STRING }, 208 { "--volume", VKAT_TEST_OPT_VOL, RTGETOPT_REQ_UINT8 } 192 { "--backend", 'b', RTGETOPT_REQ_STRING }, 193 { "--drvaudio", 'd', RTGETOPT_REQ_NOTHING }, 194 { "--exclude", 'e', RTGETOPT_REQ_UINT32 }, 195 { "--exclude-all", 'a', RTGETOPT_REQ_NOTHING }, 196 { "--mode", VKAT_TEST_OPT_MODE, RTGETOPT_REQ_STRING }, 197 { "--guest-ats-address", VKAT_TEST_OPT_GUEST_ATS_ADDR, RTGETOPT_REQ_STRING }, 198 { "--guest-ats-port", VKAT_TEST_OPT_GUEST_ATS_PORT, RTGETOPT_REQ_UINT32 }, 199 { "--host-ats-address", VKAT_TEST_OPT_HOST_ATS_ADDR, RTGETOPT_REQ_STRING }, 200 { "--host-ats-port", VKAT_TEST_OPT_HOST_ATS_PORT, RTGETOPT_REQ_UINT32 }, 201 { "--include", 'i', RTGETOPT_REQ_UINT32 }, 202 { "--outdir", VKAT_TEST_OPT_OUTDIR, RTGETOPT_REQ_STRING }, 203 { "--count", VKAT_TEST_OPT_COUNT, RTGETOPT_REQ_UINT32 }, 204 { "--device", VKAT_TEST_OPT_DEV, RTGETOPT_REQ_STRING }, 205 { "--pause", VKAT_TEST_OPT_PAUSE, RTGETOPT_REQ_UINT32 }, 206 { "--pcm-bit", VKAT_TEST_OPT_PCM_BIT, RTGETOPT_REQ_UINT8 }, 207 { "--pcm-chan", VKAT_TEST_OPT_PCM_CHAN, RTGETOPT_REQ_UINT8 }, 208 { "--pcm-hz", VKAT_TEST_OPT_PCM_HZ, RTGETOPT_REQ_UINT16 }, 209 { "--pcm-signed", VKAT_TEST_OPT_PCM_SIGNED, RTGETOPT_REQ_BOOL }, 210 { "--tag", VKAT_TEST_OPT_TAG, RTGETOPT_REQ_STRING }, 211 { "--tempdir", VKAT_TEST_OPT_TEMPDIR, RTGETOPT_REQ_STRING }, 212 { "--volume", VKAT_TEST_OPT_VOL, RTGETOPT_REQ_UINT8 } 209 213 }; 210 214 … … 306 310 AudioTestToneParamsInitRandom(&pTstParms->TestTone, &pTstParms->Props); 307 311 308 PAUDIOTEST ENTRY pTst;309 rc = AudioTestS etTestBegin(&pTstEnv->Set, "Playing test tone", pTstParms, &pTst);312 PAUDIOTESTTONEPARMS const pToneParms = &pTstParms->TestTone; 313 rc = AudioTestSvcClientToneRecord(&pTstEnv->u.Host.AtsClValKit, pToneParms); 310 314 if (RT_SUCCESS(rc)) 311 { 312 PDMAUDIOSTREAMCFG Cfg; 313 RT_ZERO(Cfg); 314 /** @todo Add more parameters here? */ 315 Cfg.Props = pTstParms->Props; 316 317 rc = AudioTestSvcClientTonePlay(&pTstEnv->u.Host.AtsClGuest, &pTstParms->TestTone); 318 if (RT_SUCCESS(rc)) 319 { 320 AudioTestSetTestDone(pTst); 321 } 322 else 323 AudioTestSetTestFailed(pTst, rc, "Playing test tone failed"); 324 } 315 rc = AudioTestSvcClientTonePlay(&pTstEnv->u.Host.AtsClGuest, pToneParms); 325 316 326 317 if (RT_FAILURE(rc)) … … 346 337 static DECLCALLBACK(int) audioTestRecordToneSetup(PAUDIOTESTENV pTstEnv, PAUDIOTESTDESC pTstDesc, PAUDIOTESTPARMS pTstParmsAcq, void **ppvCtx) 347 338 { 348 RT_NOREF(pTst Desc, ppvCtx);339 RT_NOREF(pTstEnv, pTstDesc, ppvCtx); 349 340 350 341 pTstParmsAcq->enmType = AUDIOTESTTYPE_TESTTONE_RECORD; … … 360 351 pTstParmsAcq->idxCurrent = 0; 361 352 362 /* Connect to the Validation Kit audio driver ATS. */ 363 int rc = AudioTestSvcClientConnect(&pTstEnv->u.Host.AtsClValKit, 364 "127.0.0.1" /** @todo Make this dynamic. */, ATS_TCP_DEFAULT_PORT); 365 if (RT_SUCCESS(rc)) 366 { 367 char szTag[AUDIOTEST_TAG_MAX]; 368 rc = RTStrPrintf2(szTag, sizeof(szTag), "%s-valkit", pTstEnv->szTag); 369 if (RT_SUCCESS(rc)) 370 rc = AudioTestSvcClientTestSetBegin(&pTstEnv->u.Host.AtsClValKit, szTag); 371 } 372 373 return rc; 353 return VINF_SUCCESS; 374 354 } 375 355 … … 391 371 pTstParms->TestTone.msDuration = RTRandU32Ex(50 /* ms */, RT_MS_30SEC); /** @todo Record even longer? */ 392 372 #endif 393 PAUDIOTESTENTRY pTst; 394 rc = AudioTestSetTestBegin(&pTstEnv->Set, "Recording test tone", pTstParms, &pTst); 373 /* 374 * 1. Arm the ValKit ATS with the recording parameters. 375 */ 376 rc = AudioTestSvcClientTonePlay(&pTstEnv->u.Host.AtsClValKit, &pTstParms->TestTone); 395 377 if (RT_SUCCESS(rc)) 396 378 { 397 379 /* 398 * 1. Arm the ValKit ATS with the recording parameters.380 * 2. Tell the guest ATS to start recording. 399 381 */ 400 rc = AudioTestSvcClientTonePlay(&pTstEnv->u.Host.AtsClValKit, &pTstParms->TestTone); 401 if (RT_SUCCESS(rc)) 402 { 403 /* 404 * 2. Tell the guest ATS to start recording. 405 */ 406 rc = AudioTestSvcClientToneRecord(&pTstEnv->u.Host.AtsClGuest, &pTstParms->TestTone); 407 if (RT_SUCCESS(rc)) 408 { 409 AudioTestSetTestDone(pTst); 410 } 411 else 412 AudioTestSetTestFailed(pTst, rc, "Recording test tone failed"); 413 } 382 rc = AudioTestSvcClientToneRecord(&pTstEnv->u.Host.AtsClGuest, &pTstParms->TestTone); 414 383 } 415 384 … … 426 395 static DECLCALLBACK(int) audioTestRecordToneDestroy(PAUDIOTESTENV pTstEnv, void *pvCtx) 427 396 { 428 RT_NOREF(pvCtx); 429 430 char szTag[AUDIOTEST_TAG_MAX]; 431 int rc = RTStrPrintf2(szTag, sizeof(szTag), "%s-valkit", pTstEnv->szTag); 432 if (RT_SUCCESS(rc)) 433 rc = AudioTestSvcClientTestSetEnd(&pTstEnv->u.Host.AtsClValKit, szTag); 434 435 int rc2 = AudioTestSvcClientClose(&pTstEnv->u.Host.AtsClValKit); 436 if (RT_SUCCESS(rc)) 437 rc = rc2; 438 439 return rc; 397 RT_NOREF(pTstEnv, pvCtx); 398 399 return VINF_SUCCESS; 440 400 } 441 401 … … 550 510 else if (pTstEnv->enmMode == AUDIOTESTMODE_HOST) 551 511 { 552 /* Generate tag for the host side. */ 553 char szTag[AUDIOTEST_TAG_MAX]; 554 rc = RTStrPrintf2(szTag, sizeof(szTag), "%s-host", pTstEnv->szTag); 512 /* Generate tags for the host and guest side. */ 513 char szTagHost [AUDIOTEST_TAG_MAX]; 514 char szTagGuest[AUDIOTEST_TAG_MAX]; 515 516 rc = RTStrPrintf2(szTagHost, sizeof(szTagHost), "%s-host", pTstEnv->szTag); 555 517 AssertRCReturn(rc, rc); 556 557 /* We have one single test set for all executed tests for now. */ 558 rc = AudioTestSetCreate(&pTstEnv->Set, pTstEnv->szPathTemp, szTag); 518 rc = RTStrPrintf2(szTagGuest, sizeof(szTagGuest), "%s-guest", pTstEnv->szTag); 519 AssertRCReturn(rc, rc); 520 521 RTTestPrintf(g_hTest, RTTESTLVL_DEBUG, "Guest test set tag is '%s'\n", szTagGuest); 522 RTTestPrintf(g_hTest, RTTESTLVL_DEBUG, "Host test set tag is '%s'\n", szTagHost); 523 524 rc = AudioTestSvcClientTestSetBegin(&pTstEnv->u.Host.AtsClValKit, szTagHost); 525 if (RT_SUCCESS(rc)) 526 rc = AudioTestSvcClientTestSetBegin(&pTstEnv->u.Host.AtsClGuest, szTagGuest); 527 559 528 if (RT_SUCCESS(rc)) 560 529 { 561 rc = AudioTestSvcClientTestSetBegin(&pTstEnv->u.Host.AtsClGuest, pTstEnv->szTag);562 if (RT_SUCCESS(rc))530 unsigned uSeq = 0; 531 for (unsigned i = 0; i < RT_ELEMENTS(g_aTests); i++) 563 532 { 564 unsigned uSeq = 0; 565 for (unsigned i = 0; i < RT_ELEMENTS(g_aTests); i++) 566 { 567 int rc2 = audioTestOne(pTstEnv, &g_aTests[i], uSeq, pOverrideParms); 568 if (RT_SUCCESS(rc)) 569 rc = rc2; 570 571 if (!g_aTests[i].fExcluded) 572 uSeq++; 573 574 if (g_fTerminate) 575 break; 576 } 577 578 int rc2 = AudioTestSvcClientTestSetEnd(&pTstEnv->u.Host.AtsClGuest, pTstEnv->szTag); 533 int rc2 = audioTestOne(pTstEnv, &g_aTests[i], uSeq, pOverrideParms); 579 534 if (RT_SUCCESS(rc)) 580 535 rc = rc2; 536 537 if (!g_aTests[i].fExcluded) 538 uSeq++; 539 540 if (g_fTerminate) 541 break; 581 542 } 582 543 583 audioTestEnvPrologue(pTstEnv); 544 int rc2 = AudioTestSvcClientTestSetEnd(&pTstEnv->u.Host.AtsClGuest, szTagGuest); 545 if (RT_SUCCESS(rc)) 546 rc = rc2; 547 rc2 = AudioTestSvcClientTestSetEnd(&pTstEnv->u.Host.AtsClValKit, szTagHost); 548 if (RT_SUCCESS(rc)) 549 rc = rc2; 584 550 } 585 551 } … … 598 564 switch (pOpt->iShort) 599 565 { 600 case 'd': return "Go via DrvAudio instead of directly interfacing with the backend"; 601 case VKAT_TEST_OPT_DEV: return "Use the specified audio device"; 602 case VKAT_TEST_OPT_ATS_ADDR: return "ATS address (hostname or IP) to connect to"; 603 case VKAT_TEST_OPT_ATS_PORT: return "ATS port to connect to. Defaults to 6052 if not set"; 604 case VKAT_TEST_OPT_MODE: return "Specifies the mode this program runs at"; 605 case 'e': return "Exclude the given test id from the list"; 606 case 'a': return "Exclude all tests from the list (useful to enable single tests later with --include)"; 607 case 'i': return "Include the given test id in the list"; 566 case 'd': return "Go via DrvAudio instead of directly interfacing with the backend"; 567 case VKAT_TEST_OPT_DEV: return "Use the specified audio device"; 568 case VKAT_TEST_OPT_GUEST_ATS_ADDR: return "Address of guest ATS to connect to."; 569 case VKAT_TEST_OPT_GUEST_ATS_PORT: return "Port of guest ATS to connect to [6052]."; 570 case VKAT_TEST_OPT_HOST_ATS_ADDR: return "Address of host ATS to connect to."; 571 case VKAT_TEST_OPT_HOST_ATS_PORT: return "Port of host ATS to connect to [6052]."; 572 case VKAT_TEST_OPT_MODE: return "Specifies the mode this program runs at"; 573 case 'e': return "Exclude the given test id from the list"; 574 case 'a': return "Exclude all tests from the list (useful to enable single tests later with --include)"; 575 case 'i': return "Include the given test id in the list"; 608 576 } 609 577 return NULL; … … 632 600 uint32_t uPcmHz = 0; 633 601 bool fPcmSigned = true; 634 const char *pszTcpAddr = NULL; 635 uint16_t uTcpPort = 0; 602 603 const char *pszGuestTcpAddr = NULL; 604 uint16_t uGuestTcpPort = ATS_TCP_GUEST_DEFAULT_PORT; 605 const char *pszValKitTcpAddr = NULL; 606 uint16_t uValKitTcpPort = ATS_TCP_HOST_DEFAULT_PORT; 636 607 637 608 int rc; … … 662 633 break; 663 634 664 case VKAT_TEST_OPT_ATS_ADDR: 665 if (TstEnv.enmMode == AUDIOTESTMODE_UNKNOWN) 666 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Must specify a test mode first!"); 667 pszTcpAddr = ValueUnion.psz; 668 break; 669 670 case VKAT_TEST_OPT_ATS_PORT: 671 if (TstEnv.enmMode == AUDIOTESTMODE_UNKNOWN) 672 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Must specify a test mode first!"); 673 uTcpPort = ValueUnion.u32; 635 case VKAT_TEST_OPT_GUEST_ATS_ADDR: 636 pszGuestTcpAddr = ValueUnion.psz; 637 break; 638 639 case VKAT_TEST_OPT_GUEST_ATS_PORT: 640 uGuestTcpPort = ValueUnion.u32; 641 break; 642 643 case VKAT_TEST_OPT_HOST_ATS_ADDR: 644 pszValKitTcpAddr = ValueUnion.psz; 645 break; 646 647 case VKAT_TEST_OPT_HOST_ATS_PORT: 648 uValKitTcpPort = ValueUnion.u32; 674 649 break; 675 650 … … 754 729 if (TstEnv.enmMode == AUDIOTESTMODE_HOST) 755 730 { 756 /* Use the default port is none is specified. */ 757 if (!uTcpPort) 758 uTcpPort = ATS_TCP_DEFAULT_PORT; 759 760 if (!pszTcpAddr) 761 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "--ats-address missing\n"); 731 if (!pszGuestTcpAddr) 732 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "--guest-ats-address missing\n"); 762 733 } 763 734 764 735 /* For now all tests have the same test environment. */ 765 rc = audioTestEnvInit(&TstEnv, pDrvReg, fWithDrvAudio, pszTcpAddr, uTcpPort); 736 rc = audioTestEnvInit(&TstEnv, pDrvReg, fWithDrvAudio, 737 pszValKitTcpAddr, uValKitTcpPort, 738 pszGuestTcpAddr, uGuestTcpPort); 766 739 if (RT_SUCCESS(rc)) 767 740 { -
trunk/src/VBox/ValidationKit/utils/audio/vkatCmdSelfTest.cpp
r89544 r89575 44 44 45 45 46 /** 47 * Thread callback for mocking the guest (VM) side of things. 48 * 49 * @returns VBox status code. 50 * @param hThread Thread handle. 51 * @param pvUser Pointer to user-supplied data. 52 */ 46 53 static DECLCALLBACK(int) audioTestSelftestGuestAtsThread(RTTHREAD hThread, void *pvUser) 47 54 { … … 73 80 2 /* 16-bit */, true /* fSigned */, 2 /* cChannels */, 44100 /* uHz */); 74 81 75 /* Use ATS_ALT_PORT, as on ATS_DEFAULT_PORT the 76 * Validation Kit audio driver ATS already is running on ATS_DEFAULT_PORT. */ 77 rc = audioTestEnvInit(pTstEnv, pCtx->Guest.pDrvReg, pCtx->fWithDrvAudio, 78 "127.0.0.1", ATS_TCP_ALT_PORT); 82 rc = audioTestEnvInit(pTstEnv, pTstEnv->DrvStack.pDrvReg, pCtx->fWithDrvAudio, 83 pCtx->Host.szValKitAtsAddr, pCtx->Host.uValKitAtsPort, 84 pCtx->Guest.szAtsAddr, pCtx->Guest.uAtsPort); 79 85 if (RT_SUCCESS(rc)) 80 86 { … … 102 108 /* 103 109 * The self-test does the following: 104 * - 1. Creates an ATS instance to emulate the guest mode ("--mode guest") 105 * at port 6042 (ATS_ALT_PORT). 110 * - 1. a) Creates an ATS instance to emulate the guest mode ("--mode guest") 111 * at port 6042 (ATS_TCP_GUEST_DEFAULT_PORT). 112 * or 113 * b) Connect to an already existing guest ATS instance if "--guest-ats-address" is specified. 114 * This makes it more flexible in terms of testing / debugging. 106 115 * - 2. Uses the Validation Kit audio backend, which in turn creates an ATS instance 107 * at port 6052 (ATS_ DEFAULT_PORT).116 * at port 6052 (ATS_TCP_HOST_DEFAULT_PORT). 108 117 * - 3. Executes a complete test run locally (e.g. without any guest (VM) involved). 109 118 */ … … 125 134 AssertRCReturn(rc, RTEXITCODE_FAILURE); 126 135 127 rc = AudioTestPathCreateTemp(pTstEnv->szPathTemp, sizeof(pTstEnv->szPathTemp), "selftest- host");136 rc = AudioTestPathCreateTemp(pTstEnv->szPathTemp, sizeof(pTstEnv->szPathTemp), "selftest-tmp"); 128 137 AssertRCReturn(rc, RTEXITCODE_FAILURE); 129 138 … … 133 142 /* 134 143 * Step 1. 135 * Creates a separate thread for the guest ATS.136 144 */ 137 RTTHREAD hThreadGstAts; 138 rc = RTThreadCreate(&hThreadGstAts, audioTestSelftestGuestAtsThread, pCtx, 0, RTTHREADTYPE_IO, RTTHREADFLAGS_WAITABLE, 139 "VKATGstAts"); 145 RTTHREAD hThreadGstAts = NIL_RTTHREAD; 146 147 bool const fStartGuestAts = RTStrNLen(pCtx->Host.szGuestAtsAddr, sizeof(pCtx->Host.szGuestAtsAddr)) == 0; 148 if (fStartGuestAts) 149 { 150 /* Step 1b. */ 151 rc = RTThreadCreate(&hThreadGstAts, audioTestSelftestGuestAtsThread, pCtx, 0, RTTHREADTYPE_IO, RTTHREADFLAGS_WAITABLE, 152 "VKATGstAts"); 153 if (RT_SUCCESS(rc)) 154 rc = RTThreadUserWait(hThreadGstAts, RT_MS_30SEC); 155 } 156 /* else Step 1a later. */ 157 140 158 if (RT_SUCCESS(rc)) 141 159 { 142 rc = RTThreadUserWait(hThreadGstAts, RT_MS_30SEC); 160 /* 161 * Steps 2 + 3. 162 */ 163 pTstEnv->enmMode = AUDIOTESTMODE_HOST; 164 165 rc = audioTestEnvInit(pTstEnv, &g_DrvHostValidationKitAudio, true /* fWithDrvAudio */, 166 pCtx->Host.szValKitAtsAddr, pCtx->Host.uValKitAtsPort, 167 pCtx->Host.szGuestAtsAddr, pCtx->Host.uGuestAtsPort); 143 168 if (RT_SUCCESS(rc)) 144 169 { 145 /* 146 * Steps 2 + 3. 147 */ 148 pTstEnv->enmMode = AUDIOTESTMODE_HOST; 149 150 if (!pCtx->Host.uGuestAtsPort) 151 pCtx->Host.uGuestAtsPort = ATS_TCP_ALT_PORT; 152 153 rc = audioTestEnvInit(pTstEnv, &g_DrvHostValidationKitAudio, true /* fWithDrvAudio */, 154 pCtx->Host.szGuestAtsAddr, pCtx->Host.uGuestAtsPort); 155 if (RT_SUCCESS(rc)) 156 { 157 audioTestWorker(pTstEnv, &TstCust); 158 audioTestEnvDestroy(pTstEnv); 159 } 170 audioTestWorker(pTstEnv, &TstCust); 171 audioTestEnvDestroy(pTstEnv); 160 172 } 161 173 } … … 170 182 ASMAtomicWriteBool(&g_fTerminate, true); 171 183 172 int rcThread; 173 int rc2 = RTThreadWait(hThreadGstAts, RT_MS_30SEC, &rcThread); 174 if (RT_SUCCESS(rc2)) 175 rc2 = rcThread; 176 if (RT_FAILURE(rc2)) 177 RTTestFailed(g_hTest, "Shutting down self test failed with %Rrc\n", rc2); 178 179 if (RT_SUCCESS(rc)) 180 rc = rc2; 184 if (fStartGuestAts) 185 { 186 int rcThread; 187 int rc2 = RTThreadWait(hThreadGstAts, RT_MS_30SEC, &rcThread); 188 if (RT_SUCCESS(rc2)) 189 rc2 = rcThread; 190 if (RT_FAILURE(rc2)) 191 RTTestFailed(g_hTest, "Shutting down guest ATS failed with %Rrc\n", rc2); 192 if (RT_SUCCESS(rc)) 193 rc = rc2; 194 } 181 195 182 196 if (RT_FAILURE(rc)) -
trunk/src/VBox/ValidationKit/utils/audio/vkatCommon.cpp
r89544 r89575 31 31 32 32 #include <iprt/ctype.h> 33 #include <iprt/dir.h> 33 34 #include <iprt/errcore.h> 34 35 #include <iprt/getopt.h> … … 401 402 PAUDIOTESTENV pTstEnv = pCtx->pTstEnv; 402 403 403 char szTag[AUDIOTEST_TAG_MAX]; 404 int rc = RTStrPrintf2(szTag, sizeof(szTag), "%s-guest", pszTag); 405 AssertRCReturn(rc, rc); 406 407 RTTestPrintf(g_hTest, RTTESTLVL_DEBUG, "Beginning test set '%s'\n", szTag); 408 409 return AudioTestSetCreate(&pTstEnv->Set, pTstEnv->szPathTemp, szTag); 404 RTTestPrintf(g_hTest, RTTESTLVL_DEBUG, "Beginning test set '%s'\n", pszTag); 405 406 return AudioTestSetCreate(&pTstEnv->Set, pTstEnv->szPathTemp, pszTag); 410 407 } 411 408 … … 413 410 static DECLCALLBACK(int) audioTestSvcTestSetEndCallback(void const *pvUser, const char *pszTag) 414 411 { 415 RT_NOREF(pszTag);416 417 412 PATSCALLBACKCTX pCtx = (PATSCALLBACKCTX)pvUser; 418 413 PAUDIOTESTENV pTstEnv = pCtx->pTstEnv; … … 518 513 * @param pDrvReg Audio driver to use. 519 514 * @param fWithDrvAudio Whether to include DrvAudio in the stack or not. 520 * @param pszTcpAddr TCP/IP address to connect to. 515 * @param pszHostTcpAddr Host ATS TCP/IP address to connect to. 516 * If NULL, ATS_TCP_HOST_DEFAULT_ADDR_STR will be used. 517 * @param uHostTcpPort Host ATS TCP/IP port to connect to. 518 * If 0, ATS_TCP_HOST_DEFAULT_PORT will be used. 519 * @param pszGuestTcpAddr Guest ATS TCP/IP address to connect to. 521 520 * If NULL, localhost (127.0.0.1) will be used. 522 * @param u TcpPortTCP/IP port to connect to.523 * If 0, ATS_ DEFAULT_PORT will be used.521 * @param uGuestTcpPort Guest ATS TCP/IP port to connect to. 522 * If 0, ATS_TCP_GUEST_DEFAULT_PORT will be used. 524 523 */ 525 524 int audioTestEnvInit(PAUDIOTESTENV pTstEnv, 526 525 PCPDMDRVREG pDrvReg, bool fWithDrvAudio, 527 const char *pszTcpAddr, uint32_t uTcpPort) 528 { 526 const char *pszHostTcpAddr, uint32_t uHostTcpPort, 527 const char *pszGuestTcpAddr, uint32_t uGuestTcpPort) 528 { 529 int rc = VINF_SUCCESS; 530 531 /* 532 * Set sane defaults if not already set. 533 */ 534 if (!RTStrNLen(pTstEnv->szTag, sizeof(pTstEnv->szTag))) 535 { 536 rc = AudioTestGenTag(pTstEnv->szTag, sizeof(pTstEnv->szTag)); 537 AssertRCReturn(rc, rc); 538 } 539 540 if (!RTStrNLen(pTstEnv->szPathTemp, sizeof(pTstEnv->szPathTemp))) 541 { 542 rc = AudioTestPathGetTemp(pTstEnv->szPathTemp, sizeof(pTstEnv->szPathTemp)); 543 AssertRCReturn(rc, rc); 544 } 545 546 if (!RTStrNLen(pTstEnv->szPathOut, sizeof(pTstEnv->szPathOut))) 547 { 548 rc = RTPathJoin(pTstEnv->szPathOut, sizeof(pTstEnv->szPathOut), pTstEnv->szPathTemp, "vkat-temp"); 549 AssertRCReturn(rc, rc); 550 } 551 552 if (pDrvReg == NULL) /* Go with the platform's default backend if nothing else is set. */ 553 pDrvReg = g_aBackends[0].pDrvReg; 554 555 if (!uHostTcpPort) 556 uHostTcpPort = ATS_TCP_HOST_DEFAULT_PORT; 557 558 if (!uGuestTcpPort) 559 uGuestTcpPort = ATS_TCP_GUEST_DEFAULT_PORT; 560 529 561 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Test mode is '%s'\n", pTstEnv->enmMode == AUDIOTESTMODE_HOST ? "host" : "guest"); 530 562 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Using tag '%s'\n", pTstEnv->szTag); … … 532 564 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Temp directory is '%s'\n", pTstEnv->szPathTemp); 533 565 534 int rc = VINF_SUCCESS;535 536 566 PDMAudioHostEnumInit(&pTstEnv->DevEnum); 537 567 … … 544 574 /* The self test mode drives the ValKit audio driver locally, 545 575 * so also use the driver stack here. */ 546 || pTstEnv->fSelftest; 576 || ( pTstEnv->enmMode == AUDIOTESTMODE_HOST 577 && pTstEnv->fSelftest); 547 578 if (fUseDriverStack) 548 579 { 549 rc = audioTestDriverStackInit(&pTstEnv->DrvStack, pDrvReg, fWithDrvAudio); 580 rc = audioTestDriverStackInitEx(&pTstEnv->DrvStack, pDrvReg, 581 true /* fEnabledIn */, true /* fEnabledOut */, fWithDrvAudio); 550 582 if (RT_FAILURE(rc)) 551 583 return rc; … … 586 618 Callbacks.pvUser = &Ctx; 587 619 588 RTTestPrintf(g_hTest, RTTESTLVL_DEBUG, "Starting guest ATS at %s:%RU32...\n", pszTcpAddr, uTcpPort); 589 rc = AudioTestSvcInit(&pTstEnv->u.Guest.Srv, pszTcpAddr, uTcpPort, &Callbacks); 620 /* 621 * Start the ATS (Audio Test Service) on the guest side. 622 * That service then will perform playback and recording operations on the guest, triggered from the host. 623 * 624 * When running this in self-test mode, that service also will be run on the host. 625 */ 626 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Starting guest ATS at %s:%RU32...\n", 627 (pszGuestTcpAddr && *pszGuestTcpAddr) ? pszGuestTcpAddr : "127.0.0.1", 628 uGuestTcpPort ? uGuestTcpPort : ATS_TCP_GUEST_DEFAULT_PORT); 629 rc = AudioTestSvcInit(&pTstEnv->u.Guest.Srv, pszGuestTcpAddr, uGuestTcpPort, &Callbacks); 590 630 if (RT_SUCCESS(rc)) 591 631 rc = AudioTestSvcStart(&pTstEnv->u.Guest.Srv); … … 599 639 else /* Host mode */ 600 640 { 601 RTTestPrintf(g_hTest, RTTESTLVL_DEBUG, "Connecting to guest ATS at %s:%RU32 ...\n", 602 (pszTcpAddr && *pszTcpAddr) ? pszTcpAddr : "127.0.0.1", uTcpPort ? uTcpPort : ATS_TCP_DEFAULT_PORT); 603 604 rc = AudioTestSvcClientConnect(&pTstEnv->u.Host.AtsClGuest, pszTcpAddr, uTcpPort); 641 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Connecting to host ATS at %s:%RU32 ...\n", 642 (pszHostTcpAddr && *pszHostTcpAddr) ? pszHostTcpAddr : ATS_TCP_HOST_DEFAULT_ADDR_STR, 643 uHostTcpPort ? uHostTcpPort : ATS_TCP_HOST_DEFAULT_PORT); 644 645 rc = AudioTestSvcClientConnect(&pTstEnv->u.Host.AtsClValKit, pszHostTcpAddr, uHostTcpPort); 605 646 if (RT_FAILURE(rc)) 606 647 { 607 RTTestFailed(g_hTest, "Connecting to ATS failed with %Rrc\n", rc);648 RTTestFailed(g_hTest, "Connecting to host ATS failed with %Rrc\n", rc); 608 649 return rc; 609 650 } 610 651 611 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Connected to ATS\n"); 652 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Connected to host ATS\n"); 653 654 RTTestPrintf(g_hTest, RTTESTLVL_DEBUG, "Connecting to guest ATS at %s:%RU32 ...\n", 655 (pszGuestTcpAddr && *pszGuestTcpAddr) ? pszGuestTcpAddr : "127.0.0.1", 656 uGuestTcpPort ? uGuestTcpPort : ATS_TCP_GUEST_DEFAULT_PORT); 657 658 rc = AudioTestSvcClientConnect(&pTstEnv->u.Host.AtsClGuest, pszGuestTcpAddr, uGuestTcpPort); 659 if (RT_FAILURE(rc)) 660 { 661 RTTestFailed(g_hTest, "Connecting to guest ATS failed with %Rrc\n", rc); 662 return rc; 663 } 664 665 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Connected to guest ATS\n"); 612 666 } 613 667 … … 637 691 RTTestFailed(g_hTest, "Stream destruction for stream #%u failed with %Rrc\n", i, rc2); 638 692 } 693 694 /* Try cleaning up a bit. */ 695 RTDirRemove(pTstEnv->szPathTemp); 696 RTDirRemove(pTstEnv->szPathOut); 639 697 640 698 audioTestDriverStackDelete(&pTstEnv->DrvStack); … … 659 717 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Test set packed up to '%s'\n", szFileOut); 660 718 661 int rc2 = AudioTestSetWipe(&pTstEnv->Set); 662 if (RT_SUCCESS(rc)) 663 rc = rc2; 719 /* ignore rc */ AudioTestSetWipe(&pTstEnv->Set); 664 720 665 721 AudioTestSetDestroy(&pTstEnv->Set); -
trunk/src/VBox/ValidationKit/utils/audio/vkatDriverStack.cpp
r89535 r89575 490 490 491 491 /** 492 * Initializes a driver stack .492 * Initializes a driver stack, extended version. 493 493 * 494 494 * @returns VBox status code. 495 495 * @param pDrvStack The driver stack to initialize. 496 496 * @param pDrvReg The backend driver to use. 497 * @param fEnabledIn Whether input is enabled or not on creation time. 498 * @param fEnabledOut Whether output is enabled or not on creation time. 497 499 * @param fWithDrvAudio Whether to include DrvAudio in the stack or not. 498 500 */ 499 int audioTestDriverStackInit (PAUDIOTESTDRVSTACK pDrvStack, PCPDMDRVREG pDrvReg, bool fWithDrvAudio)501 int audioTestDriverStackInitEx(PAUDIOTESTDRVSTACK pDrvStack, PCPDMDRVREG pDrvReg, bool fEnabledIn, bool fEnabledOut, bool fWithDrvAudio) 500 502 { 501 503 int rc; … … 516 518 if (pDrvStack->pIAudioConnector) 517 519 { 518 /* Both input and output is disabled by default. Fix that: */ 519 rc = pDrvStack->pIAudioConnector->pfnEnable(pDrvStack->pIAudioConnector, PDMAUDIODIR_OUT, true); 520 /* Both input and output is disabled by default. */ 521 if (fEnabledIn) 522 rc = pDrvStack->pIAudioConnector->pfnEnable(pDrvStack->pIAudioConnector, PDMAUDIODIR_IN, true); 523 520 524 if (RT_SUCCESS(rc)) 521 rc = pDrvStack->pIAudioConnector->pfnEnable(pDrvStack->pIAudioConnector, PDMAUDIODIR_IN, true); 525 { 526 if (fEnabledOut) 527 rc = pDrvStack->pIAudioConnector->pfnEnable(pDrvStack->pIAudioConnector, PDMAUDIODIR_OUT, true); 528 } 529 522 530 if (RT_FAILURE(rc)) 523 531 { … … 556 564 557 565 return rc; 566 } 567 568 569 /** 570 * Initializes a driver stack. 571 * 572 * @returns VBox status code. 573 * @param pDrvStack The driver stack to initialize. 574 * @param pDrvReg The backend driver to use. 575 * @param fEnabledIn Whether input is enabled or not on creation time. 576 * @param fEnabledOut Whether output is enabled or not on creation time. 577 * @param fWithDrvAudio Whether to include DrvAudio in the stack or not. 578 */ 579 int audioTestDriverStackInit(PAUDIOTESTDRVSTACK pDrvStack, PCPDMDRVREG pDrvReg, bool fWithDrvAudio) 580 { 581 return audioTestDriverStackInitEx(pDrvStack, pDrvReg, true /* fEnabledIn */, true /* fEnabledOut */, fWithDrvAudio); 558 582 } 559 583 -
trunk/src/VBox/ValidationKit/utils/audio/vkatInternal.h
r89544 r89575 281 281 /** Client connected to the ATS on the guest side. */ 282 282 ATSCLIENT AtsClGuest; 283 /** Client connected to the ATS on the Validation Kit. */283 /** Client connected to the Validation Kit audio driver ATS. */ 284 284 ATSCLIENT AtsClValKit; 285 285 } Host; … … 319 319 * Defaults to the platform's default driver. */ 320 320 PCPDMDRVREG pDrvReg; 321 /** Where to bind the address of the guest ATS instance to. 322 * Defaults to localhost (127.0.0.1) if empty. */ 323 char szAtsAddr[64]; 324 /** Port of the guest ATS instance. 325 * Defaults to ATS_ALT_PORT if not set. */ 326 uint32_t uAtsPort; 321 327 } Guest; 322 328 struct … … 347 353 * @{ */ 348 354 void audioTestDriverStackDelete(PAUDIOTESTDRVSTACK pDrvStack); 355 int audioTestDriverStackInitEx(PAUDIOTESTDRVSTACK pDrvStack, PCPDMDRVREG pDrvReg, bool fEnabledIn, bool fEnabledOut, bool fWithDrvAudio); 349 356 int audioTestDriverStackInit(PAUDIOTESTDRVSTACK pDrvStack, PCPDMDRVREG pDrvReg, bool fWithDrvAudio); 350 357 int audioTestDriverStackSetDevice(PAUDIOTESTDRVSTACK pDrvStack, PDMAUDIODIR enmDir, const char *pszDevId); … … 405 412 /** @name Test environment handling 406 413 * @{ */ 407 int audioTestEnvInit(PAUDIOTESTENV pTstEnv, PCPDMDRVREG pDrvReg, bool fWithDrvAudio, const char *psz TcpAddr, uint32_t uTcpPort);414 int audioTestEnvInit(PAUDIOTESTENV pTstEnv, PCPDMDRVREG pDrvReg, bool fWithDrvAudio, const char *pszHostTcpAddr, uint32_t uHostTcpPort, const char *pszGuestTcpAddr, uint32_t uGuestTcpPort); 408 415 void audioTestEnvDestroy(PAUDIOTESTENV pTstEnv); 409 416 int audioTestEnvPrologue(PAUDIOTESTENV pTstEnv);
Note:
See TracChangeset
for help on using the changeset viewer.