VirtualBox

Ignore:
Timestamp:
May 31, 2021 7:26:13 AM (4 years ago)
Author:
vboxsync
Message:

Audio/ValKit: More validation / test set handling code. bugref:10008

File:
1 edited

Legend:

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

    r89380 r89383  
    22162216*********************************************************************************************************************************/
    22172217
    2218 /**
    2219  * Verifies one single test set.
    2220  *
    2221  * @returns VBox status code.
    2222  * @param   pszPath             Absolute path to test set.
    2223  * @param   pszTag              Tag of test set to verify. Optional and can be NULL.
    2224  */
    2225 static int audioVerifyOne(const char *pszPath, const char *pszTag)
    2226 {
    2227     RTTestSubF(g_hTest, "Verifying test set ...");
    2228 
    2229     RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Using tag '%s'\n", pszTag ? pszTag : "default");
    2230     RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Opening archive '%s'\n", pszPath);
    2231 
    2232     int rc = VINF_SUCCESS;
     2218static int audioVerifyOpenTestSet(const char *pszPathSet, PAUDIOTESTSET pSet)
     2219{
     2220    int rc;
    22332221
    22342222    char szPathExtracted[RTPATH_MAX];
    2235     const bool fPacked = AudioTestSetIsPacked(pszPath);
     2223
     2224    RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Opening test set '%s'\n", pszPathSet);
     2225
     2226    const bool fPacked = AudioTestSetIsPacked(pszPathSet);
    22362227    if (fPacked)
    22372228    {
     2229        RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Test set is an archive and needs to be unpacked\n");
     2230
    22382231        char szPathTemp[RTPATH_MAX];
    22392232        rc = RTPathTemp(szPathTemp, sizeof(szPathTemp));
     
    22492242                {
    22502243                    RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Unpacking archive to '%s'\n", szPathExtracted);
    2251                     rc = AudioTestSetUnpack(pszPath, szPathExtracted);
     2244                    rc = AudioTestSetUnpack(pszPathSet, szPathExtracted);
    22522245                    if (RT_SUCCESS(rc))
    22532246                        RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Archive successfully unpacked\n");
     
    22562249        }
    22572250    }
     2251    else
     2252        rc = VINF_SUCCESS;
     2253
     2254    if (RT_SUCCESS(rc))
     2255        rc = AudioTestSetOpen(pSet, fPacked ? szPathExtracted : pszPathSet);
    22582256
    22592257    if (RT_FAILURE(rc))
    2260     {
    22612258        RTTestFailed(g_hTest, "Unable to open / unpack test set archive: %Rrc", rc);
    2262         return rc;
    2263     }
    2264 
    2265     AUDIOTESTSET tstSet;
    2266     rc = AudioTestSetOpen(&tstSet, fPacked ? szPathExtracted : pszPath);
     2259
     2260    return rc;
     2261}
     2262
     2263/**
     2264 * Verifies one single test set.
     2265 *
     2266 * @returns VBox status code.
     2267 * @param   pszPathSetA         Absolute path to test set A.
     2268 * @param   pszPathSetB         Absolute path to test set B.
     2269 */
     2270static int audioVerifyOne(const char *pszPathSetA, const char *pszPathSetB)
     2271{
     2272    RTTestSubF(g_hTest, "Verifying");
     2273    RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Verifying test set '%s' with test set '%s'\n", pszPathSetA, pszPathSetB);
     2274
     2275    AUDIOTESTSET SetA, SetB;
     2276    int rc = audioVerifyOpenTestSet(pszPathSetA, &SetA);
    22672277    if (RT_SUCCESS(rc))
     2278        rc = audioVerifyOpenTestSet(pszPathSetB, &SetB);
     2279
     2280    if (RT_SUCCESS(rc))
    22682281    {
    22692282        AUDIOTESTERRORDESC errDesc;
    2270         rc = AudioTestSetVerify(&tstSet, pszTag ? pszTag : "default", &errDesc);
     2283        rc = AudioTestSetVerify(&SetA, &SetB, &errDesc);
    22712284        if (RT_SUCCESS(rc))
    22722285        {
     
    22762289                PAUDIOTESTERRORENTRY pErrEntry;
    22772290                RTListForEach(&errDesc.List, pErrEntry, AUDIOTESTERRORENTRY, Node)
    2278                 {
    22792291                    RTTestFailed(g_hTest, pErrEntry->szDesc);
    2280                 }
    22812292            }
    22822293            else
    2283                 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Verification successful");
     2294                RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Verification successful\n");
    22842295
    22852296            AudioTestErrorDescDestroy(&errDesc);
     
    22872298        else
    22882299            RTTestFailed(g_hTest, "Verification failed with %Rrc", rc);
    2289 
    2290         AudioTestSetClose(&tstSet);
    2291     }
    2292     else
    2293         RTTestFailed(g_hTest, "Opening test set '%s' (tag '%s') failed, rc=%Rrc\n", pszPath, pszTag, rc);
     2300    }
     2301
     2302    AudioTestSetClose(&SetA);
     2303    AudioTestSetClose(&SetB);
    22942304
    22952305    RTTestSubDone(g_hTest);
     
    23092319     * Parse options and process arguments.
    23102320     */
    2311     const char   *pszTag   = NULL; /* Custom tag to use. Can be NULL if not being used. */
    2312     unsigned      iTestSet = 0;
     2321    char     *pszSetA = NULL;
     2322    char     *pszSetB = NULL;
     2323    unsigned iTestSet = 0;
    23132324
    23142325    int           rc;
     
    23192330        {
    23202331            case VKAT_VERIFY_OPT_TAG:
    2321                 pszTag = ValueUnion.psz;
    2322                 if (g_uVerbosity > 0)
    2323                     RTMsgInfo("Using tag '%s'\n", pszTag);
    23242332                break;
    23252333
    23262334            case VINF_GETOPT_NOT_OPTION:
     2335            {
     2336                char **ppszSet = iTestSet == 0 ? &pszSetA : &pszSetB;
     2337
    23272338                if (iTestSet == 0)
    23282339                    RTTestBanner(g_hTest);
    2329                 audioVerifyOne(ValueUnion.psz, pszTag);
     2340
     2341                *ppszSet = RTStrDup(ValueUnion.psz);
     2342                AssertPtrReturn(*ppszSet, RTEXITCODE_FAILURE);
     2343
    23302344                iTestSet++;
    23312345                break;
     2346            }
    23322347
    23332348            AUDIO_TEST_COMMON_OPTION_CASES(ValueUnion);
     
    23382353    }
    23392354
     2355    if (!iTestSet)
     2356        return RTMsgErrorExitFailure("At least one test set must be specified");
     2357
     2358    if (iTestSet > 2)
     2359        return RTMsgErrorExitFailure("Only two test sets can be verified at one time");
     2360
    23402361    /*
    2341      * If no paths given, default to the current directory.
     2362     * If only test set A is given, default to the current directory
     2363     * for test set B.
    23422364     */
    2343     if (iTestSet == 0)
    2344     {
    2345         if (iTestSet == 0)
    2346             RTTestBanner(g_hTest);
     2365    if (iTestSet == 1)
     2366    {
    23472367        char szDirCur[RTPATH_MAX];
    2348         int rc2 = RTPathGetCurrent(szDirCur, sizeof(szDirCur));
    2349         if (RT_FAILURE(rc2))
    2350             RTTestFailed(g_hTest, "Failed to retrieve current directory: %Rrc", rc2);
    2351         rc = audioVerifyOne(RT_SUCCESS(rc2) ? szDirCur : ".", pszTag);
    2352     }
     2368        rc = RTPathGetCurrent(szDirCur, sizeof(szDirCur));
     2369        if (RT_SUCCESS(rc))
     2370        {
     2371            Assert(pszSetB == NULL);
     2372            pszSetB = RTStrDup(szDirCur);
     2373            AssertPtrReturn(pszSetB, RTEXITCODE_FAILURE);
     2374        }
     2375        else
     2376            RTTestFailed(g_hTest, "Failed to retrieve current directory: %Rrc", rc);
     2377    }
     2378
     2379    if (RT_SUCCESS(rc))
     2380        rc = audioVerifyOne(pszSetA, pszSetB);
     2381
     2382    RTStrFree(pszSetA);
     2383    RTStrFree(pszSetB);
    23532384
    23542385    /*
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