VirtualBox

Changeset 89316 in vbox for trunk/src/VBox/Devices


Ignore:
Timestamp:
May 27, 2021 12:31:34 PM (4 years ago)
Author:
vboxsync
Message:

Audio/ValKit: Implemented handling for meta data of test (set) objects. bugref:10008

Location:
trunk/src/VBox/Devices/Audio
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Audio/AudioTest.cpp

    r89311 r89316  
    452452
    453453    RTListInit(&pSet->lstTest);
    454     pSet->cTests        = 0;
    455     pSet->cTestsRunning = 0;
    456     pSet->offTestCount  = 0;
    457 
     454    pSet->cTests         = 0;
     455    pSet->cTestsRunning  = 0;
     456    pSet->offTestCount   = 0;
     457    pSet->pTestCur       = NULL;
     458    pSet->cObj           = 0;
     459    pSet->offObjCount    = 0;
    458460    pSet->cTotalFailures = 0;
    459461}
     
    705707    AssertRCReturn(rc, rc);
    706708
     709    rc = audioTestManifestWrite(pSet, "obj_count=");
     710    AssertRCReturn(rc, rc);
     711    pSet->offObjCount = audioTestManifestGetOffsetAbs(pSet);
     712    rc = audioTestManifestWrite(pSet, "0000\n"); /* A bit messy, but does the trick for now. */
     713    AssertRCReturn(rc, rc);
     714
    707715    pSet->enmMode = AUDIOTESTSETMODE_TEST;
    708716
     
    809817        return VINF_SUCCESS;
    810818
    811     /* Update number of ran tests. */
    812     int rc = RTFileSeek(pSet->f.hFile, pSet->offTestCount, RTFILE_SEEK_BEGIN, NULL);
     819    int rc;
     820
     821    /* Update number of bound test objects. */
     822    PAUDIOTESTENTRY pTest;
     823    RTListForEach(&pSet->lstTest, pTest, AUDIOTESTENTRY, Node)
     824    {
     825        rc = RTFileSeek(pSet->f.hFile, pTest->offObjCount, RTFILE_SEEK_BEGIN, NULL);
     826        AssertRCReturn(rc, rc);
     827        rc = audioTestManifestWrite(pSet, "%04RU32", pTest->cObj);
     828        AssertRCReturn(rc, rc);
     829    }
     830
     831    /*
     832     * Update number of ran tests.
     833     */
     834    rc = RTFileSeek(pSet->f.hFile, pSet->offObjCount, RTFILE_SEEK_BEGIN, NULL);
     835    AssertRCReturn(rc, rc);
     836    rc = audioTestManifestWrite(pSet, "%04RU32", pSet->cObj);
     837    AssertRCReturn(rc, rc);
     838
     839    /*
     840     * Update number of ran tests.
     841     */
     842    rc = RTFileSeek(pSet->f.hFile, pSet->offTestCount, RTFILE_SEEK_BEGIN, NULL);
    813843    AssertRCReturn(rc, rc);
    814844    rc = audioTestManifestWrite(pSet, "%04RU32", pSet->cTests);
    815845    AssertRCReturn(rc, rc);
     846
     847    /*
     848     * Serialize all registered test objects.
     849     */
     850    rc = RTFileSeek(pSet->f.hFile, 0, RTFILE_SEEK_END, NULL);
     851    AssertRCReturn(rc, rc);
     852
     853    PAUDIOTESTOBJ pObj;
     854    RTListForEach(&pSet->lstObj, pObj, AUDIOTESTOBJ, Node)
     855    {
     856        rc = audioTestManifestWrite(pSet, "\n");
     857        AssertRCReturn(rc, rc);
     858        char szUuid[64];
     859        rc = RTUuidToStr(&pObj->Uuid, szUuid, sizeof(szUuid));
     860        AssertRCReturn(rc, rc);
     861        rc = audioTestManifestWriteSectionHdr(pSet, "obj_%s", szUuid);
     862        AssertRCReturn(rc, rc);
     863        rc = audioTestManifestWrite(pSet, "obj_type=%RU32\n", pObj->enmType);
     864        AssertRCReturn(rc, rc);
     865        rc = audioTestManifestWrite(pSet, "obj_name=%s\n", pObj->szName);
     866        AssertRCReturn(rc, rc);
     867    }
    816868
    817869    RTFileClose(pSet->f.hFile);
     
    865917
    866918/**
    867  * Creates and registers a new audio test object to a test set.
     919 * Creates and registers a new audio test object to the current running test.
    868920 *
    869921 * @returns VBox status code.
     
    874926int AudioTestSetObjCreateAndRegister(PAUDIOTESTSET pSet, const char *pszName, PAUDIOTESTOBJ *ppObj)
    875927{
     928    AssertReturn(pSet->cTestsRunning == 1, VERR_WRONG_ORDER); /* No test nesting allowed. */
     929
    876930    AssertPtrReturn(pszName, VERR_INVALID_POINTER);
    877931
     
    892946        {
    893947            pObj->enmType = AUDIOTESTOBJTYPE_FILE;
     948            pObj->cRefs   = 1; /* Currently only 1:1 mapping. */
    894949
    895950            RTListAppend(&pSet->lstObj, &pObj->Node);
    896951            pSet->cObj++;
     952
     953            /* Generate + set an UUID for the object and assign it to the current test. */
     954            rc = RTUuidCreate(&pObj->Uuid);
     955            AssertRCReturn(rc, rc);
     956            char szUuid[64];
     957            rc = RTUuidToStr(&pObj->Uuid, szUuid, sizeof(szUuid));
     958            AssertRCReturn(rc, rc);
     959
     960            rc = audioTestManifestWrite(pSet, "obj%RU32_uuid=%s\n", pSet->pTestCur->cObj, szUuid);
     961            AssertRCReturn(rc, rc);
     962
     963            AssertPtr(pSet->pTestCur);
     964            pSet->pTestCur->cObj++;
    897965
    898966            *ppObj = pObj;
     
    9631031    AssertRCReturn(rc, rc);
    9641032
    965     rc = audioTestManifestWriteSectionHdr(pSet, "test%04RU32", pSet->cTests);
     1033    rc = audioTestManifestWriteSectionHdr(pSet, "test_%04RU32", pSet->cTests);
    9661034    AssertRCReturn(rc, rc);
    9671035    rc = audioTestManifestWrite(pSet, "test_desc=%s\n", pszDesc);
     
    9721040    AssertRCReturn(rc, rc);
    9731041    rc = audioTestManifestWrite(pSet, "audio_direction=%s\n", PDMAudioDirGetName(pParms->enmDir));
     1042    AssertRCReturn(rc, rc);
     1043
     1044    rc = audioTestManifestWrite(pSet, "obj_count=");
     1045    AssertRCReturn(rc, rc);
     1046    pEntry->offObjCount = audioTestManifestGetOffsetAbs(pSet);
     1047    rc = audioTestManifestWrite(pSet, "0000\n"); /* A bit messy, but does the trick for now. */
    9741048    AssertRCReturn(rc, rc);
    9751049
     
    10091083    pSet->cTests++;
    10101084    pSet->cTestsRunning++;
     1085    pSet->pTestCur = pEntry;
    10111086
    10121087    *ppEntry = pEntry;
     
    10281103
    10291104    pEntry->pParent->cTestsRunning--;
     1105    pEntry->pParent->pTestCur = NULL;
    10301106
    10311107    return rc2;
     
    10411117
    10421118    pEntry->pParent->cTestsRunning--;
     1119    pEntry->pParent->pTestCur = NULL;
    10431120
    10441121    return rc2;
  • trunk/src/VBox/Devices/Audio/AudioTest.h

    r89308 r89316  
    185185    /** List node. */
    186186    RTLISTNODE           Node;
     187    RTUUID               Uuid;
     188    /** Number of references to this test object. */
     189    uint32_t             cRefs;
    187190    /** Name of the test object.
    188191     *  Must not contain a path and has to be able to serialize to disk. */
     
    208211    char                 szDesc[64];
    209212    AUDIOTESTPARMS       Parms;
     213    /** Number of test objects bound to this test. */
     214    uint32_t             cObj;
     215    /** Absolute offset (in bytes) where to write the "obj_count" value later. */
     216    uint64_t             offObjCount;
    210217    int                  rc;
    211218} AUDIOTESTENTRY;
     
    234241    /** Number of test objects in lstObj. */
    235242    uint32_t         cObj;
     243    /** Absolute offset (in bytes) where to write the "obj_count" value later. */
     244    uint64_t         offObjCount;
    236245    /** List containing PAUDIOTESTOBJ test object entries. */
    237246    RTLISTANCHOR     lstObj;
     
    243252    /** List containing PAUDIOTESTENTRY test entries. */
    244253    RTLISTANCHOR     lstTest;
    245     /** Number of tests currently running. */
     254    /** Current test running. Can be NULL if no test is running. */
     255    PAUDIOTESTENTRY  pTestCur;
     256    /** Number of tests currently running.
     257     *  Currently we only allow one concurrent test running at a given time. */
    246258    uint32_t         cTestsRunning;
    247259    /** Number of total (test) failures. */
Note: See TracChangeset for help on using the changeset viewer.

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