Fix the kernel/directory tests
Francois Gouget
fgouget at free.fr
Tue Dec 10 21:28:47 CST 2002
With this patch the kernel/directory tests should complete successfully
on Win95, Win98 and NT4.
Changelog:
* dlls/kernel/tests/directory.c
Skip the Unicode tests on Win9x
Test Get{System,Windows}Directory{A,W}(NULL, 0). This is a more
standard way to get len_with_null too
Adapt the error code checks to take into account variations between
Win9x and NT
Index: dlls/kernel/tests/directory.c
===================================================================
RCS file: /home/wine/wine/dlls/kernel/tests/directory.c,v
retrieving revision 1.3
diff -u -r1.3 directory.c
--- dlls/kernel/tests/directory.c 27 Aug 2002 01:56:08 -0000 1.3
+++ dlls/kernel/tests/directory.c 11 Dec 2002 02:54:55 -0000
@@ -30,21 +30,25 @@
UINT len, len_with_null;
char buf[MAX_PATH];
+ len_with_null = GetWindowsDirectoryA(NULL, 0);
+ ok(len_with_null <= MAX_PATH, "should fit into MAX_PATH");
+
lstrcpyA(buf, "foo");
len_with_null = GetWindowsDirectoryA(buf, 1);
ok(lstrcmpA(buf, "foo") == 0, "should not touch the buffer");
- ok(len_with_null <= MAX_PATH, "should fit into MAX_PATH");
lstrcpyA(buf, "foo");
len = GetWindowsDirectoryA(buf, len_with_null - 1);
ok(lstrcmpA(buf, "foo") == 0, "should not touch the buffer");
- ok(len == len_with_null, "should return length with terminating 0");
+ ok(len == len_with_null, "GetWindowsDirectoryW returned %d, expected %d",
+ len, len_with_null);
lstrcpyA(buf, "foo");
len = GetWindowsDirectoryA(buf, len_with_null);
ok(lstrcmpA(buf, "foo") != 0, "should touch the buffer");
ok(len == lstrlenA(buf), "returned length should be equal to the length of string");
- ok(len == (len_with_null - 1), "should return length without terminating 0");
+ ok(len == len_with_null-1, "GetWindowsDirectoryA returned %d, expected %d",
+ len, len_with_null-1);
}
static void test_GetWindowsDirectoryW(void)
@@ -53,21 +57,29 @@
WCHAR buf[MAX_PATH];
static const WCHAR fooW[] = {'f','o','o',0};
+ len_with_null = GetWindowsDirectoryW(NULL, 0);
+ if (len_with_null==0 && GetLastError()==ERROR_CALL_NOT_IMPLEMENTED)
+ return;
+ ok(len_with_null <= MAX_PATH, "should fit into MAX_PATH");
+
lstrcpyW(buf, fooW);
- len_with_null = GetWindowsDirectoryW(buf, 1);
+ len = GetWindowsDirectoryW(buf, 1);
ok(lstrcmpW(buf, fooW) == 0, "should not touch the buffer");
- ok(len_with_null <= MAX_PATH, "should fit into MAX_PATH");
+ ok(len == len_with_null, "GetWindowsDirectoryW returned %d, expected %d",
+ len, len_with_null);
lstrcpyW(buf, fooW);
len = GetWindowsDirectoryW(buf, len_with_null - 1);
ok(lstrcmpW(buf, fooW) == 0, "should not touch the buffer");
- ok(len == len_with_null, "should return length with terminating 0");
+ ok(len == len_with_null, "GetWindowsDirectoryW returned %d, expected %d",
+ len, len_with_null);
lstrcpyW(buf, fooW);
len = GetWindowsDirectoryW(buf, len_with_null);
ok(lstrcmpW(buf, fooW) != 0, "should touch the buffer");
ok(len == lstrlenW(buf), "returned length should be equal to the length of string");
- ok(len == (len_with_null - 1), "should return length without terminating 0");
+ ok(len == len_with_null-1, "GetWindowsDirectoryW returned %d, expected %d",
+ len, len_with_null-1);
}
@@ -79,21 +91,27 @@
UINT len, len_with_null;
char buf[MAX_PATH];
+ len_with_null = GetSystemDirectoryA(NULL, 0);
+ ok(len_with_null <= MAX_PATH, "should fit into MAX_PATH");
+
lstrcpyA(buf, "foo");
- len_with_null = GetSystemDirectoryA(buf, 1);
+ len = GetSystemDirectoryA(buf, 1);
ok(lstrcmpA(buf, "foo") == 0, "should not touch the buffer");
- ok(len_with_null <= MAX_PATH, "should fit into MAX_PATH");
+ ok(len == len_with_null, "GetSystemDirectoryA returned %d, expected %d",
+ len, len_with_null);
lstrcpyA(buf, "foo");
len = GetSystemDirectoryA(buf, len_with_null - 1);
ok(lstrcmpA(buf, "foo") == 0, "should not touch the buffer");
- ok(len == len_with_null, "should return length with terminating 0");
+ ok(len == len_with_null, "GetSystemDirectoryA returned %d, expected %d",
+ len, len_with_null);
lstrcpyA(buf, "foo");
len = GetSystemDirectoryA(buf, len_with_null);
ok(lstrcmpA(buf, "foo") != 0, "should touch the buffer");
ok(len == lstrlenA(buf), "returned length should be equal to the length of string");
- ok(len == (len_with_null - 1), "should return length without terminating 0");
+ ok(len == len_with_null-1, "GetSystemDirectoryW returned %d, expected %d",
+ len, len_with_null-1);
}
static void test_GetSystemDirectoryW(void)
@@ -102,21 +120,29 @@
WCHAR buf[MAX_PATH];
static const WCHAR fooW[] = {'f','o','o',0};
+ len_with_null = GetSystemDirectoryW(NULL, 0);
+ if (len_with_null==0 && GetLastError()==ERROR_CALL_NOT_IMPLEMENTED)
+ return;
+ ok(len_with_null <= MAX_PATH, "should fit into MAX_PATH");
+
lstrcpyW(buf, fooW);
- len_with_null = GetSystemDirectoryW(buf, 1);
+ len = GetSystemDirectoryW(buf, 1);
ok(lstrcmpW(buf, fooW) == 0, "should not touch the buffer");
- ok(len_with_null <= MAX_PATH, "should fit into MAX_PATH");
+ ok(len == len_with_null, "GetSystemDirectoryW returned %d, expected %d",
+ len, len_with_null);
lstrcpyW(buf, fooW);
len = GetSystemDirectoryW(buf, len_with_null - 1);
ok(lstrcmpW(buf, fooW) == 0, "should not touch the buffer");
- ok(len == len_with_null, "should return length with terminating 0");
+ ok(len == len_with_null, "GetSystemDirectoryW returned %d, expected %d",
+ len, len_with_null);
lstrcpyW(buf, fooW);
len = GetSystemDirectoryW(buf, len_with_null);
ok(lstrcmpW(buf, fooW) != 0, "should touch the buffer");
ok(len == lstrlenW(buf), "returned length should be equal to the length of string");
- ok(len == (len_with_null - 1), "should return length without terminating 0");
+ ok(len == len_with_null-1, "GetSystemDirectoryW returned %d, expected %d",
+ len, len_with_null-1);
}
static void test_CreateDirectoryA(void)
@@ -125,10 +151,14 @@
BOOL ret;
ret = CreateDirectoryA(NULL, NULL);
- ok(ret == FALSE && GetLastError() == ERROR_PATH_NOT_FOUND, "should not create NULL path");
+ ok(ret == FALSE && (GetLastError() == ERROR_PATH_NOT_FOUND ||
+ GetLastError() == ERROR_INVALID_PARAMETER),
+ "CreateDirectoryA(NULL,NULL): ret=%d error=%ld",ret,GetLastError());
ret = CreateDirectoryA("", NULL);
- ok(ret == FALSE && GetLastError() == ERROR_PATH_NOT_FOUND, "should not create empty path");
+ ok(ret == FALSE && (GetLastError() == ERROR_BAD_PATHNAME ||
+ GetLastError() == ERROR_PATH_NOT_FOUND),
+ "CreateDirectoryA(\"\",NULL): ret=%d error=%ld",ret,GetLastError());
ret = GetSystemDirectoryA(tmpdir, MAX_PATH);
ok(ret < MAX_PATH, "System directory should fit into MAX_PATH");
@@ -145,7 +175,9 @@
GetTempPathA(MAX_PATH, tmpdir);
tmpdir[3] = 0; /* truncate the path */
ret = CreateDirectoryA(tmpdir, NULL);
- ok(ret == FALSE && GetLastError() == ERROR_ACCESS_DENIED, "should deny access to the drive root");
+ ok(ret == FALSE && (GetLastError() == ERROR_ALREADY_EXISTS ||
+ GetLastError() == ERROR_ACCESS_DENIED),
+ "CreateDirectoryA(drive_root): ret=%d error=%ld",ret,GetLastError());
GetTempPathA(MAX_PATH, tmpdir);
lstrcatA(tmpdir, "Please Remove Me");
@@ -169,6 +201,8 @@
static const WCHAR dotdotW[] = {'.','.',0};
ret = CreateDirectoryW(NULL, NULL);
+ if (!ret && GetLastError()==ERROR_CALL_NOT_IMPLEMENTED)
+ return;
ok(ret == FALSE && GetLastError() == ERROR_PATH_NOT_FOUND, "should not create NULL path");
ret = CreateDirectoryW(empty_strW, NULL);
--
Francois Gouget fgouget at free.fr http://fgouget.free.fr/
Before you criticize someone, walk a mile in his shoes.
That way, if he gets angry, he'll be a mile away - and barefoot.
More information about the wine-patches
mailing list