1 /* 2 * PROJECT: ReactOS api tests 3 * LICENSE: GPLv2+ - See COPYING in the top level directory 4 * PURPOSE: Tests for the Find*File*A/W APIs. 5 * PROGRAMMER: Hermès BÉLUSCA - MAÏTO 6 */ 7 8 #include "precomp.h" 9 #include <versionhelpers.h> 10 11 /* 12 * NOTE: This test supposes the following requirements: 13 * - There is a disk attached to the letter "C:" 14 * - There is a Windows-like system installed in "C:\<installation_directory>" 15 * which contains a sub-directory "system32" 16 * - There is no sub-directory called "foobar" in "C:\". 17 * 18 * If one of these requirements is not fulfilled, one or more tests may fail. 19 */ 20 21 static CHAR OSDirA[MAX_PATH]; // OS directory 22 static WCHAR OSDirW[MAX_PATH]; 23 static CHAR baseA[MAX_PATH]; // Current directory 24 static WCHAR baseW[MAX_PATH]; 25 static CHAR selfnameA[MAX_PATH]; // Path to this executable 26 static WCHAR selfnameW[MAX_PATH]; 27 static LPSTR exenameA; // Executable's name 28 static LPWSTR exenameW; 29 static INT myARGC; 30 static LPSTR* myARGV; 31 32 33 /* 34 * Fixes definition of Wine's ok_err 35 */ 36 #ifdef ok_err 37 #undef ok_err 38 #endif 39 40 #define ok_err(error) \ 41 ok_int(GetLastError(), error) 42 43 44 /* 45 * Types of tests. Define them as macros so that calling them 46 * into the code reports the actual line where they were called. 47 */ 48 #define testType1_A(lpFileName, dwInitialError, hExpectedHandleValue, dwExpectedError, bExpectedNullFilename) \ 49 do { \ 50 ZeroMemory(&fd, sizeof(fd)); \ 51 SetLastError((dwInitialError)); \ 52 h = FindFirstFileA((lpFileName), &fd); \ 53 ok(h == (hExpectedHandleValue), "FindFirstFileA returned 0x%p, expected 0x%p\n", h, (hExpectedHandleValue)); \ 54 ok_err(dwExpectedError); \ 55 if (bExpectedNullFilename) \ 56 ok(fd.cFileName[0] == 0, "fd.cFileName != \"\"\n"); \ 57 else \ 58 ok(fd.cFileName[0] != 0, "fd.cFileName == \"\"\n"); \ 59 FindClose(h); \ 60 } while (0) 61 62 #define testType1_W(lpFileName, dwInitialError, hExpectedHandleValue, dwExpectedError, bExpectedNullFilename) \ 63 do { \ 64 ZeroMemory(&fd, sizeof(fd)); \ 65 SetLastError((dwInitialError)); \ 66 h = FindFirstFileW((lpFileName), &fd); \ 67 ok(h == (hExpectedHandleValue), "FindFirstFileW returned 0x%p, expected 0x%p\n", h, (hExpectedHandleValue)); \ 68 ok_err(dwExpectedError); \ 69 if (bExpectedNullFilename) \ 70 ok(fd.cFileName[0] == 0, "fd.cFileName != \"\"\n"); \ 71 else \ 72 ok(fd.cFileName[0] != 0, "fd.cFileName == \"\"\n"); \ 73 FindClose(h); \ 74 } while (0) 75 76 #define testType2_A(lpFileName, dwInitialError, hUnexpectedHandleValue, dwExpectedError) \ 77 do { \ 78 ZeroMemory(&fd, sizeof(fd)); \ 79 SetLastError((dwInitialError)); \ 80 h = FindFirstFileA((lpFileName), &fd); \ 81 ok(h != (hUnexpectedHandleValue), "FindFirstFileA returned 0x%p\n", h); \ 82 ok_err(dwExpectedError); \ 83 ok(fd.cFileName[0] != 0, "fd.cFileName == \"\"\n"); \ 84 FindClose(h); \ 85 } while (0) 86 87 #define testType2_W(lpFileName, dwInitialError, hUnexpectedHandleValue, dwExpectedError) \ 88 do { \ 89 ZeroMemory(&fd, sizeof(fd)); \ 90 SetLastError((dwInitialError)); \ 91 h = FindFirstFileW((lpFileName), &fd); \ 92 ok(h != (hUnexpectedHandleValue), "FindFirstFileW returned 0x%p\n", h); \ 93 ok_err(dwExpectedError); \ 94 ok(fd.cFileName[0] != 0, "fd.cFileName == \"\"\n"); \ 95 FindClose(h); \ 96 } while (0) 97 98 99 static void Test_FindFirstFileA(void) 100 { 101 CHAR CurrentDirectory[MAX_PATH]; 102 CHAR Buffer[MAX_PATH]; 103 WIN32_FIND_DATAA fd; 104 HANDLE h; 105 106 /* Save the current directory */ 107 GetCurrentDirectoryA(sizeof(CurrentDirectory) / sizeof(CHAR), CurrentDirectory); 108 109 /*** Tests for the root directory - root directory ***/ 110 /* Modify the current directory */ 111 SetCurrentDirectoryA("C:\\"); 112 113 testType1_A("C:", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); 114 115 testType1_A("C:\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); 116 testType1_A("C:\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); 117 testType2_A("C:\\*", 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef); 118 119 testType1_A("\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); 120 testType1_A("\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE, IsWindows7OrGreater() ? ERROR_INVALID_NAME : ERROR_BAD_NETPATH, TRUE); 121 testType2_A("\\*", 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef); 122 123 /* Restore the old current directory */ 124 SetCurrentDirectoryA(CurrentDirectory); 125 /*****************************************************/ 126 127 /*** Tests for the root directory - long directory ***/ 128 /* Modify the current directory */ 129 SetCurrentDirectoryA(OSDirA); /* We expect here that OSDir is of the form: C:\OSDir */ 130 131 testType2_A("C:", 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef); 132 133 testType1_A("C:\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); 134 testType1_A("C:\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); 135 testType2_A("C:\\*", 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef); 136 137 testType1_A("\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); 138 testType1_A("\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE, IsWindows7OrGreater() ? ERROR_INVALID_NAME : ERROR_BAD_NETPATH, TRUE); 139 testType2_A("\\*", 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef); 140 141 /* Restore the old current directory */ 142 SetCurrentDirectoryA(CurrentDirectory); 143 /*****************************************************/ 144 145 /*** Relative paths ***/ 146 /* 147 * NOTE: This test does not give the same results if you launch the app 148 * from a root drive or from a long-form directory (of the form C:\dir). 149 */ 150 // testType2_A("..", 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef); 151 // testType1_A("..", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); 152 /**********************/ 153 154 /*** Relative paths - root directory ***/ 155 /* Modify the current directory */ 156 SetCurrentDirectoryA("C:\\"); 157 158 testType1_A(".", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); 159 testType1_A(".\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); 160 testType1_A(".\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); 161 testType2_A(".\\*", 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef); 162 163 testType1_A("..", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); 164 testType1_A("..\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); 165 testType1_A("..\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); 166 testType2_A("..\\*", 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef); 167 168 /* Restore the old current directory */ 169 SetCurrentDirectoryA(CurrentDirectory); 170 /***************************************/ 171 172 /*** Relative paths - long directory ***/ 173 /* Modify the current directory */ 174 SetCurrentDirectoryA(OSDirA); /* We expect here that OSDir is of the form: C:\OSDir */ 175 176 testType2_A(".", 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef); 177 178 testType1_A(".\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); 179 testType1_A(".\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); 180 testType2_A(".\\*", 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef); 181 182 testType1_A("..", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); 183 184 testType1_A("..\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); 185 testType1_A("..\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); 186 testType2_A("..\\*", 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef); 187 188 /* Restore the old current directory */ 189 SetCurrentDirectoryA(CurrentDirectory); 190 /****************************************/ 191 192 /*** Unexisting path ***/ 193 testType1_A("C:\\foobar", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); 194 testType1_A("C:\\foobar\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); 195 testType1_A("C:\\foobar\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); 196 testType1_A("C:\\foobar\\*", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); 197 testType1_A("C:\\foobar\\system32\\..\\*", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); 198 199 /* Possibly a DOS device */ 200 testType1_A("C:\\foobar\\nul", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); 201 testType1_A("C:\\foobar\\nul\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); 202 testType1_A("C:\\foobar\\nul\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); 203 testType1_A("C:\\foobar\\nul\\*", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); 204 205 testType1_A("C:\\foobar\\toto", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); 206 testType1_A("C:\\foobar\\toto\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); 207 testType1_A("C:\\foobar\\toto\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); 208 testType1_A("C:\\foobar\\toto\\*", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); 209 210 strcpy(Buffer, "C:\\foobar\\"); 211 strcat(Buffer, exenameA); 212 testType1_A(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); 213 214 strcpy(Buffer, "C:\\foobar\\.\\"); 215 strcat(Buffer, exenameA); 216 testType1_A(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); 217 /***********************/ 218 219 /*** Existing path ***/ 220 strcpy(Buffer, OSDirA); 221 testType2_A(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef); 222 223 strcpy(Buffer, OSDirA); 224 strcat(Buffer, "\\"); 225 testType1_A(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); 226 227 strcpy(Buffer, OSDirA); 228 strcat(Buffer, "\\\\"); 229 testType1_A(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); 230 231 strcpy(Buffer, OSDirA); 232 strcat(Buffer, "\\*"); 233 testType2_A(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef); 234 235 strcpy(Buffer, OSDirA); 236 strcat(Buffer, "\\.\\*"); 237 testType2_A(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef); 238 239 strcpy(Buffer, OSDirA); 240 strcat(Buffer, "\\system32\\..\\*"); 241 testType2_A(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef); 242 243 /* Possibly a DOS device */ 244 strcpy(Buffer, OSDirA); 245 strcat(Buffer, "\\nul"); 246 testType1_A(Buffer, 0xdeadbeef, (HANDLE)0x00000001, 0xdeadbeef, FALSE); 247 248 strcpy(Buffer, OSDirA); 249 strcat(Buffer, "\\nul\\"); 250 testType1_A(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); 251 252 strcpy(Buffer, OSDirA); 253 strcat(Buffer, "\\nul\\\\"); 254 testType1_A(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); 255 256 strcpy(Buffer, OSDirA); 257 strcat(Buffer, "\\nul\\*"); 258 testType1_A(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); 259 260 strcpy(Buffer, OSDirA); 261 strcat(Buffer, "\\toto"); 262 testType1_A(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); 263 264 strcpy(Buffer, OSDirA); 265 strcat(Buffer, "\\toto\\"); 266 testType1_A(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); 267 268 strcpy(Buffer, OSDirA); 269 strcat(Buffer, "\\toto\\\\"); 270 testType1_A(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); 271 272 strcpy(Buffer, OSDirA); 273 strcat(Buffer, "\\toto\\*"); 274 testType1_A(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); 275 276 // strcpy(Buffer, baseA); 277 // strcat(Buffer, "\\"); 278 // strcat(Buffer, exenameA); 279 // testType2_A(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef); 280 281 // strcpy(Buffer, baseA); 282 // strcat(Buffer, "\\.\\"); 283 // strcat(Buffer, exenameA); 284 // testType2_A(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef); 285 /*********************/ 286 287 return; 288 } 289 290 static void Test_FindFirstFileW(void) 291 { 292 WCHAR CurrentDirectory[MAX_PATH]; 293 WCHAR Buffer[MAX_PATH]; 294 WIN32_FIND_DATAW fd; 295 HANDLE h; 296 297 /* Save the current directory */ 298 GetCurrentDirectoryW(sizeof(CurrentDirectory) / sizeof(WCHAR), CurrentDirectory); 299 300 /*** Tests for the root directory - root directory ***/ 301 /* Modify the current directory */ 302 SetCurrentDirectoryW(L"C:\\"); 303 304 testType1_W(L"C:", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); 305 306 testType1_W(L"C:\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); 307 testType1_W(L"C:\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); 308 testType2_W(L"C:\\*", 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef); 309 310 testType1_W(L"\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); 311 testType1_W(L"\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE, IsWindows7OrGreater() ? ERROR_INVALID_NAME : ERROR_BAD_NETPATH, TRUE); 312 testType2_W(L"\\*", 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef); 313 314 /* Restore the old current directory */ 315 SetCurrentDirectoryW(CurrentDirectory); 316 /*****************************************************/ 317 318 /*** Tests for the root directory - long directory ***/ 319 /* Modify the current directory */ 320 SetCurrentDirectoryW(OSDirW); /* We expect here that OSDir is of the form: C:\OSDir */ 321 322 testType2_W(L"C:", 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef); 323 324 testType1_W(L"C:\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); 325 testType1_W(L"C:\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); 326 testType2_W(L"C:\\*", 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef); 327 328 testType1_W(L"\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); 329 testType1_W(L"\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE, IsWindows7OrGreater() ? ERROR_INVALID_NAME : ERROR_BAD_NETPATH, TRUE); 330 testType2_W(L"\\*", 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef); 331 332 /* Restore the old current directory */ 333 SetCurrentDirectoryW(CurrentDirectory); 334 /*****************************************************/ 335 336 /*** Relative paths ***/ 337 /* 338 * NOTE: This test does not give the same results if you launch the app 339 * from a root drive or from a long-form directory (of the form C:\dir). 340 */ 341 // testType2_W(L"..", 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef); 342 // testType1_W(L"..", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); 343 /**********************/ 344 345 /*** Relative paths - root directory ***/ 346 /* Modify the current directory */ 347 SetCurrentDirectoryW(L"C:\\"); 348 349 testType1_W(L".", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); 350 testType1_W(L".\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); 351 testType1_W(L".\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); 352 testType2_W(L".\\*", 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef); 353 354 testType1_W(L"..", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); 355 testType1_W(L"..\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); 356 testType1_W(L"..\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); 357 testType2_W(L"..\\*", 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef); 358 359 /* Restore the old current directory */ 360 SetCurrentDirectoryW(CurrentDirectory); 361 /***************************************/ 362 363 /*** Relative paths - long directory ***/ 364 /* Modify the current directory */ 365 SetCurrentDirectoryW(OSDirW); /* We expect here that OSDir is of the form: C:\OSDir */ 366 367 testType2_W(L".", 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef); 368 369 testType1_W(L".\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); 370 testType1_W(L".\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); 371 testType2_W(L".\\*", 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef); 372 373 testType1_W(L"..", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); 374 375 testType1_W(L"..\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); 376 testType1_W(L"..\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); 377 testType2_W(L"..\\*", 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef); 378 379 /* Restore the old current directory */ 380 SetCurrentDirectoryW(CurrentDirectory); 381 /****************************************/ 382 383 /*** Unexisting path ***/ 384 testType1_W(L"C:\\foobar", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); 385 testType1_W(L"C:\\foobar\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); 386 testType1_W(L"C:\\foobar\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); 387 testType1_W(L"C:\\foobar\\*", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); 388 testType1_W(L"C:\\foobar\\system32\\..\\*", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); 389 390 /* Possibly a DOS device */ 391 testType1_W(L"C:\\foobar\\nul", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); 392 testType1_W(L"C:\\foobar\\nul\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); 393 testType1_W(L"C:\\foobar\\nul\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); 394 testType1_W(L"C:\\foobar\\nul\\*", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); 395 396 testType1_W(L"C:\\foobar\\toto", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); 397 testType1_W(L"C:\\foobar\\toto\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); 398 testType1_W(L"C:\\foobar\\toto\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); 399 testType1_W(L"C:\\foobar\\toto\\*", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); 400 401 wcscpy(Buffer, L"C:\\foobar\\"); 402 wcscat(Buffer, exenameW); 403 testType1_W(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); 404 405 wcscpy(Buffer, L"C:\\foobar\\.\\"); 406 wcscat(Buffer, exenameW); 407 testType1_W(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); 408 /***********************/ 409 410 /*** Existing path ***/ 411 wcscpy(Buffer, OSDirW); 412 testType2_W(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef); 413 414 wcscpy(Buffer, OSDirW); 415 wcscat(Buffer, L"\\"); 416 testType1_W(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); 417 418 wcscpy(Buffer, OSDirW); 419 wcscat(Buffer, L"\\\\"); 420 testType1_W(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); 421 422 wcscpy(Buffer, OSDirW); 423 wcscat(Buffer, L"\\*"); 424 testType2_W(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef); 425 426 wcscpy(Buffer, OSDirW); 427 wcscat(Buffer, L"\\.\\*"); 428 testType2_W(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef); 429 430 wcscpy(Buffer, OSDirW); 431 wcscat(Buffer, L"\\system32\\..\\*"); 432 testType2_W(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef); 433 434 /* Possibly a DOS device */ 435 wcscpy(Buffer, OSDirW); 436 wcscat(Buffer, L"\\nul"); 437 testType1_W(Buffer, 0xdeadbeef, (HANDLE)0x00000001, 0xdeadbeef, FALSE); 438 439 wcscpy(Buffer, OSDirW); 440 wcscat(Buffer, L"\\nul\\"); 441 testType1_W(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); 442 443 wcscpy(Buffer, OSDirW); 444 wcscat(Buffer, L"\\nul\\\\"); 445 testType1_W(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); 446 447 wcscpy(Buffer, OSDirW); 448 wcscat(Buffer, L"\\nul\\*"); 449 testType1_W(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); 450 451 wcscpy(Buffer, OSDirW); 452 wcscat(Buffer, L"\\toto"); 453 testType1_W(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); 454 455 wcscpy(Buffer, OSDirW); 456 wcscat(Buffer, L"\\toto\\"); 457 testType1_W(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); 458 459 wcscpy(Buffer, OSDirW); 460 wcscat(Buffer, L"\\toto\\\\"); 461 testType1_W(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); 462 463 wcscpy(Buffer, OSDirW); 464 wcscat(Buffer, L"\\toto\\*"); 465 testType1_W(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); 466 467 // wcscpy(Buffer, baseW); 468 // wcscat(Buffer, L"\\"); 469 // wcscat(Buffer, exenameW); 470 // testType2_W(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef); 471 472 // wcscpy(Buffer, baseW); 473 // wcscat(Buffer, L"\\.\\"); 474 // wcscat(Buffer, exenameW); 475 // testType2_W(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef); 476 /*********************/ 477 478 return; 479 } 480 481 482 static int init(void) 483 { 484 LPSTR p; 485 size_t i; 486 487 myARGC = winetest_get_mainargs(&myARGV); 488 if (!GetCurrentDirectoryA(sizeof(baseA)/sizeof(baseA[0]), baseA)) return 0; 489 strcpy(selfnameA, myARGV[0]); 490 491 /* Strip the path of selfname */ 492 if ((p = strrchr(selfnameA, '\\')) != NULL) 493 exenameA = p + 1; 494 else 495 exenameA = selfnameA; 496 497 if ((p = strrchr(exenameA, '/')) != NULL) 498 exenameA = p + 1; 499 500 if (!GetWindowsDirectoryA(OSDirA, sizeof(OSDirA)/sizeof(OSDirA[0]))) return 0; 501 502 /* Quick-and-dirty conversion ANSI --> UNICODE without the Win32 APIs */ 503 for (i = 0 ; i <= strlen(baseA) ; ++i) 504 { 505 baseW[i] = (WCHAR)baseA[i]; 506 } 507 for (i = 0 ; i <= strlen(selfnameA) ; ++i) 508 { 509 selfnameW[i] = (WCHAR)selfnameA[i]; 510 } 511 exenameW = selfnameW + (exenameA - selfnameA); 512 for (i = 0 ; i <= strlen(OSDirA) ; ++i) 513 { 514 OSDirW[i] = (WCHAR)OSDirA[i]; 515 } 516 517 return 1; 518 } 519 520 START_TEST(FindFiles) 521 { 522 int b = init(); 523 ok(b, "Basic init of FindFiles test\n"); 524 if (!b) return; 525 526 Test_FindFirstFileA(); 527 Test_FindFirstFileW(); 528 } 529