VirtualBox

Ignore:
Timestamp:
Feb 12, 2019 1:44:35 PM (6 years ago)
Author:
vboxsync
Message:

tstSharedFolderService.cpp: Need to catch RTFileWriteAt and RTFileReadAt too now. bugref:9172

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostServices/SharedFolders/testcase/tstSharedFolderService.cpp

    r76553 r77276  
    414414}
    415415
     416extern int  testRTFileReadAt(RTFILE hFile, uint64_t offFile, void *pvBuf, size_t cbToRead, size_t *pcbRead)
     417{
     418    RT_NOREF1(hFile);
     419    RT_NOREF(offFile);
     420 /* RTPrintf("%s : File=%p, cbToRead=%llu\n", __PRETTY_FUNCTION__, File,
     421             LLUIFY(cbToRead)); */
     422    bufferFromPath(pvBuf, cbToRead, testRTFileReadData);
     423    if (pcbRead)
     424        *pcbRead = RT_MIN(cbToRead, strlen(testRTFileReadData) + 1);
     425    testRTFileReadData = 0;
     426    return VINF_SUCCESS;
     427}
     428
    416429extern int testRTFileSeek(RTFILE hFile, int64_t offSeek, unsigned uMethod, uint64_t *poffActual)
    417430{
     
    485498{
    486499    RT_NOREF2(File, cbToWrite);
     500 /* RTPrintf("%s: File=%p, pvBuf=%.*s, cbToWrite=%llu\n", __PRETTY_FUNCTION__,
     501             File, cbToWrite, (const char *)pvBuf, LLUIFY(cbToWrite)); */
     502    ARRAY_FROM_PATH(testRTFileWriteData, (const char *)pvBuf);
     503    if (pcbWritten)
     504        *pcbWritten = strlen(testRTFileWriteData) + 1;
     505    return VINF_SUCCESS;
     506}
     507
     508extern int  testRTFileWriteAt(RTFILE File, uint64_t offFile, const void *pvBuf, size_t cbToWrite, size_t *pcbWritten)
     509{
     510    RT_NOREF3(File, cbToWrite, offFile);
    487511 /* RTPrintf("%s: File=%p, pvBuf=%.*s, cbToWrite=%llu\n", __PRETTY_FUNCTION__,
    488512             File, cbToWrite, (const char *)pvBuf, LLUIFY(cbToWrite)); */
     
    861885    VBOXHGCMSVCHELPERS  svcHelpers;
    862886    SHFLROOT Root;
    863     const RTFILE hcFile = (RTFILE) 0x10000;
     887    const RTFILE hFile = (RTFILE) 0x10000;
    864888    SHFLCREATERESULT Result;
    865889    int rc;
     
    868892    Root = initWithWritableMapping(hTest, &svcTable, &svcHelpers,
    869893                                   "/test/mapping", "testname");
    870     testRTFileOpenpFile = hcFile;
     894    testRTFileOpenpFile = hFile;
    871895    rc = createFile(&svcTable, Root, "/test/file", SHFL_CF_ACCESS_READ, NULL,
    872896                    &Result);
     
    884908    AssertReleaseRC(svcTable.pfnUnload(NULL));
    885909    RTTestGuardedFree(hTest, svcTable.pvService);
    886     RTTEST_CHECK_MSG(hTest, g_testRTFileCloseFile == hcFile,
     910    RTTEST_CHECK_MSG(hTest, g_testRTFileCloseFile == hFile,
    887911                     (hTest, "File=%u\n", (uintptr_t)g_testRTFileCloseFile));
    888912}
     
    893917    VBOXHGCMSVCHELPERS  svcHelpers;
    894918    SHFLROOT Root;
    895     const RTFILE hcFile = (RTFILE) 0x10000;
     919    const RTFILE hFile = (RTFILE) 0x10000;
    896920    SHFLCREATERESULT Result;
    897921    int rc;
     
    902926    Root = initWithWritableMapping(hTest, &svcTable, &svcHelpers,
    903927                                   "/test/mapping", "testname", false /*fCaseSensitive*/);
    904     testRTFileOpenpFile = hcFile;
     928    testRTFileOpenpFile = hFile;
    905929    rc = createFile(&svcTable, Root, "/TesT/FilE", SHFL_CF_ACCESS_READ, NULL,
    906930                    &Result);
     
    919943    AssertReleaseRC(svcTable.pfnUnload(NULL));
    920944    RTTestGuardedFree(hTest, svcTable.pvService);
    921     RTTEST_CHECK_MSG(hTest, g_testRTFileCloseFile == hcFile,
     945    RTTEST_CHECK_MSG(hTest, g_testRTFileCloseFile == hFile,
    922946                     (hTest, "File=%u\n", (uintptr_t)g_testRTFileCloseFile));
    923947
     
    963987    VBOXHGCMSVCHELPERS  svcHelpers;
    964988    SHFLROOT Root;
    965     const RTFILE hcFile = (RTFILE) 0x10000;
     989    const RTFILE hFile = (RTFILE) 0x10000;
    966990    SHFLHANDLE Handle;
    967991    const char *pcszReadData = "Data to read";
    968     char acBuf[sizeof(pcszReadData) + 10];
     992    char achBuf[sizeof(pcszReadData) + 10];
    969993    uint32_t cbRead;
    970994    int rc;
     
    973997    Root = initWithWritableMapping(hTest, &svcTable, &svcHelpers,
    974998                                   "/test/mapping", "testname");
    975     testRTFileOpenpFile = hcFile;
     999    testRTFileOpenpFile = hFile;
    9761000    rc = createFile(&svcTable, Root, "/test/file", SHFL_CF_ACCESS_READ,
    9771001                    &Handle, NULL);
    9781002    RTTEST_CHECK_RC_OK(hTest, rc);
    9791003    testRTFileReadData = pcszReadData;
     1004    memset(achBuf, 'f', sizeof(achBuf));
    9801005    rc = readFile(&svcTable, Root, Handle, 0, (uint32_t)strlen(pcszReadData) + 1,
    981                   &cbRead, acBuf, (uint32_t)sizeof(acBuf));
     1006                  &cbRead, achBuf, (uint32_t)sizeof(achBuf));
    9821007    RTTEST_CHECK_RC_OK(hTest, rc);
    9831008    RTTEST_CHECK_MSG(hTest,
    984                      !strncmp(acBuf, pcszReadData, sizeof(acBuf)),
    985                      (hTest, "pvBuf=%.*s\n", sizeof(acBuf), acBuf));
     1009                     !strncmp(achBuf, pcszReadData, sizeof(achBuf)),
     1010                     (hTest, "pvBuf=%.*s Handle=%#RX64\n", sizeof(achBuf), achBuf, Handle));
    9861011    RTTEST_CHECK_MSG(hTest, cbRead == strlen(pcszReadData) + 1,
    9871012                     (hTest, "cbRead=%llu\n", LLUIFY(cbRead)));
    9881013    unmapAndRemoveMapping(hTest, &svcTable, Root, "testname");
    989     RTTEST_CHECK_MSG(hTest, g_testRTFileCloseFile == hcFile, (hTest, "File=%u\n", g_testRTFileCloseFile));
     1014    RTTEST_CHECK_MSG(hTest, g_testRTFileCloseFile == hFile, (hTest, "File=%u\n", g_testRTFileCloseFile));
    9901015    AssertReleaseRC(svcTable.pfnDisconnect(NULL, 0, svcTable.pvService));
    9911016    AssertReleaseRC(svcTable.pfnUnload(NULL));
     
    9981023    VBOXHGCMSVCHELPERS  svcHelpers;
    9991024    SHFLROOT Root;
    1000     const RTFILE hcFile = (RTFILE) 0x10000;
     1025    const RTFILE hFile = (RTFILE) 0x10000;
    10011026    SHFLHANDLE Handle;
    10021027    const char *pcszWrittenData = "Data to write";
     
    10081033    Root = initWithWritableMapping(hTest, &svcTable, &svcHelpers,
    10091034                                   "/test/mapping", "testname");
    1010     testRTFileOpenpFile = hcFile;
     1035    testRTFileOpenpFile = hFile;
    10111036    rc = createFile(&svcTable, Root, "/test/file", SHFL_CF_ACCESS_READ,
    10121037                    &Handle, NULL);
     
    10211046                     (hTest, "cbWritten=%llu\n", LLUIFY(cbWritten)));
    10221047    unmapAndRemoveMapping(hTest, &svcTable, Root, "testname");
    1023     RTTEST_CHECK_MSG(hTest, g_testRTFileCloseFile == hcFile, (hTest, "File=%u\n", g_testRTFileCloseFile));
     1048    RTTEST_CHECK_MSG(hTest, g_testRTFileCloseFile == hFile, (hTest, "File=%u\n", g_testRTFileCloseFile));
    10241049    AssertReleaseRC(svcTable.pfnDisconnect(NULL, 0, svcTable.pvService));
    10251050    AssertReleaseRC(svcTable.pfnUnload(NULL));
     
    10321057    VBOXHGCMSVCHELPERS  svcHelpers;
    10331058    SHFLROOT Root;
    1034     const RTFILE hcFile = (RTFILE) 0x10000;
     1059    const RTFILE hFile = (RTFILE) 0x10000;
    10351060    SHFLHANDLE Handle;
    10361061    int rc;
     
    10391064    Root = initWithWritableMapping(hTest, &svcTable, &svcHelpers,
    10401065                                   "/test/mapping", "testname");
    1041     testRTFileOpenpFile = hcFile;
     1066    testRTFileOpenpFile = hFile;
    10421067    rc = createFile(&svcTable, Root, "/test/file", SHFL_CF_ACCESS_READ,
    10431068                    &Handle, NULL);
     
    10451070    rc = flushFile(&svcTable, Root, Handle);
    10461071    RTTEST_CHECK_RC_OK(hTest, rc);
    1047     RTTEST_CHECK_MSG(hTest, g_testRTFileFlushFile == hcFile, (hTest, "File=%u\n", g_testRTFileFlushFile));
     1072    RTTEST_CHECK_MSG(hTest, g_testRTFileFlushFile == hFile, (hTest, "File=%u\n", g_testRTFileFlushFile));
    10481073    unmapAndRemoveMapping(hTest, &svcTable, Root, "testname");
    10491074    AssertReleaseRC(svcTable.pfnDisconnect(NULL, 0, svcTable.pvService));
    10501075    AssertReleaseRC(svcTable.pfnUnload(NULL));
    10511076    RTTestGuardedFree(hTest, svcTable.pvService);
    1052     RTTEST_CHECK_MSG(hTest, g_testRTFileCloseFile == hcFile, (hTest, "File=%u\n", g_testRTFileCloseFile));
     1077    RTTEST_CHECK_MSG(hTest, g_testRTFileCloseFile == hFile, (hTest, "File=%u\n", g_testRTFileCloseFile));
    10531078}
    10541079
     
    10921117    VBOXHGCMSVCHELPERS  svcHelpers;
    10931118    SHFLROOT Root;
    1094     const RTFILE hcFile = (RTFILE) 0x10000;
     1119    const RTFILE hFile = (RTFILE) 0x10000;
    10951120    const uint32_t fMode = 0660;
    10961121    SHFLFSOBJINFO Info;
     
    11011126                                   "/test/mapping", "testname");
    11021127    SHFLHANDLE Handle = SHFL_HANDLE_NIL;
    1103     testRTFileOpenpFile = hcFile;
     1128    testRTFileOpenpFile = hFile;
    11041129    rc = createFile(&svcTable, Root, "/test/file", SHFL_CF_ACCESS_READ,
    11051130                    &Handle, NULL);
     
    11111136                       &Info);
    11121137    RTTEST_CHECK_RC_OK(hTest, rc);
    1113     RTTEST_CHECK_MSG(hTest, g_testRTFileQueryInfoFile == hcFile, (hTest, "File=%u\n", g_testRTFileQueryInfoFile));
     1138    RTTEST_CHECK_MSG(hTest, g_testRTFileQueryInfoFile == hFile, (hTest, "File=%u\n", g_testRTFileQueryInfoFile));
    11141139    RTTEST_CHECK_MSG(hTest, Info.Attr.fMode == fMode,
    11151140                     (hTest, "cbObject=%llu\n", LLUIFY(Info.cbObject)));
     
    11251150    AssertReleaseRC(svcTable.pfnUnload(NULL));
    11261151    RTTestGuardedFree(hTest, svcTable.pvService);
    1127     RTTEST_CHECK_MSG(hTest, g_testRTFileCloseFile == hcFile, (hTest, "File=%u\n", g_testRTFileCloseFile));
     1152    RTTEST_CHECK_MSG(hTest, g_testRTFileCloseFile == hFile, (hTest, "File=%u\n", g_testRTFileCloseFile));
    11281153}
    11291154
     
    11761201    VBOXHGCMSVCHELPERS  svcHelpers;
    11771202    SHFLROOT Root;
    1178     const RTFILE hcFile = (RTFILE) 0x10000;
     1203    const RTFILE hFile = (RTFILE) 0x10000;
    11791204    const int64_t ccAtimeNano = 100000;
    11801205    SHFLFSOBJINFO Info;
     
    11851210    Root = initWithWritableMapping(hTest, &svcTable, &svcHelpers,
    11861211                                   "/test/mapping", "testname");
    1187     testRTFileOpenpFile = hcFile;
     1212    testRTFileOpenpFile = hFile;
    11881213    rc = createFile(&svcTable, Root, "/test/file", SHFL_CF_ACCESS_READ,
    11891214                    &Handle, NULL);
     
    11941219                       &Info);
    11951220    RTTEST_CHECK_RC_OK(hTest, rc);
    1196     RTTEST_CHECK_MSG(hTest, g_testRTFileQueryInfoFile == hcFile, (hTest, "File=%u\n", g_testRTFileQueryInfoFile));
     1221    RTTEST_CHECK_MSG(hTest, g_testRTFileQueryInfoFile == hFile, (hTest, "File=%u\n", g_testRTFileQueryInfoFile));
    11971222    RTTEST_CHECK_MSG(hTest, RTTimeSpecGetNano(&Info.AccessTime) == ccAtimeNano,
    11981223                     (hTest, "ATime=%llu\n",
     
    12111236    AssertReleaseRC(svcTable.pfnUnload(NULL));
    12121237    RTTestGuardedFree(hTest, svcTable.pvService);
    1213     RTTEST_CHECK_MSG(hTest, g_testRTFileCloseFile == hcFile, (hTest, "File=%u\n", g_testRTFileCloseFile));
     1238    RTTEST_CHECK_MSG(hTest, g_testRTFileCloseFile == hFile, (hTest, "File=%u\n", g_testRTFileCloseFile));
    12141239}
    12151240
     
    12191244    VBOXHGCMSVCHELPERS  svcHelpers;
    12201245    SHFLROOT Root;
    1221     const RTFILE hcFile = (RTFILE) 0x10000;
     1246    const RTFILE hFile = (RTFILE) 0x10000;
    12221247    const RTFOFF cbNew = 50000;
    12231248    SHFLFSOBJINFO Info;
     
    12281253    Root = initWithWritableMapping(hTest, &svcTable, &svcHelpers,
    12291254                                   "/test/mapping", "testname");
    1230     testRTFileOpenpFile = hcFile;
     1255    testRTFileOpenpFile = hFile;
    12311256    rc = createFile(&svcTable, Root, "/test/file", SHFL_CF_ACCESS_READ,
    12321257                    &Handle, NULL);
     
    12371262                       sizeof(Info), &Info);
    12381263    RTTEST_CHECK_RC_OK(hTest, rc);
    1239     RTTEST_CHECK_MSG(hTest, g_testRTFileSetSizeFile == hcFile, (hTest, "File=%u\n", g_testRTFileSetSizeFile));
     1264    RTTEST_CHECK_MSG(hTest, g_testRTFileSetSizeFile == hFile, (hTest, "File=%u\n", g_testRTFileSetSizeFile));
    12401265    RTTEST_CHECK_MSG(hTest, testRTFileSetSizeSize == cbNew,
    12411266                     (hTest, "Size=%llu\n", LLUIFY(testRTFileSetSizeSize)));
     
    12441269    AssertReleaseRC(svcTable.pfnUnload(NULL));
    12451270    RTTestGuardedFree(hTest, svcTable.pvService);
    1246     RTTEST_CHECK_MSG(hTest, g_testRTFileCloseFile == hcFile, (hTest, "File=%u\n", g_testRTFileCloseFile));
     1271    RTTEST_CHECK_MSG(hTest, g_testRTFileCloseFile == hFile, (hTest, "File=%u\n", g_testRTFileCloseFile));
    12471272}
    12481273
     
    12521277    VBOXHGCMSVCHELPERS  svcHelpers;
    12531278    SHFLROOT Root;
    1254     const RTFILE hcFile = (RTFILE) 0x10000;
     1279    const RTFILE hFile = (RTFILE) 0x10000;
    12551280    const int64_t offLock = 50000;
    12561281    const uint64_t cbLock = 4000;
     
    12611286    Root = initWithWritableMapping(hTest, &svcTable, &svcHelpers,
    12621287                                   "/test/mapping", "testname");
    1263     testRTFileOpenpFile = hcFile;
     1288    testRTFileOpenpFile = hFile;
    12641289    rc = createFile(&svcTable, Root, "/test/file", SHFL_CF_ACCESS_READ,
    12651290                    &Handle, NULL);
     
    12681293    RTTEST_CHECK_RC_OK(hTest, rc);
    12691294#ifdef RT_OS_WINDOWS  /* Locking is a no-op elsewhere. */
    1270     RTTEST_CHECK_MSG(hTest, g_testRTFileLockFile == hcFile, (hTest, "File=%u\n", g_testRTFileLockFile));
     1295    RTTEST_CHECK_MSG(hTest, g_testRTFileLockFile == hFile, (hTest, "File=%u\n", g_testRTFileLockFile));
    12711296    RTTEST_CHECK_MSG(hTest, testRTFileLockfLock == 0,
    12721297                     (hTest, "fLock=%u\n", testRTFileLockfLock));
     
    12791304    RTTEST_CHECK_RC_OK(hTest, rc);
    12801305#ifdef RT_OS_WINDOWS
    1281     RTTEST_CHECK_MSG(hTest, g_testRTFileUnlockFile == hcFile, (hTest, "File=%u\n", g_testRTFileUnlockFile));
     1306    RTTEST_CHECK_MSG(hTest, g_testRTFileUnlockFile == hFile, (hTest, "File=%u\n", g_testRTFileUnlockFile));
    12821307    RTTEST_CHECK_MSG(hTest, testRTFileUnlockOffset == offLock,
    12831308                     (hTest, "Offs=%llu\n",
     
    12901315    AssertReleaseRC(svcTable.pfnUnload(NULL));
    12911316    RTTestGuardedFree(hTest, svcTable.pvService);
    1292     RTTEST_CHECK_MSG(hTest, g_testRTFileCloseFile == hcFile, (hTest, "File=%u\n", g_testRTFileCloseFile));
     1317    RTTEST_CHECK_MSG(hTest, g_testRTFileCloseFile == hFile, (hTest, "File=%u\n", g_testRTFileCloseFile));
    12931318}
    12941319
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