Something went wrong. Try again.
Reactos
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586/* * PROJECT: ReactOS api tests * LICENSE: GPLv2+ - See COPYING in the top level directory * PURPOSE: Tests for the Find*File*A/W APIs. * PROGRAMMER: Hermès BÉLUSCA - MAÏTO */
#include "precomp.h"#include <versionhelpers.h>
/* * NOTE: This test supposes the following requirements: * - There is a disk attached to the letter "C:" * - There is a Windows-like system installed in "C:\<installation_directory>" * which contains a sub-directory "system32" * - There is no sub-directory called "foobar" in "C:\". * * If one of these requirements is not fulfilled, one or more tests may fail. */
static CHAR OSDirA[MAX_PATH]; // OS directorystatic WCHAR OSDirW[MAX_PATH];static CHAR baseA[MAX_PATH]; // Current directorystatic WCHAR baseW[MAX_PATH];static CHAR selfnameA[MAX_PATH]; // Path to this executablestatic WCHAR selfnameW[MAX_PATH];static LPSTR exenameA; // Executable's namestatic LPWSTR exenameW;static INT myARGC;static LPSTR* myARGV;
/* * Fixes definition of Wine's ok_err */#ifdef ok_err#undef ok_err#endif
#define ok_err(error) \ ok_int(GetLastError(), error)
/* * Types of tests. Define them as macros so that calling them * into the code reports the actual line where they were called. */#define testType1_A(lpFileName, dwInitialError, hExpectedHandleValue, dwExpectedError, bExpectedNullFilename) \do { \ ZeroMemory(&fd, sizeof(fd)); \ SetLastError((dwInitialError)); \ h = FindFirstFileA((lpFileName), &fd); \ ok(h == (hExpectedHandleValue), "FindFirstFileA returned 0x%p, expected 0x%p\n", h, (hExpectedHandleValue)); \ ok_err(dwExpectedError); \ if (bExpectedNullFilename) \ ok(fd.cFileName[0] == 0, "fd.cFileName != \"\"\n"); \ else \ ok(fd.cFileName[0] != 0, "fd.cFileName == \"\"\n"); \ FindClose(h); \} while (0)
#define testType1_W(lpFileName, dwInitialError, hExpectedHandleValue, dwExpectedError, bExpectedNullFilename) \do { \ ZeroMemory(&fd, sizeof(fd)); \ SetLastError((dwInitialError)); \ h = FindFirstFileW((lpFileName), &fd); \ ok(h == (hExpectedHandleValue), "FindFirstFileW returned 0x%p, expected 0x%p\n", h, (hExpectedHandleValue)); \ ok_err(dwExpectedError); \ if (bExpectedNullFilename) \ ok(fd.cFileName[0] == 0, "fd.cFileName != \"\"\n"); \ else \ ok(fd.cFileName[0] != 0, "fd.cFileName == \"\"\n"); \ FindClose(h); \} while (0)
#define testType2_A(lpFileName, dwInitialError, hUnexpectedHandleValue, dwExpectedError) \do { \ ZeroMemory(&fd, sizeof(fd)); \ SetLastError((dwInitialError)); \ h = FindFirstFileA((lpFileName), &fd); \ ok(h != (hUnexpectedHandleValue), "FindFirstFileA returned 0x%p\n", h); \ ok_err(dwExpectedError); \ ok(fd.cFileName[0] != 0, "fd.cFileName == \"\"\n"); \ FindClose(h); \} while (0)
#define testType2_W(lpFileName, dwInitialError, hUnexpectedHandleValue, dwExpectedError) \do { \ ZeroMemory(&fd, sizeof(fd)); \ SetLastError((dwInitialError)); \ h = FindFirstFileW((lpFileName), &fd); \ ok(h != (hUnexpectedHandleValue), "FindFirstFileW returned 0x%p\n", h); \ ok_err(dwExpectedError); \ ok(fd.cFileName[0] != 0, "fd.cFileName == \"\"\n"); \ FindClose(h); \} while (0)
#define testType3_A(lpFileName, fInfoLevelId, fSearchOp, lpSearchFilter, dwAdditionalFlags, dwInitialError, hUnexpectedHandleValue, dwExpectedError) \do { \ ZeroMemory(&fd, sizeof(fd)); \ SetLastError((dwInitialError)); \ h = FindFirstFileExA((lpFileName), (fInfoLevelId), &fd, (fSearchOp), (lpSearchFilter), (dwAdditionalFlags)); \ ok(h != (hUnexpectedHandleValue), "FindFirstFileExA returned 0x%p\n", h); \ ok_err(dwExpectedError); \ ok(fd.cFileName[0] != 0, "fd.cFileName == \"\"\n"); \ FindClose(h); \} while (0)
#define testType3_W(lpFileName, fInfoLevelId, fSearchOp, lpSearchFilter, dwAdditionalFlags, dwInitialError, hUnexpectedHandleValue, dwExpectedError) \do { \ ZeroMemory(&fd, sizeof(fd)); \ SetLastError((dwInitialError)); \ h = FindFirstFileExW((lpFileName), (fInfoLevelId), &fd, (fSearchOp), (lpSearchFilter), (dwAdditionalFlags)); \ ok(h != (hUnexpectedHandleValue), "FindFirstFileExW returned 0x%p\n", h); \ ok_err(dwExpectedError); \ ok(fd.cFileName[0] != 0, "fd.cFileName == \"\"\n"); \ FindClose(h); \} while (0)
static void Test_FindFirstFileA(void){ CHAR CurrentDirectory[MAX_PATH]; CHAR Buffer[MAX_PATH]; WIN32_FIND_DATAA fd; HANDLE h;
/* Save the current directory */ GetCurrentDirectoryA(_countof(CurrentDirectory), CurrentDirectory);
/*** Tests for the root directory - root directory ***/ /* Modify the current directory */ SetCurrentDirectoryA("C:\\");
testType1_A("C:", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE);
testType1_A("C:\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); testType1_A("C:\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); testType2_A("C:\\*", 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef);
testType1_A("\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); testType1_A("\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_INVALID_NAME, TRUE); testType2_A("\\*", 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef);
/* Restore the old current directory */ SetCurrentDirectoryA(CurrentDirectory);/*****************************************************/
/*** Tests for the root directory - long directory ***/ /* Modify the current directory */ SetCurrentDirectoryA(OSDirA); /* We expect here that OSDir is of the form: C:\OSDir */
testType2_A("C:", 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef);
testType1_A("C:\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); testType1_A("C:\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); testType2_A("C:\\*", 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef);
testType1_A("\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); testType1_A("\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_INVALID_NAME, TRUE); testType2_A("\\*", 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef);
/* Restore the old current directory */ SetCurrentDirectoryA(CurrentDirectory);/*****************************************************/
/*** Relative paths ***/ /* * NOTE: This test does not give the same results if you launch the app * from a root drive or from a long-form directory (of the form C:\dir). */ // testType2_A("..", 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef); // testType1_A("..", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE);/**********************/
/*** Relative paths - root directory ***/ /* Modify the current directory */ SetCurrentDirectoryA("C:\\");
testType1_A(".", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); testType1_A(".\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); testType1_A(".\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); testType2_A(".\\*", 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef);
testType1_A("..", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); testType1_A("..\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); testType1_A("..\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); testType2_A("..\\*", 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef);
/* Restore the old current directory */ SetCurrentDirectoryA(CurrentDirectory);/***************************************/
/*** Relative paths - long directory ***/ /* Modify the current directory */ SetCurrentDirectoryA(OSDirA); /* We expect here that OSDir is of the form: C:\OSDir */
testType2_A(".", 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef);
testType1_A(".\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); testType1_A(".\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); testType2_A(".\\*", 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef);
testType1_A("..", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE);
testType1_A("..\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); testType1_A("..\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); testType2_A("..\\*", 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef);
/* Restore the old current directory */ SetCurrentDirectoryA(CurrentDirectory);/****************************************/
/*** Unexisting path ***/ testType1_A("C:\\foobar", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); testType1_A("C:\\foobar\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); testType1_A("C:\\foobar\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); testType1_A("C:\\foobar\\*", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); testType1_A("C:\\foobar\\system32\\..\\*", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE);
/* Possibly a DOS device */ testType1_A("C:\\foobar\\nul", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); testType1_A("C:\\foobar\\nul\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); testType1_A("C:\\foobar\\nul\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); testType1_A("C:\\foobar\\nul\\*", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE);
testType1_A("C:\\foobar\\toto", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); testType1_A("C:\\foobar\\toto\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); testType1_A("C:\\foobar\\toto\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); testType1_A("C:\\foobar\\toto\\*", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE);
strcpy(Buffer, "C:\\foobar\\"); strcat(Buffer, exenameA); testType1_A(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE);
strcpy(Buffer, "C:\\foobar\\.\\"); strcat(Buffer, exenameA); testType1_A(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE);/***********************/
/*** Existing path ***/ strcpy(Buffer, OSDirA); testType2_A(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef);
strcpy(Buffer, OSDirA); strcat(Buffer, "\\"); testType1_A(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE);
strcpy(Buffer, OSDirA); strcat(Buffer, "\\\\"); testType1_A(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE);
strcpy(Buffer, OSDirA); strcat(Buffer, "\\*"); testType2_A(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef);
strcpy(Buffer, OSDirA); strcat(Buffer, "\\.\\*"); testType2_A(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef);
strcpy(Buffer, OSDirA); strcat(Buffer, "\\system32\\..\\*"); testType2_A(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef);
/* Possibly a DOS device */ strcpy(Buffer, OSDirA); strcat(Buffer, "\\nul"); testType1_A(Buffer, 0xdeadbeef, (HANDLE)0x00000001, 0xdeadbeef, FALSE);
strcpy(Buffer, OSDirA); strcat(Buffer, "\\nul\\"); testType1_A(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE);
strcpy(Buffer, OSDirA); strcat(Buffer, "\\nul\\\\"); testType1_A(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE);
strcpy(Buffer, OSDirA); strcat(Buffer, "\\nul\\*"); testType1_A(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE);
strcpy(Buffer, OSDirA); strcat(Buffer, "\\toto"); testType1_A(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE);
strcpy(Buffer, OSDirA); strcat(Buffer, "\\toto\\"); testType1_A(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE);
strcpy(Buffer, OSDirA); strcat(Buffer, "\\toto\\\\"); testType1_A(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE);
strcpy(Buffer, OSDirA); strcat(Buffer, "\\toto\\*"); testType1_A(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE);
// strcpy(Buffer, baseA); // strcat(Buffer, "\\"); // strcat(Buffer, exenameA); // testType2_A(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef);
// strcpy(Buffer, baseA); // strcat(Buffer, "\\.\\"); // strcat(Buffer, exenameA); // testType2_A(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef);/*********************/
return;}
static void Test_FindFirstFileW(void){ WCHAR CurrentDirectory[MAX_PATH]; WCHAR Buffer[MAX_PATH]; WIN32_FIND_DATAW fd; HANDLE h;
/* Save the current directory */ GetCurrentDirectoryW(_countof(CurrentDirectory), CurrentDirectory);
/*** Tests for the root directory - root directory ***/ /* Modify the current directory */ SetCurrentDirectoryW(L"C:\\");
testType1_W(L"C:", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE);
testType1_W(L"C:\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); testType1_W(L"C:\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); testType2_W(L"C:\\*", 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef);
testType1_W(L"\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); testType1_W(L"\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_INVALID_NAME, TRUE); testType2_W(L"\\*", 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef);
/* Restore the old current directory */ SetCurrentDirectoryW(CurrentDirectory);/*****************************************************/
/*** Tests for the root directory - long directory ***/ /* Modify the current directory */ SetCurrentDirectoryW(OSDirW); /* We expect here that OSDir is of the form: C:\OSDir */
testType2_W(L"C:", 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef);
testType1_W(L"C:\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); testType1_W(L"C:\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); testType2_W(L"C:\\*", 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef);
testType1_W(L"\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); testType1_W(L"\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_INVALID_NAME, TRUE); testType2_W(L"\\*", 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef);
/* Restore the old current directory */ SetCurrentDirectoryW(CurrentDirectory);/*****************************************************/
/*** Relative paths ***/ /* * NOTE: This test does not give the same results if you launch the app * from a root drive or from a long-form directory (of the form C:\dir). */ // testType2_W(L"..", 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef); // testType1_W(L"..", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE);/**********************/
/*** Relative paths - root directory ***/ /* Modify the current directory */ SetCurrentDirectoryW(L"C:\\");
testType1_W(L".", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); testType1_W(L".\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); testType1_W(L".\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); testType2_W(L".\\*", 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef);
testType1_W(L"..", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); testType1_W(L"..\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); testType1_W(L"..\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); testType2_W(L"..\\*", 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef);
/* Restore the old current directory */ SetCurrentDirectoryW(CurrentDirectory);/***************************************/
/*** Relative paths - long directory ***/ /* Modify the current directory */ SetCurrentDirectoryW(OSDirW); /* We expect here that OSDir is of the form: C:\OSDir */
testType2_W(L".", 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef);
testType1_W(L".\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); testType1_W(L".\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); testType2_W(L".\\*", 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef);
testType1_W(L"..", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE);
testType1_W(L"..\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); testType1_W(L"..\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); testType2_W(L"..\\*", 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef);
/* Restore the old current directory */ SetCurrentDirectoryW(CurrentDirectory);/****************************************/
/*** Unexisting path ***/ testType1_W(L"C:\\foobar", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE); testType1_W(L"C:\\foobar\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); testType1_W(L"C:\\foobar\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); testType1_W(L"C:\\foobar\\*", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); testType1_W(L"C:\\foobar\\system32\\..\\*", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE);
/* Possibly a DOS device */ testType1_W(L"C:\\foobar\\nul", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); testType1_W(L"C:\\foobar\\nul\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); testType1_W(L"C:\\foobar\\nul\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); testType1_W(L"C:\\foobar\\nul\\*", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE);
testType1_W(L"C:\\foobar\\toto", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); testType1_W(L"C:\\foobar\\toto\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); testType1_W(L"C:\\foobar\\toto\\\\", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE); testType1_W(L"C:\\foobar\\toto\\*", 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE);
wcscpy(Buffer, L"C:\\foobar\\"); wcscat(Buffer, exenameW); testType1_W(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE);
wcscpy(Buffer, L"C:\\foobar\\.\\"); wcscat(Buffer, exenameW); testType1_W(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE);/***********************/
/*** Existing path ***/ wcscpy(Buffer, OSDirW); testType2_W(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef);
wcscpy(Buffer, OSDirW); wcscat(Buffer, L"\\"); testType1_W(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE);
wcscpy(Buffer, OSDirW); wcscat(Buffer, L"\\\\"); testType1_W(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE);
wcscpy(Buffer, OSDirW); wcscat(Buffer, L"\\*"); testType2_W(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef);
wcscpy(Buffer, OSDirW); wcscat(Buffer, L"\\.\\*"); testType2_W(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef);
wcscpy(Buffer, OSDirW); wcscat(Buffer, L"\\system32\\..\\*"); testType2_W(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef);
/* Possibly a DOS device */ wcscpy(Buffer, OSDirW); wcscat(Buffer, L"\\nul"); testType1_W(Buffer, 0xdeadbeef, (HANDLE)0x00000001, 0xdeadbeef, FALSE);
wcscpy(Buffer, OSDirW); wcscat(Buffer, L"\\nul\\"); testType1_W(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE);
wcscpy(Buffer, OSDirW); wcscat(Buffer, L"\\nul\\\\"); testType1_W(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE);
wcscpy(Buffer, OSDirW); wcscat(Buffer, L"\\nul\\*"); testType1_W(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE);
wcscpy(Buffer, OSDirW); wcscat(Buffer, L"\\toto"); testType1_W(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_FILE_NOT_FOUND, TRUE);
wcscpy(Buffer, OSDirW); wcscat(Buffer, L"\\toto\\"); testType1_W(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE);
wcscpy(Buffer, OSDirW); wcscat(Buffer, L"\\toto\\\\"); testType1_W(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE);
wcscpy(Buffer, OSDirW); wcscat(Buffer, L"\\toto\\*"); testType1_W(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, ERROR_PATH_NOT_FOUND, TRUE);
// wcscpy(Buffer, baseW); // wcscat(Buffer, L"\\"); // wcscat(Buffer, exenameW); // testType2_W(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef);
// wcscpy(Buffer, baseW); // wcscat(Buffer, L"\\.\\"); // wcscat(Buffer, exenameW); // testType2_W(Buffer, 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef);/*********************/
return;}
static void Test_FindFirstFileExA(void){ CHAR CurrentDirectory[MAX_PATH]; WIN32_FIND_DATAA fd; HANDLE h;
/* Save the current directory */ GetCurrentDirectoryA(_countof(CurrentDirectory), CurrentDirectory); SetCurrentDirectoryA(OSDirA); /* We expect here that OSDir is of the form: C:\OSDir */
testType3_A(".", FindExInfoStandard, FindExSearchNameMatch, NULL, 0, 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef); testType3_A(".", FindExInfoStandard, FindExSearchNameMatch, "XXX", 0, 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef);
/* Restore the old current directory */ SetCurrentDirectoryA(CurrentDirectory);}
static void Test_FindFirstFileExW(void){ WCHAR CurrentDirectory[MAX_PATH]; WIN32_FIND_DATAW fd; HANDLE h;
/* Save the current directory */ GetCurrentDirectoryW(_countof(CurrentDirectory), CurrentDirectory); SetCurrentDirectoryW(OSDirW); /* We expect here that OSDir is of the form: C:\OSDir */
testType3_W(L".", FindExInfoStandard, FindExSearchNameMatch, NULL, 0, 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef); testType3_W(L".", FindExInfoStandard, FindExSearchNameMatch, L"XXX", 0, 0xdeadbeef, INVALID_HANDLE_VALUE, 0xdeadbeef);
/* Restore the old current directory */ SetCurrentDirectoryW(CurrentDirectory);}
static int init(void){ LPSTR p; size_t i;
myARGC = winetest_get_mainargs(&myARGV); if (!GetCurrentDirectoryA(_countof(baseA), baseA)) return 0; strcpy(selfnameA, myARGV[0]);
/* Strip the path of selfname */ if ((p = strrchr(selfnameA, '\\')) != NULL) exenameA = p + 1; else exenameA = selfnameA;
if ((p = strrchr(exenameA, '/')) != NULL) exenameA = p + 1;
if (!GetWindowsDirectoryA(OSDirA, _countof(OSDirA))) return 0;
/* Quick-and-dirty conversion ANSI --> UNICODE without the Win32 APIs */ for (i = 0 ; i <= strlen(baseA) ; ++i) { baseW[i] = (WCHAR)baseA[i]; } for (i = 0 ; i <= strlen(selfnameA) ; ++i) { selfnameW[i] = (WCHAR)selfnameA[i]; } exenameW = selfnameW + (exenameA - selfnameA); for (i = 0 ; i <= strlen(OSDirA) ; ++i) { OSDirW[i] = (WCHAR)OSDirA[i]; }
return 1;}
START_TEST(FindFiles){ int b = init(); ok(b, "Basic init of FindFiles test\n"); if (!b) return;
Test_FindFirstFileA(); Test_FindFirstFileW(); Test_FindFirstFileExA(); Test_FindFirstFileExW();}