Changelog: - dlls/kernel/tests/directory.c - dlls/kernel/tests/file.c Add a few todo_wine tests with filenames with wildcards to the kernel32 tests. Wine currently does happily create wildcard filenames and directories, something which is forbidden under Win32. Tested under W2K to produce these error codes. Non-NT versions might differ in the returned error code but fail as well on those paths. - dlls/kernel/tests/process.c - dlls/kernel/tests/thread.c Remove <ntstatus.h> to allow compilation with MS PSDK headers. License: X11 Rolf Kalbermatter Index: dlls/kernel/tests/directory.c =================================================================== RCS file: /home/wine/wine/dlls/kernel/tests/directory.c,v retrieving revision 1.6 diff -u -r1.6 directory.c --- dlls/kernel/tests/directory.c 5 Sep 2003 23:08:36 -0000 1.6 +++ dlls/kernel/tests/directory.c 15 Sep 2003 20:34:46 -0000 @@ -192,6 +192,22 @@ ret = RemoveDirectoryA(tmpdir); ok(ret == TRUE, "RemoveDirectoryA should always succeed"); + + todo_wine { + lstrcatA(tmpdir, "?"); + ret = CreateDirectoryA(tmpdir, NULL); + ok(ret == FALSE && GetLastError() == ERROR_INVALID_NAME, + "CreateDirectoryA with ? wildcard name should fail, ret=%s error=%ld", + ret ? " True" : "False", GetLastError()); + ret = RemoveDirectoryA(tmpdir); + + tmpdir[lstrlenA(tmpdir) - 1] = '*'; + ret = CreateDirectoryA(tmpdir, NULL); + ok(ret == FALSE && GetLastError() == ERROR_INVALID_NAME, + "CreateDirectoryA with * wildcard name should fail, ret=%s error=%ld", + ret ? " True" : "False", GetLastError()); + ret = RemoveDirectoryA(tmpdir); + } } static void test_CreateDirectoryW(void) @@ -202,6 +218,7 @@ static const WCHAR tmp_dir_name[] = {'P','l','e','a','s','e',' ','R','e','m','o','v','e',' ','M','e',0}; static const WCHAR dotW[] = {'.',0}; static const WCHAR dotdotW[] = {'.','.',0}; + static const WCHAR questionW[] = {'?',0}; ret = CreateDirectoryW(NULL, NULL); if (!ret && GetLastError()==ERROR_CALL_NOT_IMPLEMENTED) @@ -238,6 +255,81 @@ ret = RemoveDirectoryW(tmpdir); ok(ret == TRUE, "RemoveDirectoryW should always succeed"); + + todo_wine { + lstrcatW(tmpdir, questionW); + ret = CreateDirectoryW(tmpdir, NULL); + ok(ret == FALSE && GetLastError() == ERROR_INVALID_NAME, + "CreateDirectoryW with ? wildcard name should fail with error 183, ret=%s error=%ld", + ret ? " True" : "False", GetLastError()); + ret = RemoveDirectoryW(tmpdir); + + tmpdir[lstrlenW(tmpdir) - 1] = '*'; + ret = CreateDirectoryW(tmpdir, NULL); + ok(ret == FALSE && GetLastError() == ERROR_INVALID_NAME, + "CreateDirectoryW with * wildcard name should fail with error 183, ret=%s error=%ld", + ret ? " True" : "False", GetLastError()); + ret = RemoveDirectoryW(tmpdir); + } +} + +static void test_RemoveDirectoryA(void) +{ + char tmpdir[MAX_PATH]; + BOOL ret; + + GetTempPathA(MAX_PATH, tmpdir); + lstrcatA(tmpdir, "Please Remove Me"); + ret = CreateDirectoryA(tmpdir, NULL); + ok(ret == TRUE, "CreateDirectoryA should always succeed"); + + ret = RemoveDirectoryA(tmpdir); + ok(ret == TRUE, "RemoveDirectoryA should always succeed"); + + todo_wine { + lstrcatA(tmpdir, "?"); + ret = RemoveDirectoryA(tmpdir); + ok(ret == FALSE && GetLastError() == ERROR_INVALID_NAME, + "RemoveDirectoryA with ? wildcard name should fail with error 183, ret=%s error=%ld", + ret ? " True" : "False", GetLastError()); + + tmpdir[lstrlenA(tmpdir) - 1] = '*'; + ret = RemoveDirectoryA(tmpdir); + ok(ret == FALSE && GetLastError() == ERROR_INVALID_NAME, + "RemoveDirectoryA with * wildcard name should fail with error 183, ret=%s error=%ld", + ret ? " True" : "False", GetLastError()); + } +} + +static void test_RemoveDirectoryW(void) +{ + WCHAR tmpdir[MAX_PATH]; + BOOL ret; + static const WCHAR tmp_dir_name[] = {'P','l','e','a','s','e',' ','R','e','m','o','v','e',' ','M','e',0}; + static const WCHAR questionW[] = {'?',0}; + + GetTempPathW(MAX_PATH, tmpdir); + lstrcatW(tmpdir, tmp_dir_name); + ret = CreateDirectoryW(tmpdir, NULL); + ok(ret == TRUE, "CreateDirectoryW should always succeed"); + + ret = RemoveDirectoryW(tmpdir); + ok(ret == TRUE, "RemoveDirectoryW should always succeed"); + + todo_wine { + lstrcatW(tmpdir, questionW); + ret = RemoveDirectoryW(tmpdir); + ok(ret == FALSE && GetLastError() == ERROR_INVALID_NAME, + "RemoveDirectoryW with wildcard should fail with error 183, ret=%s error=%ld", + ret ? " True" : "False", GetLastError()); + + tmpdir[lstrlenW(tmpdir) - 1] = '*'; + ret = RemoveDirectoryW(tmpdir); + ok(ret == FALSE && GetLastError() == ERROR_INVALID_NAME, + "RemoveDirectoryW with * wildcard name should fail with error 183, ret=%s error=%ld", + ret ? " True" : "False", GetLastError()); + } + } START_TEST(directory) @@ -250,4 +342,7 @@ test_CreateDirectoryA(); test_CreateDirectoryW(); + + test_RemoveDirectoryA(); + test_RemoveDirectoryW(); } Index: dlls/kernel/tests/file.c =================================================================== RCS file: /home/wine/wine/dlls/kernel/tests/file.c,v retrieving revision 1.19 diff -u -r1.19 file.c --- dlls/kernel/tests/file.c 5 Sep 2003 23:08:36 -0000 1.19 +++ dlls/kernel/tests/file.c 15 Sep 2003 20:34:46 -0000 @@ -28,7 +28,6 @@ #include "winbase.h" #include "winerror.h" - LPCSTR filename = "testfile.xxx"; LPCSTR sillytext = "en larvig liten text dx \033 gx hej 84 hej 4484 ! \001\033 bla bl\na.. bla bla." @@ -646,6 +645,109 @@ ret = DeleteFileW(emptyW); ok(!ret && GetLastError() == ERROR_PATH_NOT_FOUND, "DeleteFileW(\"\") returned ret=%d error=%ld",ret,GetLastError()); +} + +#define IsDotDir(x) ((x[0] == '.') && ((x[1] == 0) || ((x[1] == '.') && (x[2] == 0)))) + +void test_MoveFileA(void) +{ + char tempdir[MAX_PATH]; + char source[MAX_PATH], dest[MAX_PATH]; + static const char prefix[] = "pfx"; + DWORD ret; + + ret = GetTempPathA(MAX_PATH, tempdir); + ok(ret != 0, "GetTempPathA error %ld", GetLastError()); + ok(ret < MAX_PATH, "temp path should fit into MAX_PATH"); + + ret = GetTempFileNameA(tempdir, prefix, 0, source); + ok(ret != 0, "GetTempFileNameA error %ld", GetLastError()); + + ret = GetTempFileNameA(tempdir, prefix, 0, dest); + ok(ret != 0, "GetTempFileNameA error %ld", GetLastError()); + + ret = MoveFileA(source, dest); + ok(!ret && GetLastError() == ERROR_FILE_EXISTS, + "MoveFileA: unexpected error %ld\n", GetLastError()); + + ret = DeleteFileA(dest); + ok(ret, "DeleteFileA: error %ld\n", GetLastError()); + + ret = MoveFileA(source, dest); + ok(ret, "MoveFileA: failed, error %ld\n", GetLastError()); + + lstrcatA(tempdir, "Remove Me"); + ret = CreateDirectoryA(tempdir, NULL); + ok(ret == TRUE, "CreateDirectoryA failed"); + + lstrcpyA(source, dest); + lstrcpyA(dest, tempdir); + lstrcatA(dest, "\\wild?.*"); + ret = MoveFileA(source, dest); + todo_wine { + ok(!ret, "MoveFileA: shouldn't move to wildcard file"); + ok(GetLastError() == ERROR_INVALID_NAME, + "MoveFileA: with wildcards, unexpected error %ld\n", GetLastError()); + if (ret || (GetLastError() != ERROR_INVALID_NAME)) + { + WIN32_FIND_DATAA fd; + char temppath[MAX_PATH]; + HANDLE hFind; + + lstrcpyA(temppath, tempdir); + lstrcatA(temppath, "\\*.*"); + hFind = FindFirstFileA(temppath, &fd); + if (INVALID_HANDLE_VALUE != hFind) + { + LPSTR lpName; + do + { + lpName = fd.cAlternateFileName; + if (!lpName[0]) + lpName = fd.cFileName; + ok(!IsDotDir(lpName), "MoveFileA: wildcards file created!"); + } + while (FindNextFileA(hFind, &fd)); + FindClose(hFind); + } + } + } + + ret = DeleteFileA(source); + ok(ret, "DeleteFileA: error %ld\n", GetLastError()); + ret = DeleteFileA(dest); + ok(!ret, "DeleteFileA: error %ld\n", GetLastError()); + ret = RemoveDirectoryA(tempdir); + ok(ret, "DeleteDirectoryA: error %ld\n", GetLastError()); +} + +void test_MoveFileW(void) +{ + WCHAR temp_path[MAX_PATH]; + WCHAR source[MAX_PATH], dest[MAX_PATH]; + static const WCHAR prefix[] = {'p','f','x',0}; + DWORD ret; + + ret = GetTempPathW(MAX_PATH, temp_path); + if (ret==0 && GetLastError()==ERROR_CALL_NOT_IMPLEMENTED) + return; + ok(ret != 0, "GetTempPathW error %ld", GetLastError()); + ok(ret < MAX_PATH, "temp path should fit into MAX_PATH"); + + ret = GetTempFileNameW(temp_path, prefix, 0, source); + ok(ret != 0, "GetTempFileNameW error %ld", GetLastError()); + + ret = GetTempFileNameW(temp_path, prefix, 0, dest); + ok(ret != 0, "GetTempFileNameW error %ld", GetLastError()); + + ret = MoveFileW(source, dest); + ok(!ret && GetLastError() == ERROR_FILE_EXISTS, + "CopyFileW: unexpected error %ld\n", GetLastError()); + + ret = DeleteFileW(source); + ok(ret, "DeleteFileW: error %ld\n", GetLastError()); + ret = DeleteFileW(dest); + ok(ret, "DeleteFileW: error %ld\n", GetLastError()); } #define PATTERN_OFFSET 0x10 Index: dlls/kernel/tests/process.c =================================================================== RCS file: /home/wine/wine/dlls/kernel/tests/process.c,v retrieving revision 1.11 diff -u -r1.11 process.c --- dlls/kernel/tests/process.c 5 Sep 2003 23:08:36 -0000 1.11 +++ dlls/kernel/tests/process.c 15 Sep 2003 20:34:47 -0000 @@ -24,7 +24,6 @@ #include <stdlib.h> #include "wine/test.h" -#include "ntstatus.h" #include "windef.h" #include "winbase.h" #include "winuser.h" Index: dlls/kernel/tests/thread.c =================================================================== RCS file: /home/wine/wine/dlls/kernel/tests/thread.c,v retrieving revision 1.11 diff -u -r1.11 thread.c --- dlls/kernel/tests/thread.c 5 Sep 2003 23:08:36 -0000 1.11 +++ dlls/kernel/tests/thread.c 15 Sep 2003 20:34:47 -0000 @@ -24,7 +24,6 @@ #include <stdarg.h> #include "wine/test.h" -#include <ntstatus.h> #include <windef.h> #include <winbase.h> #include <winnt.h>