Changeset 77276 in vbox for trunk/src/VBox/HostServices/SharedFolders/testcase
- Timestamp:
- Feb 12, 2019 1:44:35 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/SharedFolders/testcase/tstSharedFolderService.cpp
r76553 r77276 414 414 } 415 415 416 extern 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 416 429 extern int testRTFileSeek(RTFILE hFile, int64_t offSeek, unsigned uMethod, uint64_t *poffActual) 417 430 { … … 485 498 { 486 499 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 508 extern int testRTFileWriteAt(RTFILE File, uint64_t offFile, const void *pvBuf, size_t cbToWrite, size_t *pcbWritten) 509 { 510 RT_NOREF3(File, cbToWrite, offFile); 487 511 /* RTPrintf("%s: File=%p, pvBuf=%.*s, cbToWrite=%llu\n", __PRETTY_FUNCTION__, 488 512 File, cbToWrite, (const char *)pvBuf, LLUIFY(cbToWrite)); */ … … 861 885 VBOXHGCMSVCHELPERS svcHelpers; 862 886 SHFLROOT Root; 863 const RTFILE h cFile = (RTFILE) 0x10000;887 const RTFILE hFile = (RTFILE) 0x10000; 864 888 SHFLCREATERESULT Result; 865 889 int rc; … … 868 892 Root = initWithWritableMapping(hTest, &svcTable, &svcHelpers, 869 893 "/test/mapping", "testname"); 870 testRTFileOpenpFile = h cFile;894 testRTFileOpenpFile = hFile; 871 895 rc = createFile(&svcTable, Root, "/test/file", SHFL_CF_ACCESS_READ, NULL, 872 896 &Result); … … 884 908 AssertReleaseRC(svcTable.pfnUnload(NULL)); 885 909 RTTestGuardedFree(hTest, svcTable.pvService); 886 RTTEST_CHECK_MSG(hTest, g_testRTFileCloseFile == h cFile,910 RTTEST_CHECK_MSG(hTest, g_testRTFileCloseFile == hFile, 887 911 (hTest, "File=%u\n", (uintptr_t)g_testRTFileCloseFile)); 888 912 } … … 893 917 VBOXHGCMSVCHELPERS svcHelpers; 894 918 SHFLROOT Root; 895 const RTFILE h cFile = (RTFILE) 0x10000;919 const RTFILE hFile = (RTFILE) 0x10000; 896 920 SHFLCREATERESULT Result; 897 921 int rc; … … 902 926 Root = initWithWritableMapping(hTest, &svcTable, &svcHelpers, 903 927 "/test/mapping", "testname", false /*fCaseSensitive*/); 904 testRTFileOpenpFile = h cFile;928 testRTFileOpenpFile = hFile; 905 929 rc = createFile(&svcTable, Root, "/TesT/FilE", SHFL_CF_ACCESS_READ, NULL, 906 930 &Result); … … 919 943 AssertReleaseRC(svcTable.pfnUnload(NULL)); 920 944 RTTestGuardedFree(hTest, svcTable.pvService); 921 RTTEST_CHECK_MSG(hTest, g_testRTFileCloseFile == h cFile,945 RTTEST_CHECK_MSG(hTest, g_testRTFileCloseFile == hFile, 922 946 (hTest, "File=%u\n", (uintptr_t)g_testRTFileCloseFile)); 923 947 … … 963 987 VBOXHGCMSVCHELPERS svcHelpers; 964 988 SHFLROOT Root; 965 const RTFILE h cFile = (RTFILE) 0x10000;989 const RTFILE hFile = (RTFILE) 0x10000; 966 990 SHFLHANDLE Handle; 967 991 const char *pcszReadData = "Data to read"; 968 char ac Buf[sizeof(pcszReadData) + 10];992 char achBuf[sizeof(pcszReadData) + 10]; 969 993 uint32_t cbRead; 970 994 int rc; … … 973 997 Root = initWithWritableMapping(hTest, &svcTable, &svcHelpers, 974 998 "/test/mapping", "testname"); 975 testRTFileOpenpFile = h cFile;999 testRTFileOpenpFile = hFile; 976 1000 rc = createFile(&svcTable, Root, "/test/file", SHFL_CF_ACCESS_READ, 977 1001 &Handle, NULL); 978 1002 RTTEST_CHECK_RC_OK(hTest, rc); 979 1003 testRTFileReadData = pcszReadData; 1004 memset(achBuf, 'f', sizeof(achBuf)); 980 1005 rc = readFile(&svcTable, Root, Handle, 0, (uint32_t)strlen(pcszReadData) + 1, 981 &cbRead, ac Buf, (uint32_t)sizeof(acBuf));1006 &cbRead, achBuf, (uint32_t)sizeof(achBuf)); 982 1007 RTTEST_CHECK_RC_OK(hTest, rc); 983 1008 RTTEST_CHECK_MSG(hTest, 984 !strncmp(ac Buf, 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)); 986 1011 RTTEST_CHECK_MSG(hTest, cbRead == strlen(pcszReadData) + 1, 987 1012 (hTest, "cbRead=%llu\n", LLUIFY(cbRead))); 988 1013 unmapAndRemoveMapping(hTest, &svcTable, Root, "testname"); 989 RTTEST_CHECK_MSG(hTest, g_testRTFileCloseFile == h cFile, (hTest, "File=%u\n", g_testRTFileCloseFile));1014 RTTEST_CHECK_MSG(hTest, g_testRTFileCloseFile == hFile, (hTest, "File=%u\n", g_testRTFileCloseFile)); 990 1015 AssertReleaseRC(svcTable.pfnDisconnect(NULL, 0, svcTable.pvService)); 991 1016 AssertReleaseRC(svcTable.pfnUnload(NULL)); … … 998 1023 VBOXHGCMSVCHELPERS svcHelpers; 999 1024 SHFLROOT Root; 1000 const RTFILE h cFile = (RTFILE) 0x10000;1025 const RTFILE hFile = (RTFILE) 0x10000; 1001 1026 SHFLHANDLE Handle; 1002 1027 const char *pcszWrittenData = "Data to write"; … … 1008 1033 Root = initWithWritableMapping(hTest, &svcTable, &svcHelpers, 1009 1034 "/test/mapping", "testname"); 1010 testRTFileOpenpFile = h cFile;1035 testRTFileOpenpFile = hFile; 1011 1036 rc = createFile(&svcTable, Root, "/test/file", SHFL_CF_ACCESS_READ, 1012 1037 &Handle, NULL); … … 1021 1046 (hTest, "cbWritten=%llu\n", LLUIFY(cbWritten))); 1022 1047 unmapAndRemoveMapping(hTest, &svcTable, Root, "testname"); 1023 RTTEST_CHECK_MSG(hTest, g_testRTFileCloseFile == h cFile, (hTest, "File=%u\n", g_testRTFileCloseFile));1048 RTTEST_CHECK_MSG(hTest, g_testRTFileCloseFile == hFile, (hTest, "File=%u\n", g_testRTFileCloseFile)); 1024 1049 AssertReleaseRC(svcTable.pfnDisconnect(NULL, 0, svcTable.pvService)); 1025 1050 AssertReleaseRC(svcTable.pfnUnload(NULL)); … … 1032 1057 VBOXHGCMSVCHELPERS svcHelpers; 1033 1058 SHFLROOT Root; 1034 const RTFILE h cFile = (RTFILE) 0x10000;1059 const RTFILE hFile = (RTFILE) 0x10000; 1035 1060 SHFLHANDLE Handle; 1036 1061 int rc; … … 1039 1064 Root = initWithWritableMapping(hTest, &svcTable, &svcHelpers, 1040 1065 "/test/mapping", "testname"); 1041 testRTFileOpenpFile = h cFile;1066 testRTFileOpenpFile = hFile; 1042 1067 rc = createFile(&svcTable, Root, "/test/file", SHFL_CF_ACCESS_READ, 1043 1068 &Handle, NULL); … … 1045 1070 rc = flushFile(&svcTable, Root, Handle); 1046 1071 RTTEST_CHECK_RC_OK(hTest, rc); 1047 RTTEST_CHECK_MSG(hTest, g_testRTFileFlushFile == h cFile, (hTest, "File=%u\n", g_testRTFileFlushFile));1072 RTTEST_CHECK_MSG(hTest, g_testRTFileFlushFile == hFile, (hTest, "File=%u\n", g_testRTFileFlushFile)); 1048 1073 unmapAndRemoveMapping(hTest, &svcTable, Root, "testname"); 1049 1074 AssertReleaseRC(svcTable.pfnDisconnect(NULL, 0, svcTable.pvService)); 1050 1075 AssertReleaseRC(svcTable.pfnUnload(NULL)); 1051 1076 RTTestGuardedFree(hTest, svcTable.pvService); 1052 RTTEST_CHECK_MSG(hTest, g_testRTFileCloseFile == h cFile, (hTest, "File=%u\n", g_testRTFileCloseFile));1077 RTTEST_CHECK_MSG(hTest, g_testRTFileCloseFile == hFile, (hTest, "File=%u\n", g_testRTFileCloseFile)); 1053 1078 } 1054 1079 … … 1092 1117 VBOXHGCMSVCHELPERS svcHelpers; 1093 1118 SHFLROOT Root; 1094 const RTFILE h cFile = (RTFILE) 0x10000;1119 const RTFILE hFile = (RTFILE) 0x10000; 1095 1120 const uint32_t fMode = 0660; 1096 1121 SHFLFSOBJINFO Info; … … 1101 1126 "/test/mapping", "testname"); 1102 1127 SHFLHANDLE Handle = SHFL_HANDLE_NIL; 1103 testRTFileOpenpFile = h cFile;1128 testRTFileOpenpFile = hFile; 1104 1129 rc = createFile(&svcTable, Root, "/test/file", SHFL_CF_ACCESS_READ, 1105 1130 &Handle, NULL); … … 1111 1136 &Info); 1112 1137 RTTEST_CHECK_RC_OK(hTest, rc); 1113 RTTEST_CHECK_MSG(hTest, g_testRTFileQueryInfoFile == h cFile, (hTest, "File=%u\n", g_testRTFileQueryInfoFile));1138 RTTEST_CHECK_MSG(hTest, g_testRTFileQueryInfoFile == hFile, (hTest, "File=%u\n", g_testRTFileQueryInfoFile)); 1114 1139 RTTEST_CHECK_MSG(hTest, Info.Attr.fMode == fMode, 1115 1140 (hTest, "cbObject=%llu\n", LLUIFY(Info.cbObject))); … … 1125 1150 AssertReleaseRC(svcTable.pfnUnload(NULL)); 1126 1151 RTTestGuardedFree(hTest, svcTable.pvService); 1127 RTTEST_CHECK_MSG(hTest, g_testRTFileCloseFile == h cFile, (hTest, "File=%u\n", g_testRTFileCloseFile));1152 RTTEST_CHECK_MSG(hTest, g_testRTFileCloseFile == hFile, (hTest, "File=%u\n", g_testRTFileCloseFile)); 1128 1153 } 1129 1154 … … 1176 1201 VBOXHGCMSVCHELPERS svcHelpers; 1177 1202 SHFLROOT Root; 1178 const RTFILE h cFile = (RTFILE) 0x10000;1203 const RTFILE hFile = (RTFILE) 0x10000; 1179 1204 const int64_t ccAtimeNano = 100000; 1180 1205 SHFLFSOBJINFO Info; … … 1185 1210 Root = initWithWritableMapping(hTest, &svcTable, &svcHelpers, 1186 1211 "/test/mapping", "testname"); 1187 testRTFileOpenpFile = h cFile;1212 testRTFileOpenpFile = hFile; 1188 1213 rc = createFile(&svcTable, Root, "/test/file", SHFL_CF_ACCESS_READ, 1189 1214 &Handle, NULL); … … 1194 1219 &Info); 1195 1220 RTTEST_CHECK_RC_OK(hTest, rc); 1196 RTTEST_CHECK_MSG(hTest, g_testRTFileQueryInfoFile == h cFile, (hTest, "File=%u\n", g_testRTFileQueryInfoFile));1221 RTTEST_CHECK_MSG(hTest, g_testRTFileQueryInfoFile == hFile, (hTest, "File=%u\n", g_testRTFileQueryInfoFile)); 1197 1222 RTTEST_CHECK_MSG(hTest, RTTimeSpecGetNano(&Info.AccessTime) == ccAtimeNano, 1198 1223 (hTest, "ATime=%llu\n", … … 1211 1236 AssertReleaseRC(svcTable.pfnUnload(NULL)); 1212 1237 RTTestGuardedFree(hTest, svcTable.pvService); 1213 RTTEST_CHECK_MSG(hTest, g_testRTFileCloseFile == h cFile, (hTest, "File=%u\n", g_testRTFileCloseFile));1238 RTTEST_CHECK_MSG(hTest, g_testRTFileCloseFile == hFile, (hTest, "File=%u\n", g_testRTFileCloseFile)); 1214 1239 } 1215 1240 … … 1219 1244 VBOXHGCMSVCHELPERS svcHelpers; 1220 1245 SHFLROOT Root; 1221 const RTFILE h cFile = (RTFILE) 0x10000;1246 const RTFILE hFile = (RTFILE) 0x10000; 1222 1247 const RTFOFF cbNew = 50000; 1223 1248 SHFLFSOBJINFO Info; … … 1228 1253 Root = initWithWritableMapping(hTest, &svcTable, &svcHelpers, 1229 1254 "/test/mapping", "testname"); 1230 testRTFileOpenpFile = h cFile;1255 testRTFileOpenpFile = hFile; 1231 1256 rc = createFile(&svcTable, Root, "/test/file", SHFL_CF_ACCESS_READ, 1232 1257 &Handle, NULL); … … 1237 1262 sizeof(Info), &Info); 1238 1263 RTTEST_CHECK_RC_OK(hTest, rc); 1239 RTTEST_CHECK_MSG(hTest, g_testRTFileSetSizeFile == h cFile, (hTest, "File=%u\n", g_testRTFileSetSizeFile));1264 RTTEST_CHECK_MSG(hTest, g_testRTFileSetSizeFile == hFile, (hTest, "File=%u\n", g_testRTFileSetSizeFile)); 1240 1265 RTTEST_CHECK_MSG(hTest, testRTFileSetSizeSize == cbNew, 1241 1266 (hTest, "Size=%llu\n", LLUIFY(testRTFileSetSizeSize))); … … 1244 1269 AssertReleaseRC(svcTable.pfnUnload(NULL)); 1245 1270 RTTestGuardedFree(hTest, svcTable.pvService); 1246 RTTEST_CHECK_MSG(hTest, g_testRTFileCloseFile == h cFile, (hTest, "File=%u\n", g_testRTFileCloseFile));1271 RTTEST_CHECK_MSG(hTest, g_testRTFileCloseFile == hFile, (hTest, "File=%u\n", g_testRTFileCloseFile)); 1247 1272 } 1248 1273 … … 1252 1277 VBOXHGCMSVCHELPERS svcHelpers; 1253 1278 SHFLROOT Root; 1254 const RTFILE h cFile = (RTFILE) 0x10000;1279 const RTFILE hFile = (RTFILE) 0x10000; 1255 1280 const int64_t offLock = 50000; 1256 1281 const uint64_t cbLock = 4000; … … 1261 1286 Root = initWithWritableMapping(hTest, &svcTable, &svcHelpers, 1262 1287 "/test/mapping", "testname"); 1263 testRTFileOpenpFile = h cFile;1288 testRTFileOpenpFile = hFile; 1264 1289 rc = createFile(&svcTable, Root, "/test/file", SHFL_CF_ACCESS_READ, 1265 1290 &Handle, NULL); … … 1268 1293 RTTEST_CHECK_RC_OK(hTest, rc); 1269 1294 #ifdef RT_OS_WINDOWS /* Locking is a no-op elsewhere. */ 1270 RTTEST_CHECK_MSG(hTest, g_testRTFileLockFile == h cFile, (hTest, "File=%u\n", g_testRTFileLockFile));1295 RTTEST_CHECK_MSG(hTest, g_testRTFileLockFile == hFile, (hTest, "File=%u\n", g_testRTFileLockFile)); 1271 1296 RTTEST_CHECK_MSG(hTest, testRTFileLockfLock == 0, 1272 1297 (hTest, "fLock=%u\n", testRTFileLockfLock)); … … 1279 1304 RTTEST_CHECK_RC_OK(hTest, rc); 1280 1305 #ifdef RT_OS_WINDOWS 1281 RTTEST_CHECK_MSG(hTest, g_testRTFileUnlockFile == h cFile, (hTest, "File=%u\n", g_testRTFileUnlockFile));1306 RTTEST_CHECK_MSG(hTest, g_testRTFileUnlockFile == hFile, (hTest, "File=%u\n", g_testRTFileUnlockFile)); 1282 1307 RTTEST_CHECK_MSG(hTest, testRTFileUnlockOffset == offLock, 1283 1308 (hTest, "Offs=%llu\n", … … 1290 1315 AssertReleaseRC(svcTable.pfnUnload(NULL)); 1291 1316 RTTestGuardedFree(hTest, svcTable.pvService); 1292 RTTEST_CHECK_MSG(hTest, g_testRTFileCloseFile == h cFile, (hTest, "File=%u\n", g_testRTFileCloseFile));1317 RTTEST_CHECK_MSG(hTest, g_testRTFileCloseFile == hFile, (hTest, "File=%u\n", g_testRTFileCloseFile)); 1293 1318 } 1294 1319
Note:
See TracChangeset
for help on using the changeset viewer.