VirtualBox

Ignore:
Timestamp:
Jun 9, 2021 9:16:59 AM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
145012
Message:

Audio/ValKit: More code for completely self-contained (self) testing. bugref:10008

Location:
trunk/src/VBox/ValidationKit/utils/audio
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/utils/audio/vkat.cpp

    r89544 r89575  
    139139    VKAT_TEST_OPT_COUNT = 900,
    140140    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,
    143145    VKAT_TEST_OPT_MODE,
    144146    VKAT_TEST_OPT_OUTDIR,
     
    188190static const RTGETOPTDEF g_aCmdTestOptions[] =
    189191{
    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   }
    209213};
    210214
     
    306310        AudioTestToneParamsInitRandom(&pTstParms->TestTone, &pTstParms->Props);
    307311
    308         PAUDIOTESTENTRY pTst;
    309         rc = AudioTestSetTestBegin(&pTstEnv->Set, "Playing test tone", pTstParms, &pTst);
     312        PAUDIOTESTTONEPARMS const pToneParms = &pTstParms->TestTone;
     313        rc = AudioTestSvcClientToneRecord(&pTstEnv->u.Host.AtsClValKit, pToneParms);
    310314        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);
    325316
    326317        if (RT_FAILURE(rc))
     
    346337static DECLCALLBACK(int) audioTestRecordToneSetup(PAUDIOTESTENV pTstEnv, PAUDIOTESTDESC pTstDesc, PAUDIOTESTPARMS pTstParmsAcq, void **ppvCtx)
    347338{
    348     RT_NOREF(pTstDesc, ppvCtx);
     339    RT_NOREF(pTstEnv, pTstDesc, ppvCtx);
    349340
    350341    pTstParmsAcq->enmType     = AUDIOTESTTYPE_TESTTONE_RECORD;
     
    360351    pTstParmsAcq->idxCurrent  = 0;
    361352
    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;
    374354}
    375355
     
    391371        pTstParms->TestTone.msDuration = RTRandU32Ex(50 /* ms */, RT_MS_30SEC); /** @todo Record even longer? */
    392372#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);
    395377        if (RT_SUCCESS(rc))
    396378        {
    397379            /*
    398              * 1. Arm the ValKit ATS with the recording parameters.
     380             * 2. Tell the guest ATS to start recording.
    399381             */
    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);
    414383        }
    415384
     
    426395static DECLCALLBACK(int) audioTestRecordToneDestroy(PAUDIOTESTENV pTstEnv, void *pvCtx)
    427396{
    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;
    440400}
    441401
     
    550510    else if (pTstEnv->enmMode == AUDIOTESTMODE_HOST)
    551511    {
    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);
    555517        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
    559528        if (RT_SUCCESS(rc))
    560529        {
    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++)
    563532            {
    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);
    579534                if (RT_SUCCESS(rc))
    580535                    rc = rc2;
     536
     537                if (!g_aTests[i].fExcluded)
     538                    uSeq++;
     539
     540                if (g_fTerminate)
     541                    break;
    581542            }
    582543
    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;
    584550        }
    585551    }
     
    598564    switch (pOpt->iShort)
    599565    {
    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";
    608576    }
    609577    return NULL;
     
    632600    uint32_t    uPcmHz        = 0;
    633601    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;
    636607
    637608    int           rc;
     
    662633                break;
    663634
    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;
    674649                break;
    675650
     
    754729    if (TstEnv.enmMode == AUDIOTESTMODE_HOST)
    755730    {
    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");
    762733    }
    763734
    764735    /* 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);
    766739    if (RT_SUCCESS(rc))
    767740    {
  • trunk/src/VBox/ValidationKit/utils/audio/vkatCmdSelfTest.cpp

    r89544 r89575  
    4444
    4545
     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 */
    4653static DECLCALLBACK(int) audioTestSelftestGuestAtsThread(RTTHREAD hThread, void *pvUser)
    4754{
     
    7380                      2 /* 16-bit */, true  /* fSigned */, 2 /* cChannels */, 44100 /* uHz */);
    7481
    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);
    7985    if (RT_SUCCESS(rc))
    8086    {
     
    102108    /*
    103109     * 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.
    106115     * - 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).
    108117     * - 3. Executes a complete test run locally (e.g. without any guest (VM) involved).
    109118     */
     
    125134    AssertRCReturn(rc, RTEXITCODE_FAILURE);
    126135
    127     rc = AudioTestPathCreateTemp(pTstEnv->szPathTemp, sizeof(pTstEnv->szPathTemp), "selftest-host");
     136    rc = AudioTestPathCreateTemp(pTstEnv->szPathTemp, sizeof(pTstEnv->szPathTemp), "selftest-tmp");
    128137    AssertRCReturn(rc, RTEXITCODE_FAILURE);
    129138
     
    133142    /*
    134143     * Step 1.
    135      * Creates a separate thread for the guest ATS.
    136144     */
    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
    140158    if (RT_SUCCESS(rc))
    141159    {
    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);
    143168        if (RT_SUCCESS(rc))
    144169        {
    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);
    160172        }
    161173    }
     
    170182    ASMAtomicWriteBool(&g_fTerminate, true);
    171183
    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    }
    181195
    182196    if (RT_FAILURE(rc))
  • trunk/src/VBox/ValidationKit/utils/audio/vkatCommon.cpp

    r89544 r89575  
    3131
    3232#include <iprt/ctype.h>
     33#include <iprt/dir.h>
    3334#include <iprt/errcore.h>
    3435#include <iprt/getopt.h>
     
    401402    PAUDIOTESTENV   pTstEnv = pCtx->pTstEnv;
    402403
    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);
    410407}
    411408
     
    413410static DECLCALLBACK(int) audioTestSvcTestSetEndCallback(void const *pvUser, const char *pszTag)
    414411{
    415     RT_NOREF(pszTag);
    416 
    417412    PATSCALLBACKCTX pCtx    = (PATSCALLBACKCTX)pvUser;
    418413    PAUDIOTESTENV   pTstEnv = pCtx->pTstEnv;
     
    518513 * @param   pDrvReg             Audio driver to use.
    519514 * @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.
    521520 *                              If NULL, localhost (127.0.0.1) will be used.
    522  * @param   uTcpPort            TCP/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.
    524523 */
    525524int audioTestEnvInit(PAUDIOTESTENV pTstEnv,
    526525                     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
    529561    RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Test mode is '%s'\n", pTstEnv->enmMode == AUDIOTESTMODE_HOST ? "host" : "guest");
    530562    RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Using tag '%s'\n", pTstEnv->szTag);
     
    532564    RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Temp directory is '%s'\n", pTstEnv->szPathTemp);
    533565
    534     int rc = VINF_SUCCESS;
    535 
    536566    PDMAudioHostEnumInit(&pTstEnv->DevEnum);
    537567
     
    544574                                 /* The self test mode drives the ValKit audio driver locally,
    545575                                  * so also use the driver stack here. */
    546                                  || pTstEnv->fSelftest;
     576                                 || (   pTstEnv->enmMode == AUDIOTESTMODE_HOST
     577                                     && pTstEnv->fSelftest);
    547578    if (fUseDriverStack)
    548579    {
    549         rc = audioTestDriverStackInit(&pTstEnv->DrvStack, pDrvReg, fWithDrvAudio);
     580        rc = audioTestDriverStackInitEx(&pTstEnv->DrvStack, pDrvReg,
     581                                        true /* fEnabledIn */, true /* fEnabledOut */, fWithDrvAudio);
    550582        if (RT_FAILURE(rc))
    551583            return rc;
     
    586618        Callbacks.pvUser          = &Ctx;
    587619
    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);
    590630        if (RT_SUCCESS(rc))
    591631            rc = AudioTestSvcStart(&pTstEnv->u.Guest.Srv);
     
    599639    else /* Host mode */
    600640    {
    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);
    605646        if (RT_FAILURE(rc))
    606647        {
    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);
    608649            return rc;
    609650        }
    610651
    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");
    612666    }
    613667
     
    637691            RTTestFailed(g_hTest, "Stream destruction for stream #%u failed with %Rrc\n", i, rc2);
    638692    }
     693
     694    /* Try cleaning up a bit. */
     695    RTDirRemove(pTstEnv->szPathTemp);
     696    RTDirRemove(pTstEnv->szPathOut);
    639697
    640698    audioTestDriverStackDelete(&pTstEnv->DrvStack);
     
    659717        RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Test set packed up to '%s'\n", szFileOut);
    660718
    661     int rc2 = AudioTestSetWipe(&pTstEnv->Set);
    662     if (RT_SUCCESS(rc))
    663         rc = rc2;
     719    /* ignore rc */ AudioTestSetWipe(&pTstEnv->Set);
    664720
    665721    AudioTestSetDestroy(&pTstEnv->Set);
  • trunk/src/VBox/ValidationKit/utils/audio/vkatDriverStack.cpp

    r89535 r89575  
    490490
    491491/**
    492  * Initializes a driver stack.
     492 * Initializes a driver stack, extended version.
    493493 *
    494494 * @returns VBox status code.
    495495 * @param   pDrvStack       The driver stack to initialize.
    496496 * @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.
    497499 * @param   fWithDrvAudio   Whether to include DrvAudio in the stack or not.
    498500 */
    499 int audioTestDriverStackInit(PAUDIOTESTDRVSTACK pDrvStack, PCPDMDRVREG pDrvReg, bool fWithDrvAudio)
     501int audioTestDriverStackInitEx(PAUDIOTESTDRVSTACK pDrvStack, PCPDMDRVREG pDrvReg, bool fEnabledIn, bool fEnabledOut, bool fWithDrvAudio)
    500502{
    501503    int rc;
     
    516518            if (pDrvStack->pIAudioConnector)
    517519            {
    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
    520524                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
    522530                if (RT_FAILURE(rc))
    523531                {
     
    556564
    557565    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 */
     579int audioTestDriverStackInit(PAUDIOTESTDRVSTACK pDrvStack, PCPDMDRVREG pDrvReg, bool fWithDrvAudio)
     580{
     581    return audioTestDriverStackInitEx(pDrvStack, pDrvReg, true /* fEnabledIn */, true /* fEnabledOut */, fWithDrvAudio);
    558582}
    559583
  • trunk/src/VBox/ValidationKit/utils/audio/vkatInternal.h

    r89544 r89575  
    281281            /** Client connected to the ATS on the guest side. */
    282282            ATSCLIENT       AtsClGuest;
    283             /** Client connected to the ATS on the Validation Kit. */
     283            /** Client connected to the Validation Kit audio driver ATS. */
    284284            ATSCLIENT       AtsClValKit;
    285285        } Host;
     
    319319         *  Defaults to the platform's default driver. */
    320320        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;
    321327    } Guest;
    322328    struct
     
    347353 * @{ */
    348354void        audioTestDriverStackDelete(PAUDIOTESTDRVSTACK pDrvStack);
     355int         audioTestDriverStackInitEx(PAUDIOTESTDRVSTACK pDrvStack, PCPDMDRVREG pDrvReg, bool fEnabledIn, bool fEnabledOut, bool fWithDrvAudio);
    349356int         audioTestDriverStackInit(PAUDIOTESTDRVSTACK pDrvStack, PCPDMDRVREG pDrvReg, bool fWithDrvAudio);
    350357int         audioTestDriverStackSetDevice(PAUDIOTESTDRVSTACK pDrvStack, PDMAUDIODIR enmDir, const char *pszDevId);
     
    405412/** @name Test environment handling
    406413 * @{ */
    407 int         audioTestEnvInit(PAUDIOTESTENV pTstEnv, PCPDMDRVREG pDrvReg, bool fWithDrvAudio, const char *pszTcpAddr, uint32_t uTcpPort);
     414int         audioTestEnvInit(PAUDIOTESTENV pTstEnv, PCPDMDRVREG pDrvReg, bool fWithDrvAudio, const char *pszHostTcpAddr, uint32_t uHostTcpPort, const char *pszGuestTcpAddr, uint32_t uGuestTcpPort);
    408415void        audioTestEnvDestroy(PAUDIOTESTENV pTstEnv);
    409416int         audioTestEnvPrologue(PAUDIOTESTENV pTstEnv);
Note: See TracChangeset for help on using the changeset viewer.

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