VirtualBox

Changeset 78180 in vbox


Ignore:
Timestamp:
Apr 17, 2019 7:13:51 PM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
130098
Message:

FsPerf: Added '--relative-dir' option to work around PATH_MAX limitations on linux. bugref:9172

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/utils/fs/FsPerf.cpp

    r77979 r78180  
    342342{
    343343    { "--dir",              'd', RTGETOPT_REQ_STRING  },
     344    { "--relative-dir",     'r', RTGETOPT_REQ_NOTHING },
    344345    { "--seconds",          's', RTGETOPT_REQ_UINT32  },
    345346    { "--milliseconds",     'm', RTGETOPT_REQ_UINT64  },
     
    496497static bool         g_fIgnoreNoCache            = false;
    497498
     499/** Set if g_szDir and friends are path relative to CWD rather than absolute. */
     500static bool         g_fRelativeDir              = false;
    498501/** The length of g_szDir. */
    499502static size_t       g_cchDir;
     
    43034306        {
    43044307            case 'd':                           pszHelp = "The directory to use for testing.            default: CWD/fstestdir"; break;
     4308            case 'r':                           pszHelp = "Don't abspath test dir (good for deep dirs). default: disabled"; break;
    43054309            case 'e':                           pszHelp = "Enables all tests.                           default: -e"; break;
    43064310            case 'z':                           pszHelp = "Disables all tests.                          default: -e"; break;
     
    43754379     * Default values.
    43764380     */
    4377     rc = RTPathGetCurrent(g_szDir, sizeof(g_szDir) - FSPERF_MAX_NEEDED_PATH);
    4378     if (RT_SUCCESS(rc))
    4379         rc = RTPathAppend(g_szDir, sizeof(g_szDir) - FSPERF_MAX_NEEDED_PATH, "fstestdir-");
    4380     if (RT_SUCCESS(rc))
    4381     {
    4382         g_cchDir = strlen(g_szDir);
    4383         g_cchDir += RTStrPrintf(&g_szDir[g_cchDir], sizeof(g_szDir) - g_cchDir, "%u" RTPATH_SLASH_STR, RTProcSelf());
    4384     }
    4385     else
    4386     {
    4387         RTTestFailed(g_hTest, "RTPathGetCurrent (or RTPathAppend) failed: %Rrc\n", rc);
    4388         return RTTestSummaryAndDestroy(g_hTest);
    4389     }
     4381    char szDefaultDir[32];
     4382    const char *pszDir = szDefaultDir;
     4383    RTStrPrintf(szDefaultDir, sizeof(szDefaultDir), "fstestdir-%u" RTPATH_SLASH_STR, RTProcSelf());
    43904384
    43914385    RTGETOPTUNION ValueUnion;
     
    43974391        {
    43984392            case 'd':
    4399                 rc = RTPathAbs(ValueUnion.psz, g_szDir, sizeof(g_szDir) - FSPERF_MAX_NEEDED_PATH);
    4400                 if (RT_SUCCESS(rc))
    4401                 {
    4402                     RTPathEnsureTrailingSeparator(g_szDir, sizeof(g_szDir));
    4403                     g_cchDir = strlen(g_szDir);
    4404                     break;
    4405                 }
    4406                 RTTestFailed(g_hTest, "RTPathAbs(%s) failed: %Rrc\n", ValueUnion.psz, rc);
    4407                 return RTTestSummaryAndDestroy(g_hTest);
     4393                pszDir = ValueUnion.psz;
     4394                break;
     4395
     4396            case 'r':
     4397                g_fRelativeDir = true;
     4398                break;
    44084399
    44094400            case 's':
     
    46174608        }
    46184609    }
     4610
     4611    /*
     4612     * Populate g_szDir.
     4613     */
     4614    if (!g_fRelativeDir)
     4615        rc = RTPathAbs(pszDir, g_szDir, sizeof(g_szDir) - FSPERF_MAX_NEEDED_PATH);
     4616    else
     4617        rc = RTStrCopy(g_szDir, sizeof(g_szDir) - FSPERF_MAX_NEEDED_PATH, pszDir);
     4618    if (RT_FAILURE(rc))
     4619    {
     4620        RTTestFailed(g_hTest, "%s(%s) failed: %Rrc\n", g_fRelativeDir ? "RTStrCopy" : "RTAbsPath", pszDir, rc);
     4621        return RTTestSummaryAndDestroy(g_hTest);
     4622    }
     4623    RTPathEnsureTrailingSeparator(g_szDir, sizeof(g_szDir));
     4624    g_cchDir = strlen(g_szDir);
    46194625
    46204626    /*
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