Changeset 89135 in vbox for trunk/src/VBox
- Timestamp:
- May 18, 2021 10:38:17 AM (4 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/AudioTest.cpp
r89125 r89135 315 315 } 316 316 317 DECLINLINE(int) audioTestManifestWriteData(PAUDIOTESTSET pSet, const void *pvData, size_t cbData) 318 { 319 /** @todo Use RTIniFileWrite once its implemented. */ 320 return RTFileWrite(pSet->f.hFile, pvData, cbData, NULL); 321 } 322 317 323 /** 318 324 * Writes string data to a test set manifest. … … 326 332 { 327 333 char *psz = NULL; 328 RTStrAPrintfV(&psz, pszFormat, args);329 AssertPtr(psz);330 331 /** @todo Use RTIniFileWrite once its implemented. */ 332 int rc = RTFileWrite(pSet->f.hFile, psz, strlen(psz), NULL);334 if (RTStrAPrintfV(&psz, pszFormat, args) == -1) 335 return VERR_NO_MEMORY; 336 AssertPtrReturn(psz, VERR_NO_MEMORY); 337 338 int rc = audioTestManifestWriteData(pSet, psz, strlen(psz)); 333 339 AssertRC(rc); 334 340 … … 339 345 340 346 /** 341 * Writes a terminated string lineto a test set manifest.347 * Writes a string to a test set manifest. 342 348 * Convenience function. 343 349 * … … 347 353 * @param ... Variable arguments for \a pszFormat. Optional. 348 354 */ 349 static int audioTestManifestWrite Ln(PAUDIOTESTSET pSet, const char *pszFormat, ...)355 static int audioTestManifestWrite(PAUDIOTESTSET pSet, const char *pszFormat, ...) 350 356 { 351 357 va_list va; … … 357 363 va_end(va); 358 364 359 /** @todo Keep it as simple as possible for now. Improve this later. */ 360 rc = RTFileWrite(pSet->f.hFile, "\n", strlen("\n"), NULL); 361 AssertRC(rc); 362 363 return rc; 364 } 365 366 /** 367 * Writes a section entry to a test set manifest. 365 return rc; 366 } 367 368 /** 369 * Returns the current read/write offset (in bytes) of the opened manifest file. 370 * 371 * @returns Current read/write offset (in bytes). 372 * @param pSet Set to return offset for. 373 * Must have an opened manifest file. 374 */ 375 DECLINLINE(uint64_t) audioTestManifestGetOffsetAbs(PAUDIOTESTSET pSet) 376 { 377 AssertReturn(RTFileIsValid(pSet->f.hFile), 0); 378 return RTFileTell(pSet->f.hFile); 379 } 380 381 /** 382 * Writes a section header to a test set manifest. 368 383 * 369 384 * @returns VBox status code. … … 372 387 * @param ... Variable arguments for \a pszSection. Optional. 373 388 */ 374 static int audioTestManifestWriteSection (PAUDIOTESTSET pSet, const char *pszSection, ...)389 static int audioTestManifestWriteSectionHdr(PAUDIOTESTSET pSet, const char *pszSection, ...) 375 390 { 376 391 va_list va; … … 378 393 379 394 /** @todo Keep it as simple as possible for now. Improve this later. */ 380 int rc = RTFileWrite(pSet->f.hFile, "[", strlen("["), NULL);395 int rc = audioTestManifestWrite(pSet, "["); 381 396 AssertRC(rc); 382 397 … … 384 399 AssertRC(rc); 385 400 386 rc = RTFileWrite(pSet->f.hFile, "]\n", strlen("]\n"), NULL);401 rc = audioTestManifestWrite(pSet, "]\n"); 387 402 AssertRC(rc); 388 403 … … 394 409 /** 395 410 * Initializes an audio test set, internal function. 411 * 396 412 * @param pSet Test set to initialize. 397 413 */ … … 401 417 402 418 RTListInit(&pSet->lstObj); 419 pSet->cObj = 0; 420 421 RTListInit(&pSet->lstTest); 422 pSet->cTests = 0; 423 pSet->cTestsRunning = 0; 424 pSet->offTestCount = 0; 425 426 pSet->cTotalFailures = 0; 403 427 } 404 428 … … 612 636 AssertRCReturn(rc, rc); 613 637 614 rc = audioTestManifestWriteSection (pSet, "header");615 AssertRCReturn(rc, rc); 616 617 rc = audioTestManifestWrite Ln(pSet, "magic=vkat_ini"); /* VKAT Manifest, .INI-style. */618 AssertRCReturn(rc, rc); 619 rc = audioTestManifestWrite Ln(pSet, "ver=%d", AUDIOTEST_MANIFEST_VER);620 AssertRCReturn(rc, rc); 621 rc = audioTestManifestWrite Ln(pSet, "tag=%s", pSet->szTag);638 rc = audioTestManifestWriteSectionHdr(pSet, "header"); 639 AssertRCReturn(rc, rc); 640 641 rc = audioTestManifestWrite(pSet, "magic=vkat_ini\n"); /* VKAT Manifest, .INI-style. */ 642 AssertRCReturn(rc, rc); 643 rc = audioTestManifestWrite(pSet, "ver=%d\n", AUDIOTEST_MANIFEST_VER); 644 AssertRCReturn(rc, rc); 645 rc = audioTestManifestWrite(pSet, "tag=%s\n", pSet->szTag); 622 646 AssertRCReturn(rc, rc); 623 647 … … 627 651 AssertFailedReturn(VERR_BUFFER_OVERFLOW); 628 652 629 rc = audioTestManifestWrite Ln(pSet, "date_created=%s", szVal);653 rc = audioTestManifestWrite(pSet, "date_created=%s\n", szVal); 630 654 AssertRCReturn(rc, rc); 631 655 632 656 rc = RTSystemQueryOSInfo(RTSYSOSINFO_PRODUCT, szVal, sizeof(szVal)); 633 657 AssertRCReturn(rc, rc); 634 rc = audioTestManifestWrite Ln(pSet, "os_product=%s", szVal);658 rc = audioTestManifestWrite(pSet, "os_product=%s\n", szVal); 635 659 AssertRCReturn(rc, rc); 636 660 rc = RTSystemQueryOSInfo(RTSYSOSINFO_RELEASE, szVal, sizeof(szVal)); 637 661 AssertRCReturn(rc, rc); 638 rc = audioTestManifestWrite Ln(pSet, "os_rel=%s", szVal);662 rc = audioTestManifestWrite(pSet, "os_rel=%s\n", szVal); 639 663 AssertRCReturn(rc, rc); 640 664 rc = RTSystemQueryOSInfo(RTSYSOSINFO_VERSION, szVal, sizeof(szVal)); 641 665 AssertRCReturn(rc, rc); 642 rc = audioTestManifestWriteLn(pSet, "os_ver=%s", szVal); 643 AssertRCReturn(rc, rc); 644 645 rc = audioTestManifestWriteLn(pSet, "vbox_ver=%s r%u %s (%s %s)", 666 rc = audioTestManifestWrite(pSet, "os_ver=%s\n", szVal); 667 AssertRCReturn(rc, rc); 668 rc = audioTestManifestWrite(pSet, "vbox_ver=%s r%u %s (%s %s)\n", 646 669 VBOX_VERSION_STRING, RTBldCfgRevision(), 647 670 RTBldCfgTargetDotArch(), __DATE__, __TIME__); 648 671 AssertRCReturn(rc, rc); 649 672 673 rc = audioTestManifestWrite(pSet, "test_count="); 674 AssertRCReturn(rc, rc); 675 pSet->offTestCount = audioTestManifestGetOffsetAbs(pSet); 676 rc = audioTestManifestWrite(pSet, "0000\n"); /* A bit messy, but does the trick for now. */ 677 AssertRCReturn(rc, rc); 678 650 679 pSet->enmMode = AUDIOTESTSETMODE_TEST; 651 680 } … … 665 694 return VINF_SUCCESS; 666 695 667 int rc = VINF_SUCCESS; 696 AssertReturn(pSet->cTestsRunning == 0, VERR_WRONG_ORDER); /* Make sure no tests sill are running. */ 697 698 int rc = AudioTestSetClose(pSet); 699 if (RT_FAILURE(rc)) 700 return rc; 668 701 669 702 PAUDIOTESTOBJ pObj, pObjNext; … … 688 721 Assert(pSet->cObj == 0); 689 722 690 if (RTFileIsValid(pSet->f.hFile)) 691 { 692 RTFileClose(pSet->f.hFile); 693 pSet->f.hFile = NIL_RTFILE; 694 } 723 PAUDIOTESTENTRY pEntry, pEntryNext; 724 RTListForEachSafe(&pSet->lstTest, pEntry, pEntryNext, AUDIOTESTENTRY, Node) 725 { 726 RTListNodeRemove(&pEntry->Node); 727 RTMemFree(pEntry); 728 729 Assert(pSet->cTests); 730 pSet->cTests--; 731 } 732 733 if (RT_FAILURE(rc)) 734 return rc; 735 736 Assert(pSet->cTests == 0); 695 737 696 738 return rc; … … 729 771 * Closes an opened audio test set. 730 772 * 773 * @returns VBox status code. 731 774 * @param pSet Test set to close. 732 775 */ 733 void AudioTestSetClose(PAUDIOTESTSET pSet) 734 { 735 AudioTestSetDestroy(pSet); 776 int AudioTestSetClose(PAUDIOTESTSET pSet) 777 { 778 if (!pSet) 779 return VINF_SUCCESS; 780 781 /* Update number of ran tests. */ 782 int rc = RTFileSeek(pSet->f.hFile, pSet->offTestCount, RTFILE_SEEK_BEGIN, NULL); 783 AssertRCReturn(rc, rc); 784 rc = audioTestManifestWrite(pSet, "%04RU32", pSet->cTests); 785 AssertRCReturn(rc, rc); 786 787 if (RTFileIsValid(pSet->f.hFile)) 788 { 789 RTFileClose(pSet->f.hFile); 790 pSet->f.hFile = NIL_RTFILE; 791 } 792 793 return rc; 736 794 } 737 795 … … 860 918 861 919 return rc; 920 } 921 922 int AudioTestSetTestBegin(PAUDIOTESTSET pSet, const char *pszDesc, PAUDIOTESTPARMS pParms, PAUDIOTESTENTRY *ppEntry) 923 { 924 AssertReturn(pSet->cTestsRunning == 0, VERR_WRONG_ORDER); /* No test nesting allowed. */ 925 926 PAUDIOTESTENTRY pEntry = (PAUDIOTESTENTRY)RTMemAllocZ(sizeof(AUDIOTESTENTRY)); 927 AssertPtrReturn(pEntry, VERR_NO_MEMORY); 928 929 int rc = RTStrCopy(pEntry->szDesc, sizeof(pEntry->szDesc), pszDesc); 930 AssertRCReturn(rc, rc); 931 932 memcpy(&pEntry->Parms, pParms, sizeof(AUDIOTESTPARMS)); 933 pEntry->pParent = pSet; 934 935 rc = audioTestManifestWrite(pSet, "\n"); 936 AssertRCReturn(rc, rc); 937 938 rc = audioTestManifestWriteSectionHdr(pSet, "test%04RU32", pSet->cTests); 939 AssertRCReturn(rc, rc); 940 941 rc = audioTestManifestWrite(pSet, "desc=%s\n", pszDesc); 942 AssertRCReturn(rc, rc); 943 944 RTListAppend(&pSet->lstTest, &pEntry->Node); 945 pSet->cTests++; 946 pSet->cTestsRunning++; 947 948 *ppEntry = pEntry; 949 950 return rc; 951 } 952 953 int AudioTestSetTestFailed(PAUDIOTESTENTRY pEntry, int rc, const char *pszErr) 954 { 955 AssertReturn(pEntry->pParent->cTestsRunning == 1, VERR_WRONG_ORDER); /* No test nesting allowed. */ 956 AssertReturn(pEntry->rc == VINF_SUCCESS, VERR_WRONG_ORDER); 957 958 pEntry->rc = rc; 959 960 int rc2 = audioTestManifestWrite(pEntry->pParent, "error_rc=%RI32\n", rc); 961 AssertRCReturn(rc2, rc2); 962 rc2 = audioTestManifestWrite(pEntry->pParent, "error_desc=%s", pszErr); 963 AssertRCReturn(rc2, rc2); 964 965 pEntry->pParent->cTestsRunning--; 966 967 return rc2; 968 } 969 970 int AudioTestSetTestDone(PAUDIOTESTENTRY pEntry) 971 { 972 AssertReturn(pEntry->pParent->cTestsRunning == 1, VERR_WRONG_ORDER); /* No test nesting allowed. */ 973 AssertReturn(pEntry->rc == VINF_SUCCESS, VERR_WRONG_ORDER); 974 975 int rc2 = audioTestManifestWrite(pEntry->pParent, "error_rc=%RI32\n", VINF_SUCCESS); 976 AssertRCReturn(rc2, rc2); 977 978 pEntry->pParent->cTestsRunning--; 979 980 return rc2; 862 981 } 863 982 -
trunk/src/VBox/Devices/Audio/AudioTest.h
r89115 r89135 158 158 typedef AUDIOTESTPARMS *PAUDIOTESTPARMS; 159 159 160 /** 161 * Enumeration for an audio test object type. 162 */ 160 163 typedef enum AUDIOTESTOBJTYPE 161 164 { 165 /** Unknown / invalid, do not use. */ 162 166 AUDIOTESTOBJTYPE_UNKNOWN = 0, 167 /** The test object is a file. */ 163 168 AUDIOTESTOBJTYPE_FILE, 164 169 /** The usual 32-bit hack. */ … … 166 171 } AUDIOTESTOBJTYPE; 167 172 173 /** 174 * Structure for keeping an audio test object file. 175 */ 168 176 typedef struct AUDIOTESTOBJFILE 169 177 { 170 178 RTFILE hFile; 171 179 } AUDIOTESTOBJFILE; 172 180 /** Pointer to an audio test object file. */ 181 typedef AUDIOTESTOBJFILE *PAUDIOTESTOBJFILE; 182 183 /** 184 * Structure for keeping a single audio test object. 185 * 186 * A test object is data which is needed in order to perform and verify one or 187 * more audio test case(s). 188 */ 173 189 typedef struct AUDIOTESTOBJ 174 190 { 191 /** List node. */ 175 192 RTLISTNODE Node; 193 /** Name of the test object. 194 * Must not contain a path and has to be able to serialize to disk. */ 176 195 char szName[64]; 196 /** The object type. */ 177 197 AUDIOTESTOBJTYPE enmType; 198 /** Union for holding the object type-specific data. */ 178 199 union 179 200 { … … 183 204 /** Pointer to an audio test object. */ 184 205 typedef AUDIOTESTOBJ *PAUDIOTESTOBJ; 206 207 struct AUDIOTESTSET; 208 209 typedef struct AUDIOTESTENTRY 210 { 211 /** List node. */ 212 RTLISTNODE Node; 213 AUDIOTESTSET *pParent; 214 char szDesc[64]; 215 AUDIOTESTPARMS Parms; 216 int rc; 217 } AUDIOTESTENTRY; 218 /** Pointer to an audio test entry. */ 219 typedef AUDIOTESTENTRY *PAUDIOTESTENTRY; 185 220 186 221 /** … … 200 235 RTINIFILE hIniFile; 201 236 } f; 237 /** Number of test objects in lstObj. */ 202 238 uint32_t cObj; 239 /** List containing PAUDIOTESTOBJ test object entries. */ 203 240 RTLISTANCHOR lstObj; 241 /** Number of performed tests. 242 * Not necessarily bound to the test object entries above. */ 243 uint32_t cTests; 244 /** Absolute offset (in bytes) where to write the "test_count" value later. */ 245 uint64_t offTestCount; 246 /** List containing PAUDIOTESTENTRY test entries. */ 247 RTLISTANCHOR lstTest; 248 /** Number of tests currently running. */ 249 uint32_t cTestsRunning; 250 /** Number of total (test) failures. */ 251 uint32_t cTotalFailures; 204 252 } AUDIOTESTSET; 205 253 /** Pointer to an audio test set. */ … … 267 315 int AudioTestSetObjClose(PAUDIOTESTOBJ pObj); 268 316 317 int AudioTestSetTestBegin(PAUDIOTESTSET pSet, const char *pszDesc, PAUDIOTESTPARMS pParms, PAUDIOTESTENTRY *ppEntry); 318 int AudioTestSetTestFailed(PAUDIOTESTENTRY pEntry, int rc, const char *pszErr); 319 int AudioTestSetTestDone(PAUDIOTESTENTRY pEntry); 320 269 321 int AudioTestSetCreate(PAUDIOTESTSET pSet, const char *pszPath, const char *pszTag); 270 322 int AudioTestSetDestroy(PAUDIOTESTSET pSet); 271 323 int AudioTestSetOpen(PAUDIOTESTSET pSet, const char *pszPath); 272 voidAudioTestSetClose(PAUDIOTESTSET pSet);324 int AudioTestSetClose(PAUDIOTESTSET pSet); 273 325 int AudioTestSetWipe(PAUDIOTESTSET pSet); 274 326 int AudioTestSetPack(PAUDIOTESTSET pSet, const char *pszOutDir, char *pszFileName, size_t cbFileName); -
trunk/src/VBox/ValidationKit/utils/audio/vkat.cpp
r89127 r89135 1215 1215 1216 1216 /********************************************************************************************************************************* 1217 * Implementation of Something*1217 * Implementation of audio test environment handling * 1218 1218 *********************************************************************************************************************************/ 1219 1219 … … 1311 1311 1312 1312 /********************************************************************************************************************************* 1313 * Some other stuff, you name it. *1313 * Device enumeration + handling. * 1314 1314 *********************************************************************************************************************************/ 1315 1315 … … 1613 1613 for (uint32_t i = 0; i < pTstParms->cIterations; i++) 1614 1614 { 1615 AudioTestToneParamsInitRandom(&pTstParms->TestTone, &pTstParms->TestTone.Props);1616 rc = audioTestCreateStreamDefaultOut(pTstEnv, pStream, &pTstParms->TestTone.Props);1615 PAUDIOTESTENTRY pTst; 1616 rc = AudioTestSetTestBegin(&pTstEnv->Set, "Playing test tone", pTstParms, &pTst); 1617 1617 if (RT_SUCCESS(rc)) 1618 rc = audioTestPlayTone(pTstEnv, pStream, &pTstParms->TestTone); 1619 1620 int rc2 = audioTestStreamDestroy(pTstEnv, pStream); 1621 if (RT_SUCCESS(rc)) 1622 rc = rc2; 1618 { 1619 AudioTestToneParamsInitRandom(&pTstParms->TestTone, &pTstParms->TestTone.Props); 1620 rc = audioTestCreateStreamDefaultOut(pTstEnv, pStream, &pTstParms->TestTone.Props); 1621 if (RT_SUCCESS(rc)) 1622 { 1623 rc = audioTestPlayTone(pTstEnv, pStream, &pTstParms->TestTone); 1624 } 1625 1626 int rc2 = audioTestStreamDestroy(pTstEnv, pStream); 1627 if (RT_SUCCESS(rc)) 1628 rc = rc2; 1629 1630 if (RT_SUCCESS(rc)) 1631 { 1632 AudioTestSetTestDone(pTst); 1633 } 1634 else 1635 AudioTestSetTestFailed(pTst, rc, "Playing test tone failed"); 1636 } 1637 1638 if (RT_FAILURE(rc)) 1639 RTTestFailed(g_hTest, "Playing tone failed\n"); 1623 1640 } 1624 1641 … … 1889 1906 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Test set packed up to '%s'\n", szFileOut); 1890 1907 1908 #ifndef DEBUG_andy 1891 1909 /* Clean up. */ 1892 1910 int rc2 = AudioTestSetWipe(&TstEnv.Set); 1893 1911 AssertRC(rc2); /* Annoying, but not test-critical. */ 1894 1912 #endif 1895 1913 audioTestEnvDestroy(&TstEnv); 1896 1914 }
Note:
See TracChangeset
for help on using the changeset viewer.