VirtualBox

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


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/Devices/Audio
Files:
2 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);
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