VirtualBox

Changeset 91135 in vbox


Ignore:
Timestamp:
Sep 7, 2021 8:03:30 AM (3 years ago)
Author:
vboxsync
Message:

Audio/Validation Kit: Added more tweakable options for the audio test set verification and also let the test driver pass through those to VKAT when specified. ​bugref:10008

Location:
trunk/src/VBox
Files:
3 edited

Legend:

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

    r91126 r91135  
    182182    /** Zero-based index of current test being verified. */
    183183    uint32_t            idxTest;
    184     /** Flag indicating whether to keep going after an error has occurred. */
    185     bool                fKeepGoing;
    186     /** Threshold of file differences (chunks) at when we consider audio files
    187      *  as not matching. */
    188     uint32_t            cThresholdDiff;
     184    /** The verification options to use. */
     185    AUDIOTESTVERIFYOPTS Opts;
    189186    /** PCM properties to use for verification. */
    190187    PDMAUDIOPCMPROPS    PCMProps;
     
    18461843    va_end(va);
    18471844
    1848     return pVerJob->fKeepGoing ? VINF_SUCCESS : rc;
     1845    return pVerJob->Opts.fKeepGoing ? VINF_SUCCESS : rc;
    18491846}
    18501847
     
    20172014            if (cDiffs)
    20182015            {
    2019                 int rc2 = audioTestErrorDescAddInfo(pVerJob->pErr, pVerJob->idxTest, "Chunks differ: A [%RU64-%RU64] vs. B [%RU64-%RU64] (%RU64 bytes, %RU64us)",
     2016                int rc2 = audioTestErrorDescAddInfo(pVerJob->pErr, pVerJob->idxTest, "Chunks differ: A [%RU64-%RU64] vs. B [%RU64-%RU64] (%RU64 bytes, %RU64ms)",
    20202017                                                                                     pCmpA->offStart + offLastDiff, pCmpA->offStart + offCur,
    20212018                                                                                     pCmpB->offStart + offLastDiff, pCmpB->offStart + offCur, offCur - offLastDiff,
    2022                                                                                      PDMAudioPropsBytesToMicro(&pToneParms->Props, offCur - offLastDiff));
     2019                                                                                     PDMAudioPropsBytesToMilli(&pToneParms->Props, offCur - offLastDiff));
    20232020                AssertRC(rc2);
    20242021            }
     
    20372034    if (RT_FAILURE(a_rc)) \
    20382035    { \
    2039         if (!a_pVerJob->fKeepGoing) \
     2036        if (!a_pVerJob->Opts.fKeepGoing) \
    20402037            return VINF_SUCCESS; \
    20412038    }
     
    20462043        int rc3 = audioTestErrorDescAddError(a_pVerJob->pErr, a_pVerJob->idxTest, a_Msg); \
    20472044        AssertRC(rc3); \
    2048         if (!a_pVerJob->fKeepGoing) \
     2045        if (!a_pVerJob->Opts.fKeepGoing) \
    20492046            return VINF_SUCCESS; \
    20502047    }
     
    20552052        int rc3 = audioTestErrorDescAddError(a_pVerJob->pErr, a_pVerJob->idxTest, a_Msg, __VA_ARGS__); \
    20562053        AssertRC(rc3); \
    2057         if (!a_pVerJob->fKeepGoing) \
     2054        if (!a_pVerJob->Opts.fKeepGoing) \
    20582055            return VINF_SUCCESS; \
    20592056
     
    21112108        size_t const cbDiffAbs = cbSizeA > cbSizeB ? cbSizeA - cbSizeB : cbSizeB - cbSizeA;
    21122109
    2113         int rc2 = audioTestErrorDescAddInfo(pVerJob->pErr, pVerJob->idxTest, "File '%s' is %zu bytes (%RU64us)",
    2114                                             ObjA.szName, cbSizeA, PDMAudioPropsBytesToMicro(&pVerJob->PCMProps, cbSizeA));
     2110        int rc2 = audioTestErrorDescAddInfo(pVerJob->pErr, pVerJob->idxTest, "File '%s' is %zu bytes (%RU64ms)",
     2111                                            ObjA.szName, cbSizeA, PDMAudioPropsBytesToMilli(&pVerJob->PCMProps, cbSizeA));
    21152112        AssertRC(rc2);
    2116         rc2 = audioTestErrorDescAddInfo(pVerJob->pErr, pVerJob->idxTest, "File '%s' is %zu bytes (%RU64us)",
    2117                                         ObjB.szName, cbSizeB, PDMAudioPropsBytesToMicro(&pVerJob->PCMProps, cbSizeB));
     2113        rc2 = audioTestErrorDescAddInfo(pVerJob->pErr, pVerJob->idxTest, "File '%s' is %zu bytes (%RU64ms)",
     2114                                        ObjB.szName, cbSizeB, PDMAudioPropsBytesToMilli(&pVerJob->PCMProps, cbSizeB));
    21182115        AssertRC(rc2);
    21192116
    2120         rc2 = audioTestErrorDescAddInfo(pVerJob->pErr, pVerJob->idxTest, "File '%s' is %u%% (%zu bytes, %RU64us) %s than '%s'",
    2121                                         ObjA.szName,
    2122                                         cbSizeA > cbSizeB ? 100 - ((cbSizeB * 100) / cbSizeA) : 100 - ((cbSizeA * 100) / cbSizeB),
    2123                                         cbDiffAbs, PDMAudioPropsBytesToMicro(&pVerJob->PCMProps, (uint32_t)cbDiffAbs),
    2124                                         cbSizeA > cbSizeB ? "bigger" : "smaller",
    2125                                         ObjB.szName);
    2126         AssertRC(rc2);
     2117        uint8_t const uSizeDiffPercentAbs
     2118            = cbSizeA > cbSizeB ? 100 - ((cbSizeB * 100) / cbSizeA) : 100 - ((cbSizeA * 100) / cbSizeB);
     2119
     2120        if (uSizeDiffPercentAbs > pVerJob->Opts.uMaxSizePercent)
     2121        {
     2122            rc2 = audioTestErrorDescAddError(pVerJob->pErr, pVerJob->idxTest,
     2123                                             "File '%s' is %RU8%% (%zu bytes, %RU64ms) %s than '%s' (threshold is %RU8%%)",
     2124                                             ObjA.szName,
     2125                                             uSizeDiffPercentAbs,
     2126                                             cbDiffAbs, PDMAudioPropsBytesToMilli(&pVerJob->PCMProps, (uint32_t)cbDiffAbs),
     2127                                             cbSizeA > cbSizeB ? "bigger" : "smaller",
     2128                                             ObjB.szName, pVerJob->Opts.uMaxSizePercent);
     2129            AssertRC(rc2);
     2130        }
    21272131    }
    21282132
     
    21612165    uint32_t const cDiffs = audioTestFilesFindDiffsBinary(pVerJob, &FileA, &FileB, &ToneParmsA);
    21622166
    2163     rc2 = audioTestErrorDescAddInfo(pVerJob->pErr, pVerJob->idxTest, "Files '%s' and '%s' are %s (%RU32 different chunks, threshold is %RU32)",
    2164                                     ObjA.szName, ObjB.szName, cDiffs == 0 ? "equal" : "different", cDiffs, pVerJob->cThresholdDiff);
    2165     AssertRC(rc2);
    2166 
    2167     if (cDiffs > pVerJob->cThresholdDiff)
    2168     {
    2169         rc2 = audioTestErrorDescAddError(pVerJob->pErr, pVerJob->idxTest, "Files '%s' and '%s' do not match",
    2170                                          ObjA.szName, ObjB.szName);
     2167    if (cDiffs > pVerJob->Opts.cMaxDiff)
     2168    {
     2169        rc2 = audioTestErrorDescAddError(pVerJob->pErr, pVerJob->idxTest,
     2170                                         "Files '%s' and '%s' have too many different chunks (%RU32 vs. %RU32)",
     2171                                         ObjA.szName, ObjB.szName, cDiffs, pVerJob->Opts.cMaxDiff);
     2172        AssertRC(rc2);
     2173    }
     2174
     2175    if (AudioTestErrorDescFailed(pVerJob->pErr))
     2176    {
     2177        rc2 = audioTestErrorDescAddInfo(pVerJob->pErr, pVerJob->idxTest, "Files '%s' and '%s' do not match",
     2178                                        ObjA.szName, ObjB.szName);
    21712179        AssertRC(rc2);
    21722180    }
     
    22382246
    22392247/**
    2240  * Verifies an opened audio test set.
     2248 * Verifies an opened audio test set, extended version.
    22412249 *
    22422250 * @returns VBox status code.
    22432251 * @param   pSetA               Test set A to verify.
    22442252 * @param   pSetB               Test set to verify test set A with.
     2253 * @param   pOpts               Verification options to use.
    22452254 * @param   pErrDesc            Where to return the test verification errors.
    22462255 *
    22472256 * @note    Test verification errors have to be checked for errors, regardless of the
    22482257 *          actual return code.
    2249  */
    2250 int AudioTestSetVerify(PAUDIOTESTSET pSetA, PAUDIOTESTSET pSetB, PAUDIOTESTERRORDESC pErrDesc)
    2251 {
     2258 * @note    Uses the standard verification options. Use AudioTestSetVerifyEx() to specify
     2259 *          own options.
     2260 */
     2261int AudioTestSetVerifyEx(PAUDIOTESTSET pSetA, PAUDIOTESTSET pSetB, PAUDIOTESTVERIFYOPTS pOpts, PAUDIOTESTERRORDESC pErrDesc)
     2262{
     2263    AssertPtrReturn(pSetA, VERR_INVALID_POINTER);
     2264    AssertPtrReturn(pSetB, VERR_INVALID_POINTER);
    22522265    AssertReturn(audioTestManifestIsOpen(pSetA), VERR_WRONG_ORDER);
    22532266    AssertReturn(audioTestManifestIsOpen(pSetB), VERR_WRONG_ORDER);
     2267    AssertPtrReturn(pOpts, VERR_INVALID_POINTER);
    22542268
    22552269    /* We ASSUME the caller has not init'd pErrDesc. */
     
    22612275    VerJob.pSetA      = pSetA;
    22622276    VerJob.pSetB      = pSetB;
    2263     VerJob.fKeepGoing = true; /** @todo Make this configurable. */
    2264 
    2265     /** @todo For now we're very strict and consider any diff as being erroneous.
    2266      *        We might want / need to change this depending on the test boxes lateron. */
    2267     VerJob.cThresholdDiff = 0;
     2277
     2278    memcpy(&VerJob.Opts, pOpts, sizeof(AUDIOTESTVERIFYOPTS));
    22682279
    22692280    PAUDIOTESTVERIFYJOB pVerJob = &VerJob;
     
    23562367    /* Only return critical stuff not related to actual testing here. */
    23572368    return VINF_SUCCESS;
     2369}
     2370
     2371/**
     2372 * Initializes audio test verification options in a strict manner.
     2373 *
     2374 * @param   pOpts               Verification options to initialize.
     2375 */
     2376void AudioTestSetVerifyOptsInitStrict(PAUDIOTESTVERIFYOPTS pOpts)
     2377{
     2378    RT_BZERO(pOpts, sizeof(AUDIOTESTVERIFYOPTS));
     2379
     2380    pOpts->fKeepGoing      = true;
     2381    pOpts->cMaxDiff        = 0; /* By default we're very strict and consider any diff as being erroneous. */
     2382    pOpts->uMaxSizePercent = 0; /* Ditto for size difference. */
     2383}
     2384
     2385/**
     2386 * Verifies an opened audio test set.
     2387 *
     2388 * @returns VBox status code.
     2389 * @param   pSetA               Test set A to verify.
     2390 * @param   pSetB               Test set to verify test set A with.
     2391 * @param   pErrDesc            Where to return the test verification errors.
     2392 *
     2393 * @note    Test verification errors have to be checked for errors, regardless of the
     2394 *          actual return code.
     2395 * @note    Uses the standard verification options (strict!).
     2396 *          Use AudioTestSetVerifyEx() to specify own options.
     2397 */
     2398int AudioTestSetVerify(PAUDIOTESTSET pSetA, PAUDIOTESTSET pSetB, PAUDIOTESTERRORDESC pErrDesc)
     2399{
     2400    AUDIOTESTVERIFYOPTS Opts;
     2401    AudioTestSetVerifyOptsInitStrict(&Opts);
     2402
     2403    return AudioTestSetVerifyEx(pSetA,pSetB, &Opts, pErrDesc);
    23582404}
    23592405
  • trunk/src/VBox/Devices/Audio/AudioTest.h

    r91051 r91135  
    230230
    231231/**
     232 * Audio test verification options.
     233 */
     234typedef struct AUDIOTESTVERIFYOPTS
     235{
     236    /** Flag indicating whether to keep going after an error has occurred. */
     237    bool                fKeepGoing;
     238    /** Threshold of file differences (number of chunks) at when we consider audio files
     239     *  as not matching. 0 means an exact match. */
     240    uint32_t            cMaxDiff;
     241    /** Threshold of file differences (difference in percent) at when we consider audio files
     242     *  as not matching. 0 means an exact match. */
     243    uint8_t             uMaxDiffPercent;
     244    /** Threshold of file size (+/-, in percent) at when we consider audio files
     245     *  as not matching. 0 means an exact match.*/
     246    uint8_t             uMaxSizePercent;
     247} AUDIOTESTVERIFYOPTS;
     248/** Pointer to audio test verification options. */
     249typedef AUDIOTESTVERIFYOPTS *PAUDIOTESTVERIFYOPTS;
     250
     251/**
    232252 * Structure for holding a single audio test error entry.
    233253 */
     
    295315int    AudioTestSetPack(PAUDIOTESTSET pSet, const char *pszOutDir, char *pszFileName, size_t cbFileName);
    296316int    AudioTestSetUnpack(const char *pszFile, const char *pszOutDir);
     317
     318void   AudioTestSetVerifyOptsInitStrict(PAUDIOTESTVERIFYOPTS pOpts);
    297319int    AudioTestSetVerify(PAUDIOTESTSET pSetA, PAUDIOTESTSET pSetB, PAUDIOTESTERRORDESC pErrDesc);
     320int    AudioTestSetVerifyEx(PAUDIOTESTSET pSetA, PAUDIOTESTSET pSetB, PAUDIOTESTVERIFYOPTS pOpts, PAUDIOTESTERRORDESC pErrDesc);
    298321
    299322uint32_t AudioTestErrorDescCount(PCAUDIOTESTERRORDESC pErr);
  • trunk/src/VBox/ValidationKit/tests/audio/tdAudioTest.py

    r91127 r91135  
    8585        self.asTests          = self.asTestsDef;
    8686
     87        # Optional arguments passing to VKAT when verifying audio test sets.
     88        self.asVkatVerifyArgs = [];
     89
    8790        # Enable audio debug mode.
    8891        #
     
    107110        reporter.log('  --audio-tests   <s1[:s2[:]]>');
    108111        reporter.log('      Default: %s  (all)' % (':'.join(self.asTestsDef)));
     112        reporter.log('  --audio-verify-max-diff-count <number>');
     113        reporter.log('      Default: 0 (strict)');
     114        reporter.log('  --audio-verify-max-diff-percent <0-100>');
     115        reporter.log('      Default: 0 (strict)');
     116        reporter.log('  --audio-verify-max-size-percent <0-100>');
     117        reporter.log('      Default: 0 (strict)');
    109118        return fRc;
    110119
     
    129138                        raise base.InvalidOption('The "--audio-tests" value "%s" is not valid; valid values are: %s'
    130139                                                    % (s, ' '.join(self.asTestsDef)));
     140        elif    asArgs[iArg] == '--audio-verify-max-diff-count' \
     141             or asArgs[iArg] == '--audio-verify-max-diff-percent' \
     142             or asArgs[iArg] == '--audio-verify-max-size-percent':
     143            # Strip the "--audio-verify-" prefix and keep the options as defined in VKAT,
     144            # e.g. "--audio-verify-max-diff-count" -> "--max-diff-count". That way we don't
     145            # need to do any special argument translation and whatnot.
     146            self.asVkatVerifyArgs.extend(['--' + asArgs[iArg][len('--audio-verify-'):]]);
     147            iArg += 1;
     148            if iArg >= len(asArgs):
     149                raise base.InvalidOption('Option "%s" needs a value' % (asArgs[iArg - 1]));
     150            self.asVkatVerifyArgs.extend([asArgs[iArg]]);
    131151        else:
    132152            return vbox.TestDriver.parseOption(self, asArgs, iArg);
     
    535555                asArgs.extend([ '-v' ]);
    536556
     557            if self.asVkatVerifyArgs:
     558                asArgs += self.asVkatVerifyArgs;
     559
    537560            fRc = self.executeHst("VKAT Host Verify", asArgs);
    538561            if fRc:
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