Module: wine Branch: master Commit: 34446f8cb66036dd3cd0083a558eafd351317150 URL: https://gitlab.winehq.org/wine/wine/-/commit/34446f8cb66036dd3cd0083a558eafd...
Author: Brendan McGrath bmcgrath@codeweavers.com Date: Tue May 28 12:24:24 2024 +1000
kernel32/tests: Test error code when FindFirstFileA uses file as directory.
---
dlls/kernel32/tests/file.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
diff --git a/dlls/kernel32/tests/file.c b/dlls/kernel32/tests/file.c index 02625140702..9e5c1e4c594 100644 --- a/dlls/kernel32/tests/file.c +++ b/dlls/kernel32/tests/file.c @@ -2715,6 +2715,7 @@ static void test_FindFirstFileA(void) char buffer[5] = "C:\"; char buffer2[100]; char nonexistent[MAX_PATH]; + BOOL found = FALSE;
/* try FindFirstFileA on "C:" */ buffer[0] = get_windows_drive(); @@ -2746,10 +2747,32 @@ static void test_FindFirstFileA(void) ok( FindNextFileA( handle, &data ), "FindNextFile failed\n" ); ok( !strcmp( data.cFileName, ".." ), "FindNextFile should return '..' as second entry\n" ); while (FindNextFileA( handle, &data )) + { ok ( strcmp( data.cFileName, "." ) && strcmp( data.cFileName, ".." ), "FindNextFile shouldn't return '%s'\n", data.cFileName ); + if (!found && (data.dwFileAttributes == FILE_ATTRIBUTE_NORMAL || + data.dwFileAttributes == FILE_ATTRIBUTE_ARCHIVE)) + { + GetWindowsDirectoryA( buffer2, sizeof(buffer2) ); + strcat(buffer2, "\"); + strcat(buffer2, data.cFileName); + strcat(buffer2, "\*"); + found = TRUE; + } + } ok ( FindClose(handle) == TRUE, "Failed to close handle %s\n", buffer2 );
+ ok ( found, "Windows dir should not be empty\n" ); + if (found) + { + SetLastError( 0xdeadbeef ); + handle = FindFirstFileA(buffer2, &data); + err = GetLastError(); + ok ( handle == INVALID_HANDLE_VALUE, "FindFirstFile on %s should fail\n", buffer2 ); + todo_wine + ok ( err == ERROR_DIRECTORY, "Bad Error number %x\n", err ); + } + /* try FindFirstFileA on "C:\foo" */ SetLastError( 0xdeadbeaf ); if (!GetTempFileNameA( buffer, "foo", 0, nonexistent ))