Changeset 66038 in vbox for trunk/src/VBox/HostServices
- Timestamp:
- Mar 10, 2017 3:18:45 PM (8 years ago)
- Location:
- trunk/src/VBox/HostServices/SharedFolders
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/SharedFolders/testcase/tstSharedFolderService.cpp
r66014 r66038 37 37 #include <iprt/stream.h> 38 38 #include <iprt/test.h> 39 #include <iprt/string.h> 40 #include <iprt/utf16.h> 39 41 40 42 #include "teststubs.h" … … 116 118 * Stub functions and data * 117 119 *********************************************************************************************************************************/ 120 static bool g_fFailIfNotLowercase = false; 118 121 119 122 static PRTDIR g_testRTDirClosepDir; … … 134 137 /* RTPrintf("%s: pszPath=%s, fMode=0x%llx\n", __PRETTY_FUNCTION__, pszPath, 135 138 LLUIFY(fMode)); */ 139 if (g_fFailIfNotLowercase && !RTStrIsLowerCased(strpbrk(pszPath, "/\\"))) 140 return VERR_FILE_NOT_FOUND; 136 141 ARRAY_FROM_PATH(testRTDirCreatePath, pszPath); 137 142 return 0; … … 139 144 140 145 static char testRTDirOpenName[256]; 146 static struct TESTDIRHANDLE 147 { 148 int iEntry; 149 int iDir; 150 } g_aTestDirHandles[4]; 151 static int g_iNextDirHandle = 0; 141 152 static PRTDIR testRTDirOpenpDir; 142 153 … … 144 155 { 145 156 /* RTPrintf("%s: pszPath=%s\n", __PRETTY_FUNCTION__, pszPath); */ 157 if (g_fFailIfNotLowercase && !RTStrIsLowerCased(strpbrk(pszPath, "/\\"))) 158 return VERR_FILE_NOT_FOUND; 146 159 ARRAY_FROM_PATH(testRTDirOpenName, pszPath); 147 160 *ppDir = testRTDirOpenpDir; 148 161 testRTDirOpenpDir = 0; 162 if (!*ppDir && g_fFailIfNotLowercase) 163 *ppDir = (PRTDIR)&g_aTestDirHandles[g_iNextDirHandle++ % RT_ELEMENTS(g_aTestDirHandles)]; 164 if (*ppDir) 165 { 166 struct TESTDIRHANDLE *pRealDir = (struct TESTDIRHANDLE *)*ppDir; 167 pRealDir->iEntry = 0; 168 pRealDir->iDir = 0; 169 const char *pszSlash = pszPath - 1; 170 while ((pszSlash = strpbrk(pszSlash + 1, "\\/")) != NULL) 171 pRealDir->iDir += 1; 172 /*RTPrintf("opendir %s = %d \n", pszPath, pRealDir->iDir);*/ 173 } 149 174 return VINF_SUCCESS; 150 175 } … … 154 179 { 155 180 /* RTPrintf("%s: pszPath=%s\n", __PRETTY_FUNCTION__, pszPath); */ 181 if (g_fFailIfNotLowercase && !RTStrIsLowerCased(strpbrk(pszPath, "/\\"))) 182 return VERR_FILE_NOT_FOUND; 156 183 ARRAY_FROM_PATH(testRTDirOpenName, pszPath); 157 184 *ppDir = testRTDirOpenpDir; 158 185 testRTDirOpenpDir = 0; 186 if (!*ppDir && g_fFailIfNotLowercase) 187 *ppDir = (PRTDIR)&g_aTestDirHandles[g_iNextDirHandle++ % RT_ELEMENTS(g_aTestDirHandles)]; 188 if (*ppDir) 189 { 190 struct TESTDIRHANDLE *pRealDir = (struct TESTDIRHANDLE *)*ppDir; 191 pRealDir->iEntry = 0; 192 pRealDir->iDir = 0; 193 const char *pszSlash = pszPath - 1; 194 while ((pszSlash = strpbrk(pszSlash + 1, "\\/")) != NULL) 195 pRealDir->iDir += 1; 196 pRealDir->iDir -= 1; 197 /*RTPrintf("openfiltered %s = %d\n", pszPath, pRealDir->iDir);*/ 198 } 159 199 return VINF_SUCCESS; 160 200 } … … 177 217 extern int testRTDirRemove(const char *pszPath) 178 218 { 179 RT_NOREF1(pszPath); 219 if (g_fFailIfNotLowercase && !RTStrIsLowerCased(strpbrk(pszPath, "/\\"))) 220 return VERR_FILE_NOT_FOUND; 180 221 RTPrintf("%s\n", __PRETTY_FUNCTION__); 181 222 return 0; … … 192 233 LLUIFY(enmAdditionalAttribs), LLUIFY(fFlags)); */ 193 234 g_testRTDirReadExDir = pDir; 235 if (g_fFailIfNotLowercase && pDir) 236 { 237 struct TESTDIRHANDLE *pRealDir = (struct TESTDIRHANDLE *)pDir; 238 if (pRealDir->iDir == 2) /* /test/mapping/ */ 239 { 240 if (pRealDir->iEntry == 0) 241 { 242 pRealDir->iEntry++; 243 RT_ZERO(*pDirEntry); 244 pDirEntry->Info.Attr.fMode = RTFS_TYPE_DIRECTORY | RTFS_DOS_DIRECTORY | RTFS_UNIX_IROTH | RTFS_UNIX_IXOTH; 245 pDirEntry->cbName = 4; 246 pDirEntry->cwcShortName = 4; 247 strcpy(pDirEntry->szName, "test"); 248 RTUtf16CopyAscii(pDirEntry->wszShortName, RT_ELEMENTS(pDirEntry->wszShortName), "test"); 249 /*RTPrintf("readdir: 'test'\n");*/ 250 return VINF_SUCCESS; 251 } 252 } 253 else if (pRealDir->iDir == 3) /* /test/mapping/test/ */ 254 { 255 if (pRealDir->iEntry == 0) 256 { 257 pRealDir->iEntry++; 258 RT_ZERO(*pDirEntry); 259 pDirEntry->Info.Attr.fMode = RTFS_TYPE_FILE | RTFS_DOS_NT_NORMAL | RTFS_UNIX_IROTH | RTFS_UNIX_IXOTH; 260 pDirEntry->cbName = 4; 261 pDirEntry->cwcShortName = 4; 262 strcpy(pDirEntry->szName, "file"); 263 RTUtf16CopyAscii(pDirEntry->wszShortName, RT_ELEMENTS(pDirEntry->wszShortName), "file"); 264 /*RTPrintf("readdir: 'file'\n");*/ 265 return VINF_SUCCESS; 266 } 267 } 268 /*else RTPrintf("%s: iDir=%d\n", pRealDir->iDir);*/ 269 } 194 270 return VERR_NO_MORE_FILES; 195 271 } … … 226 302 extern int testRTFileDelete(const char *pszFilename) 227 303 { 228 RT_NOREF1(pszFilename); 304 if (g_fFailIfNotLowercase && !RTStrIsLowerCased(strpbrk(pszFilename, "/\\"))) 305 return VERR_FILE_NOT_FOUND; 229 306 RTPrintf("%s\n", __PRETTY_FUNCTION__); 230 307 return 0; … … 267 344 ARRAY_FROM_PATH(testRTFileOpenName, pszFilename); 268 345 testRTFileOpenFlags = fOpen; 346 if (g_fFailIfNotLowercase && !RTStrIsLowerCased(strpbrk(pszFilename, "/\\"))) 347 return VERR_FILE_NOT_FOUND; 269 348 *pFile = testRTFileOpenpFile; 270 349 testRTFileOpenpFile = 0; … … 408 487 extern int testRTPathQueryInfoEx(const char *pszPath, PRTFSOBJINFO pObjInfo, RTFSOBJATTRADD enmAdditionalAttribs, uint32_t fFlags) 409 488 { 410 RT_NOREF 3(pszPath,enmAdditionalAttribs, fFlags);489 RT_NOREF2(enmAdditionalAttribs, fFlags); 411 490 /* RTPrintf("%s: pszPath=%s, enmAdditionalAttribs=0x%x, fFlags=0x%x\n", 412 491 __PRETTY_FUNCTION__, pszPath, (unsigned) enmAdditionalAttribs, 413 492 (unsigned) fFlags); */ 493 if (g_fFailIfNotLowercase && !RTStrIsLowerCased(strpbrk(pszPath, "/\\"))) 494 return VERR_FILE_NOT_FOUND; 414 495 RT_ZERO(*pObjInfo); 415 496 return VINF_SUCCESS; … … 419 500 { 420 501 RT_NOREF2(pszSymlink, fDelete); 502 if (g_fFailIfNotLowercase && !RTStrIsLowerCased(strpbrk(pszSymlink, "/\\"))) 503 return VERR_FILE_NOT_FOUND; 421 504 RTPrintf("%s\n", __PRETTY_FUNCTION__); 422 505 return 0; … … 425 508 extern int testRTSymlinkRead(const char *pszSymlink, char *pszTarget, size_t cbTarget, uint32_t fRead) 426 509 { 510 if (g_fFailIfNotLowercase && !RTStrIsLowerCased(strpbrk(pszSymlink, "/\\"))) 511 return VERR_FILE_NOT_FOUND; 427 512 RT_NOREF4(pszSymlink, pszTarget, cbTarget, fRead); 428 513 RTPrintf("%s\n", __PRETTY_FUNCTION__); … … 525 610 VBOXHGCMSVCHELPERS *psvcHelpers, 526 611 const char *pcszFolderName, 527 const char *pcszMapping) 612 const char *pcszMapping, 613 bool fCaseSensitive = true) 528 614 { 529 615 VBOXHGCMSVCPARM aParms[RT_MAX(SHFL_CPARMS_ADD_MAPPING, … … 553 639 aParms[1].setUInt32(0); /* root */ 554 640 aParms[2].setUInt32('/'); /* delimiter */ 555 aParms[3].setUInt32( 1); /* case sensitive */641 aParms[3].setUInt32(fCaseSensitive); 556 642 psvcTable->pfnCall(psvcTable->pvService, &callHandle, 0, 557 643 psvcTable->pvService, SHFL_FN_MAP_FOLDER, … … 767 853 } 768 854 769 void testCreate DirSimple(RTTEST hTest)855 void testCreateFileSimpleCaseInsensitive(RTTEST hTest) 770 856 { 771 857 VBOXHGCMSVCFNTABLE svcTable; 772 858 VBOXHGCMSVCHELPERS svcHelpers; 773 859 SHFLROOT Root; 774 PRTDIR pcDir = (PRTDIR)0x10000; 860 const RTFILE hcFile = (RTFILE) 0x10000; 861 SHFLCREATERESULT Result; 862 int rc; 863 864 g_fFailIfNotLowercase = true; 865 866 RTTestSub(hTest, "Create file case insensitive"); 867 Root = initWithWritableMapping(hTest, &svcTable, &svcHelpers, 868 "/test/mapping", "testname", false /*fCaseSensitive*/); 869 testRTFileOpenpFile = hcFile; 870 rc = createFile(&svcTable, Root, "/TesT/FilE", SHFL_CF_ACCESS_READ, NULL, 871 &Result); 872 RTTEST_CHECK_RC_OK(hTest, rc); 873 874 RTTEST_CHECK_MSG(hTest, 875 !strcmp(&testRTFileOpenName[RTPATH_STYLE == RTPATH_STR_F_STYLE_DOS ? 2 : 0], 876 "/test/mapping/test/file"), 877 (hTest, "pszFilename=%s\n", &testRTFileOpenName[RTPATH_STYLE == RTPATH_STR_F_STYLE_DOS ? 2 : 0])); 878 RTTEST_CHECK_MSG(hTest, testRTFileOpenFlags == 0x181, 879 (hTest, "fOpen=%llu\n", LLUIFY(testRTFileOpenFlags))); 880 RTTEST_CHECK_MSG(hTest, Result == SHFL_FILE_CREATED, 881 (hTest, "Result=%d\n", (int) Result)); 882 unmapAndRemoveMapping(hTest, &svcTable, Root, "testname"); 883 AssertReleaseRC(svcTable.pfnDisconnect(NULL, 0, svcTable.pvService)); 884 RTTestGuardedFree(hTest, svcTable.pvService); 885 RTTEST_CHECK_MSG(hTest, g_testRTFileCloseFile == hcFile, 886 (hTest, "File=%u\n", (uintptr_t)g_testRTFileCloseFile)); 887 888 g_fFailIfNotLowercase = false; 889 } 890 891 void testCreateDirSimple(RTTEST hTest) 892 { 893 VBOXHGCMSVCFNTABLE svcTable; 894 VBOXHGCMSVCHELPERS svcHelpers; 895 SHFLROOT Root; 896 PRTDIR pDir = (PRTDIR)&g_aTestDirHandles[g_iNextDirHandle++ % RT_ELEMENTS(g_aTestDirHandles)]; 775 897 SHFLCREATERESULT Result; 776 898 int rc; … … 779 901 Root = initWithWritableMapping(hTest, &svcTable, &svcHelpers, 780 902 "/test/mapping", "testname"); 781 testRTDirOpenpDir = p cDir;903 testRTDirOpenpDir = pDir; 782 904 rc = createFile(&svcTable, Root, "test/dir", 783 905 SHFL_CF_DIRECTORY | SHFL_CF_ACCESS_READ, NULL, &Result); … … 796 918 AssertReleaseRC(svcTable.pfnDisconnect(NULL, 0, svcTable.pvService)); 797 919 RTTestGuardedFree(hTest, svcTable.pvService); 798 RTTEST_CHECK_MSG(hTest, g_testRTDirClosepDir == p cDir, (hTest, "pDir=%p\n", g_testRTDirClosepDir));920 RTTEST_CHECK_MSG(hTest, g_testRTDirClosepDir == pDir, (hTest, "pDir=%p\n", g_testRTDirClosepDir)); 799 921 } 800 922 … … 896 1018 VBOXHGCMSVCHELPERS svcHelpers; 897 1019 SHFLROOT Root; 898 PRTDIR p cDir = (PRTDIR)0x10000;1020 PRTDIR pDir = (PRTDIR)&g_aTestDirHandles[g_iNextDirHandle++ % RT_ELEMENTS(g_aTestDirHandles)]; 899 1021 SHFLHANDLE Handle; 900 1022 SHFLDIRINFO DirInfo; … … 905 1027 Root = initWithWritableMapping(hTest, &svcTable, &svcHelpers, 906 1028 "/test/mapping", "testname"); 907 testRTDirOpenpDir = p cDir;1029 testRTDirOpenpDir = pDir; 908 1030 rc = createFile(&svcTable, Root, "test/dir", 909 1031 SHFL_CF_DIRECTORY | SHFL_CF_ACCESS_READ, &Handle, NULL); … … 912 1034 &DirInfo, sizeof(DirInfo), 0, &cFiles); 913 1035 RTTEST_CHECK_RC(hTest, rc, VERR_NO_MORE_FILES); 914 RTTEST_CHECK_MSG(hTest, g_testRTDirReadExDir == p cDir, (hTest, "Dir=%p\n", g_testRTDirReadExDir));1036 RTTEST_CHECK_MSG(hTest, g_testRTDirReadExDir == pDir, (hTest, "Dir=%p\n", g_testRTDirReadExDir)); 915 1037 RTTEST_CHECK_MSG(hTest, cFiles == 0, 916 1038 (hTest, "cFiles=%llu\n", LLUIFY(cFiles))); … … 918 1040 AssertReleaseRC(svcTable.pfnDisconnect(NULL, 0, svcTable.pvService)); 919 1041 RTTestGuardedFree(hTest, svcTable.pvService); 920 RTTEST_CHECK_MSG(hTest, g_testRTDirClosepDir == p cDir, (hTest, "pDir=%p\n", g_testRTDirClosepDir));1042 RTTEST_CHECK_MSG(hTest, g_testRTDirClosepDir == pDir, (hTest, "pDir=%p\n", g_testRTDirClosepDir)); 921 1043 } 922 1044 … … 966 1088 VBOXHGCMSVCHELPERS svcHelpers; 967 1089 SHFLROOT Root; 968 const PRTDIR p cDir = (PRTDIR) 0x10000;1090 const PRTDIR pDir = (PRTDIR)&g_aTestDirHandles[g_iNextDirHandle++ % RT_ELEMENTS(g_aTestDirHandles)]; 969 1091 const int64_t ccAtimeNano = 100000; 970 1092 SHFLFSOBJINFO Info; … … 975 1097 Root = initWithWritableMapping(hTest, &svcTable, &svcHelpers, 976 1098 "/test/mapping", "testname"); 977 testRTDirOpenpDir = p cDir;1099 testRTDirOpenpDir = pDir; 978 1100 rc = createFile(&svcTable, Root, "test/dir", 979 1101 SHFL_CF_DIRECTORY | SHFL_CF_ACCESS_READ, &Handle, NULL); … … 984 1106 &Info); 985 1107 RTTEST_CHECK_RC_OK(hTest, rc); 986 RTTEST_CHECK_MSG(hTest, g_testRTDirQueryInfoDir == p cDir, (hTest, "Dir=%p\n", g_testRTDirQueryInfoDir));1108 RTTEST_CHECK_MSG(hTest, g_testRTDirQueryInfoDir == pDir, (hTest, "Dir=%p\n", g_testRTDirQueryInfoDir)); 987 1109 RTTEST_CHECK_MSG(hTest, RTTimeSpecGetNano(&Info.AccessTime) == ccAtimeNano, 988 1110 (hTest, "ATime=%llu\n", … … 1000 1122 AssertReleaseRC(svcTable.pfnDisconnect(NULL, 0, svcTable.pvService)); 1001 1123 RTTestGuardedFree(hTest, svcTable.pvService); 1002 RTTEST_CHECK_MSG(hTest, g_testRTDirClosepDir == p cDir, (hTest, "pDir=%p\n", g_testRTDirClosepDir));1124 RTTEST_CHECK_MSG(hTest, g_testRTDirClosepDir == pDir, (hTest, "pDir=%p\n", g_testRTDirClosepDir)); 1003 1125 } 1004 1126 -
trunk/src/VBox/HostServices/SharedFolders/testcase/tstSharedFolderService.h
r62489 r66038 54 54 /* Sub-tests for testCreate(). */ 55 55 void testCreateFileSimple(RTTEST hTest); 56 void testCreateFileSimpleCaseInsensitive(RTTEST hTest); 56 57 void testCreateDirSimple(RTTEST hTest); 57 58 void testCreateBadParameters(RTTEST hTest); -
trunk/src/VBox/HostServices/SharedFolders/vbsf.cpp
r65999 r66038 812 812 /* Simple opening of an existing file. */ 813 813 testCreateFileSimple(hTest); 814 testCreateFileSimpleCaseInsensitive(hTest); 814 815 /* Simple opening of an existing directory. */ 815 816 /** @todo How do wildcards in the path name work? */
Note:
See TracChangeset
for help on using the changeset viewer.