VirtualBox

Ignore:
Timestamp:
Apr 17, 2019 9:36:59 PM (6 years ago)
Author:
vboxsync
Message:

IPRT,FsPerf: Added RTDIR_F_NO_ABS_PATH and RTDIRRMREC_F_NO_ABS_PATH to help FsPerf work below PATH_MAX on linux. bugref:9172

File:
1 edited

Legend:

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

    r78180 r78186  
    12211221
    12221222
     1223/**
     1224 * Wrapper around RTDirOpen/RTDirOpenFiltered which takes g_fRelativeDir into
     1225 * account.
     1226 */
     1227DECL_FORCE_INLINE(int) fsPerfOpenDirWrap(PRTDIR phDir, const char *pszPath)
     1228{
     1229    if (!g_fRelativeDir)
     1230        return RTDirOpen(phDir, pszPath);
     1231    return RTDirOpenFiltered(phDir, pszPath, RTDIRFILTER_NONE, RTDIR_F_NO_ABS_PATH);
     1232}
     1233
     1234
    12231235DECL_FORCE_INLINE(int) fsPerfOpenClose(const char *pszDir)
    12241236{
    12251237    RTDIR hDir;
    1226     RTTESTI_CHECK_RC_RET(RTDirOpen(&hDir, pszDir), VINF_SUCCESS, rcCheck);
     1238    RTTESTI_CHECK_RC_RET(fsPerfOpenDirWrap(&hDir, pszDir), VINF_SUCCESS, rcCheck);
    12271239    RTTESTI_CHECK_RC(RTDirClose(hDir), VINF_SUCCESS);
    12281240    return VINF_SUCCESS;
     
    12381250     * Non-existing files.
    12391251     */
    1240     RTTESTI_CHECK_RC(RTDirOpen(&hDir, InEmptyDir(RT_STR_TUPLE("no-such-file"))), VERR_FILE_NOT_FOUND);
    1241     RTTESTI_CHECK_RC(RTDirOpen(&hDir, InEmptyDir(RT_STR_TUPLE("no-such-dir" RTPATH_SLASH_STR "no-such-file"))), FSPERF_VERR_PATH_NOT_FOUND);
    1242     RTTESTI_CHECK_RC(RTDirOpen(&hDir, InDir(RT_STR_TUPLE("known-file" RTPATH_SLASH_STR "no-such-file"))), VERR_PATH_NOT_FOUND);
     1252    RTTESTI_CHECK_RC(fsPerfOpenDirWrap(&hDir, InEmptyDir(RT_STR_TUPLE("no-such-file"))), VERR_FILE_NOT_FOUND);
     1253    RTTESTI_CHECK_RC(fsPerfOpenDirWrap(&hDir, InEmptyDir(RT_STR_TUPLE("no-such-dir" RTPATH_SLASH_STR "no-such-file"))), FSPERF_VERR_PATH_NOT_FOUND);
     1254    RTTESTI_CHECK_RC(fsPerfOpenDirWrap(&hDir, InDir(RT_STR_TUPLE("known-file" RTPATH_SLASH_STR "no-such-file"))), VERR_PATH_NOT_FOUND);
    12431255
    12441256    /*
     
    12461258     */
    12471259    g_szEmptyDir[g_cchEmptyDir] = '\0';
    1248     RTTESTI_CHECK_RC_RETV(RTDirOpen(&hDir, g_szEmptyDir), VINF_SUCCESS);
     1260    RTTESTI_CHECK_RC_RETV(fsPerfOpenDirWrap(&hDir, g_szEmptyDir), VINF_SUCCESS);
    12491261    RTTESTI_CHECK_RC(RTDirClose(hDir), VINF_SUCCESS);
    12501262
     
    12671279    RTDIR hDir;
    12681280    g_szEmptyDir[g_cchEmptyDir] = '\0';
    1269     RTTESTI_CHECK_RC_RET(RTDirOpen(&hDir, g_szEmptyDir), VINF_SUCCESS, rcCheck);
     1281    RTTESTI_CHECK_RC_RET(fsPerfOpenDirWrap(&hDir, g_szEmptyDir), VINF_SUCCESS, rcCheck);
    12701282
    12711283    RTDIRENTRY Entry;
     
    12821294{
    12831295    RTDIR hDir;
    1284     RTTESTI_CHECK_RC_RET(RTDirOpen(&hDir, InDir(RT_STR_TUPLE("manyfiles"))), VINF_SUCCESS, rcCheck);
     1296    RTTESTI_CHECK_RC_RET(fsPerfOpenDirWrap(&hDir, InDir(RT_STR_TUPLE("manyfiles"))), VINF_SUCCESS, rcCheck);
    12851297    uint32_t cLeft = g_cManyFiles + 2;
    12861298    for (;;)
     
    13101322     */
    13111323    g_szEmptyDir[g_cchEmptyDir] = '\0';
    1312     RTTESTI_CHECK_RC_RETV(RTDirOpen(&hDir, g_szEmptyDir), VINF_SUCCESS);
     1324    RTTESTI_CHECK_RC_RETV(fsPerfOpenDirWrap(&hDir, g_szEmptyDir), VINF_SUCCESS);
    13131325
    13141326    uint32_t   fDots = 0;
     
    13401352
    13411353        uint32_t cFiles = 0;
    1342         RTTESTI_CHECK_RC_RETV(RTDirOpen(&hDir, InDir(RT_STR_TUPLE("manyfiles"))), VINF_SUCCESS);
     1354        RTTESTI_CHECK_RC_RETV(fsPerfOpenDirWrap(&hDir, InDir(RT_STR_TUPLE("manyfiles"))), VINF_SUCCESS);
    13431355        for (;;)
    13441356        {
     
    46894701            /* Cleanup: */
    46904702            g_szDir[g_cchDir] = '\0';
    4691             rc = RTDirRemoveRecursive(g_szDir, RTDIRRMREC_F_CONTENT_AND_DIR);
     4703            rc = RTDirRemoveRecursive(g_szDir, RTDIRRMREC_F_CONTENT_AND_DIR | (g_fRelativeDir ? RTDIRRMREC_F_NO_ABS_PATH : 0));
    46924704            if (RT_FAILURE(rc))
    46934705                RTTestFailed(g_hTest, "RTDirRemoveRecursive(%s,) -> %Rrc\n", g_szDir, rc);
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