VirtualBox

Changeset 89139 in vbox


Ignore:
Timestamp:
May 18, 2021 1:29:24 PM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
144480
Message:

Audio/ValKit: Implemented unpacking and verification of packed audio test archives. bugref:10008

Location:
trunk/src/VBox
Files:
3 edited

Legend:

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

    r89136 r89139  
    5555/** The current test manifest version. */
    5656#define AUDIOTEST_MANIFEST_VER      1
     57/** Audio test archive default suffix.
     58 *  According to IPRT terminology this always contains the dot. */
     59#define AUDIOTEST_ARCHIVE_SUFF_STR  ".tar.gz"
    5760
    5861/** Test manifest header name. */
     
    779782        return VINF_SUCCESS;
    780783
     784    if (!RTFileIsValid(pSet->f.hFile))
     785        return VINF_SUCCESS;
     786
    781787    /* Update number of ran tests. */
    782788    int rc = RTFileSeek(pSet->f.hFile, pSet->offTestCount, RTFILE_SEEK_BEGIN, NULL);
     
    785791    AssertRCReturn(rc, rc);
    786792
    787     if (RTFileIsValid(pSet->f.hFile))
    788     {
    789         RTFileClose(pSet->f.hFile);
    790         pSet->f.hFile = NIL_RTFILE;
    791     }
     793    RTFileClose(pSet->f.hFile);
     794    pSet->f.hFile = NIL_RTFILE;
    792795
    793796    return rc;
     
    10331036
    10341037    char szOutName[RT_ELEMENTS(AUDIOTEST_PATH_PREFIX_STR) + AUDIOTEST_TAG_MAX + 16];
    1035     if (RTStrPrintf2(szOutName, sizeof(szOutName), "%s-%s.tar.gz", AUDIOTEST_PATH_PREFIX_STR, pSet->szTag) <= 0)
     1038    if (RTStrPrintf2(szOutName, sizeof(szOutName), "%s-%s%s",
     1039                     AUDIOTEST_PATH_PREFIX_STR, pSet->szTag, AUDIOTEST_ARCHIVE_SUFF_STR) <= 0)
    10361040        AssertFailedReturn(VERR_BUFFER_OVERFLOW);
    10371041
     
    10661070
    10671071/**
     1072 * Returns whether a test set archive is packed (as .tar.gz by default) or
     1073 * a plain directory.
     1074 *
     1075 * @returns \c true if packed (as .tar.gz), or \c false if not (directory).
     1076 * @param   pszPath             Path to return packed staus for.
     1077 */
     1078bool AudioTestSetIsPacked(const char *pszPath)
     1079{
     1080    /** @todo Improve this, good enough for now. */
     1081    return (RTStrIStr(pszPath, AUDIOTEST_ARCHIVE_SUFF_STR) != NULL);
     1082}
     1083
     1084/**
    10681085 * Unpacks a formerly packed audio test set.
    10691086 *
    10701087 * @returns VBox status code.
    1071  * @param   pszFile             Test set file to unpack.
     1088 * @param   pszFile             Test set file to unpack. Must contain the absolute path.
    10721089 * @param   pszOutDir           Directory where to unpack the test set into.
    10731090 *                              If the directory does not exist it will be created.
     
    10751092int AudioTestSetUnpack(const char *pszFile, const char *pszOutDir)
    10761093{
    1077     RT_NOREF(pszFile, pszOutDir);
    1078 
    1079     // RTZipTarCmd()
    1080 
    1081     return VERR_NOT_IMPLEMENTED;
     1094    AssertReturn(pszFile && pszOutDir, VERR_INVALID_PARAMETER);
     1095
     1096    int rc = VINF_SUCCESS;
     1097
     1098    if (!RTDirExists(pszOutDir))
     1099    {
     1100        rc = RTDirCreateFullPath(pszOutDir, 0755);
     1101        if (RT_FAILURE(rc))
     1102            return rc;
     1103    }
     1104
     1105    const char *apszArgs[8];
     1106    unsigned    cArgs = 0;
     1107
     1108    apszArgs[cArgs++] = "AudioTest";
     1109    apszArgs[cArgs++] = "--extract";
     1110    apszArgs[cArgs++] = "--gunzip";
     1111    apszArgs[cArgs++] = "--directory";
     1112    apszArgs[cArgs++] = pszOutDir;
     1113    apszArgs[cArgs++] = "--file";
     1114    apszArgs[cArgs++] = pszFile;
     1115
     1116    RTEXITCODE rcExit = RTZipTarCmd(cArgs, (char **)apszArgs);
     1117    if (rcExit != RTEXITCODE_SUCCESS)
     1118        rc = VERR_GENERAL_FAILURE; /** @todo Fudge! */
     1119
     1120    return rc;
    10821121}
    10831122
  • trunk/src/VBox/Devices/Audio/AudioTest.h

    r89135 r89139  
    2727
    2828/** Maximum length in characters an audio test tag can have. */
    29 #define AUDIOTEST_TAG_MAX          64
     29#define AUDIOTEST_TAG_MAX               64
    3030/** Maximum length in characters a single audio test error description can have. */
    31 #define AUDIOTEST_ERROR_DESC_MAX   128
     31#define AUDIOTEST_ERROR_DESC_MAX        128
    3232/** Prefix for audio test (set) directories. */
    33 #define AUDIOTEST_PATH_PREFIX_STR "vkat"
     33#define AUDIOTEST_PATH_PREFIX_STR       "vkat"
    3434
    3535/**
     
    324324int    AudioTestSetClose(PAUDIOTESTSET pSet);
    325325int    AudioTestSetWipe(PAUDIOTESTSET pSet);
     326bool   AudioTestSetIsPacked(const char *pszPath);
    326327int    AudioTestSetPack(PAUDIOTESTSET pSet, const char *pszOutDir, char *pszFileName, size_t cbFileName);
    327328int    AudioTestSetUnpack(const char *pszFile, const char *pszOutDir);
  • trunk/src/VBox/ValidationKit/utils/audio/vkat.cpp

    r89136 r89139  
    3131#include <iprt/buildconfig.h>
    3232#include <iprt/ctype.h>
     33#include <iprt/dir.h>
    3334#include <iprt/errcore.h>
    3435#include <iprt/initterm.h>
     
    19421943static int audioVerifyOne(const char *pszPath, const char *pszTag)
    19431944{
    1944     RTTestSubF(g_hTest, "Verifying test set (tag '%s') ...", pszTag ? pszTag : "default");
     1945    RTTestSubF(g_hTest, "Verifying test set ...");
     1946
     1947    RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Using tag '%s'\n", pszTag ? pszTag : "default");
     1948    RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Opening archive '%s'\n", pszPath);
     1949
     1950    int rc = VINF_SUCCESS;
     1951
     1952    char szPathExtracted[RTPATH_MAX];
     1953    const bool fPacked = AudioTestSetIsPacked(pszPath);
     1954    if (fPacked)
     1955    {
     1956        char szPathTemp[RTPATH_MAX];
     1957        rc = RTPathTemp(szPathTemp, sizeof(szPathTemp));
     1958        if (RT_SUCCESS(rc))
     1959        {
     1960            RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Using temporary directory '%s'\n", szPathTemp);
     1961
     1962            rc = RTPathJoin(szPathExtracted, sizeof(szPathExtracted), szPathTemp, "vkat-XXXX");
     1963            if (RT_SUCCESS(rc))
     1964            {
     1965                rc = RTDirCreateTemp(szPathExtracted, 0755);
     1966                if (RT_SUCCESS(rc))
     1967                {
     1968                    RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Unpacking archive to '%s'\n", szPathExtracted);
     1969                    rc = AudioTestSetUnpack(pszPath, szPathExtracted);
     1970                    if (RT_SUCCESS(rc))
     1971                        RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Archive successfully unpacked\n");
     1972                }
     1973            }
     1974        }
     1975    }
     1976
     1977    if (RT_FAILURE(rc))
     1978    {
     1979        RTTestFailed(g_hTest, "Unable to open / unpack test set archive: %Rrc", rc);
     1980        return rc;
     1981    }
    19451982
    19461983    AUDIOTESTSET tstSet;
    1947     int rc = AudioTestSetOpen(&tstSet, pszPath);
     1984    rc = AudioTestSetOpen(&tstSet, fPacked ? szPathExtracted : pszPath);
    19481985    if (RT_SUCCESS(rc))
    19491986    {
     
    20272064            RTTestBanner(g_hTest);
    20282065        char szDirCur[RTPATH_MAX];
    2029         rc = RTPathGetCurrent(szDirCur, sizeof(szDirCur));
    2030         audioVerifyOne(RT_SUCCESS(rc) ? szDirCur : ".", pszTag);
     2066        int rc2 = RTPathGetCurrent(szDirCur, sizeof(szDirCur));
     2067        if (RT_FAILURE(rc2))
     2068            RTTestFailed(g_hTest, "Failed to retrieve current directory: %Rrc", rc2);
     2069        rc = audioVerifyOne(RT_SUCCESS(rc2) ? szDirCur : ".", pszTag);
    20312070    }
    20322071
     
    22792318    {
    22802319        "test",     audioTestMain,
    2281         "Does some kind of testing, I guess...",
     2320        "Runs audio tests and creates an audio test set.",
    22822321        g_aCmdTestOptions,      RT_ELEMENTS(g_aCmdTestOptions),     audioTestCmdTestHelp
    22832322    },
    22842323    {
    22852324        "verify",   audioVerifyMain,
    2286         "Verfies something, I guess...",
     2325        "Verifies a formerly created audio test set.",
    22872326        g_aCmdVerifyOptions,    RT_ELEMENTS(g_aCmdVerifyOptions),   NULL,
    22882327    },
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