kernel32/tests: Improve GetVolumePathNameA tests
Bruno Jesus
00cpxxx at gmail.com
Tue Jul 30 01:30:59 CDT 2013
Erich Hoover contacted me about a patch he sent months ago related to
GetVolumePathNameA. He developed a better test infrastructure using a
for loop instead of multiple repetitions of test lines. This patch
will make it easier for him to rebase and send his tests and function
implementation later.
I used the same approach from [1] by decomposing the "todo_wine" in
winetest_start_todo("wine") and winetest_end_todo("wine").
http://source.winehq.org/source/programs/cmd/tests/batch.c#L292
-------------- next part --------------
diff --git a/dlls/kernel32/tests/volume.c b/dlls/kernel32/tests/volume.c
index e63a2ef..50446eb 100644
--- a/dlls/kernel32/tests/volume.c
+++ b/dlls/kernel32/tests/volume.c
@@ -593,9 +593,46 @@ static void test_GetVolumePathNameA(void)
{
BOOL ret;
char volume[MAX_PATH];
- char expected[] = "C:\\", pathC1[] = "C:\\", pathC2[] = "C::";
+ const char pathC[] = {"C:\\"};
DWORD error;
+ int success, i;
+ struct GetVolumePathName_test
+ {
+ BOOL succeeds;
+ const char *file_name;
+ const char *path_name;
+ BOOL todo_ret, todo_path, todo_error;
+ DWORD error;
+ } test_paths[] = {
+ { /* 0 : standard drive */
+ TRUE,
+ pathC, pathC,
+ FALSE, FALSE, TRUE, 0
+ },
+ { /* 1 : lower case drive should go uppercase */
+ TRUE,
+ "c:\\", pathC,
+ FALSE, TRUE, TRUE, 0
+ },
+ { /* 2 : drive without slash is also valid */
+ TRUE,
+ "C:", pathC,
+ TRUE, TRUE, TRUE, 0
+ },
+ { /* 3 : invalid char after drive is also valid */
+ TRUE,
+ "C::", pathC,
+ TRUE, TRUE, TRUE, 0
+ },
+ { /* 4 : more invalid drive tests */
+ TRUE,
+ "C:%", pathC,
+ TRUE, TRUE, TRUE, 0
+ }
+ };
+
+ /* GetVolumePathName is not present before w2k */
if (!pGetVolumePathNameA)
{
win_skip("required functions not found\n");
@@ -621,7 +658,7 @@ todo_wine
"expected ERROR_INVALID_PARAMETER got %u\n", error);
SetLastError( 0xdeadbeef );
- ret = pGetVolumePathNameA(pathC1, NULL, 0);
+ ret = pGetVolumePathNameA(pathC, NULL, 0);
error = GetLastError();
ok(!ret, "expected failure\n");
todo_wine
@@ -630,7 +667,7 @@ todo_wine
"expected ERROR_INVALID_PARAMETER got %u\n", error);
SetLastError( 0xdeadbeef );
- ret = pGetVolumePathNameA(pathC1, volume, 0);
+ ret = pGetVolumePathNameA(pathC, volume, 0);
error = GetLastError();
ok(!ret, "expected failure\n");
todo_wine
@@ -639,31 +676,41 @@ todo_wine
"expected ERROR_INVALID_PARAMETER got %u\n", error);
SetLastError( 0xdeadbeef );
- ret = pGetVolumePathNameA(pathC1, volume, 1);
+ ret = pGetVolumePathNameA(pathC, volume, 1);
error = GetLastError();
ok(!ret, "expected failure\n");
todo_wine
ok(error == ERROR_FILENAME_EXCED_RANGE, "expected ERROR_FILENAME_EXCED_RANGE got %u\n", error);
- volume[0] = '\0';
- ret = pGetVolumePathNameA(pathC1, volume, sizeof(volume));
- ok(ret, "expected success\n");
- ok(!strcmp(expected, volume), "expected name '%s', returned '%s'\n", pathC1, volume);
-
- pathC1[0] = tolower(pathC1[0]);
- volume[0] = '\0';
- ret = pGetVolumePathNameA(pathC1, volume, sizeof(volume));
- ok(ret, "expected success\n");
-todo_wine
- ok(!strcmp(expected, volume) || broken(!strcasecmp(expected, volume)) /* <=XP */,
- "expected name '%s', returned '%s'\n", expected, volume);
-
- volume[0] = '\0';
- ret = pGetVolumePathNameA(pathC2, volume, sizeof(volume));
-todo_wine
- ok(ret, "expected success\n");
-todo_wine
- ok(!strcmp(expected, volume), "expected name '%s', returned '%s'\n", expected, volume);
+ for(i = 0; i < sizeof(test_paths)/sizeof(test_paths[0]); i++)
+ {
+ volume[0] = 0;
+ SetLastError( 0xdeadbeef );
+ ret = pGetVolumePathNameA(test_paths[i].file_name, volume, sizeof(volume));
+
+ if(test_paths[i].todo_ret) winetest_start_todo("wine");
+ success = (ret == test_paths[i].succeeds);
+ ok(success, "GetVolumePathName test %d %s unexpectedly.\n",
+ i, test_paths[i].succeeds ? "failed" : "succeeded");
+ if(test_paths[i].todo_ret) winetest_end_todo("wine");
+
+ if(test_paths[i].todo_path) winetest_start_todo("wine");
+ success = (!strcmp(volume, test_paths[i].path_name)
+ || broken(!strcasecmp(volume, test_paths[i].path_name) /* <=XP */));
+ ok(success, "GetVolumePathName test %d unexpectedly returned path '%s' (expected '%s').\n",
+ i, volume, test_paths[i].path_name);
+ if(test_paths[i].todo_path) winetest_end_todo("wine");
+
+ if(test_paths[i].error)
+ {
+ if(test_paths[i].todo_error) winetest_start_todo("wine");
+ error = GetLastError();
+ success = (error == test_paths[i].error);
+ ok(success, "GetVolumePathName test %d unexpectedly returned error %u (expected %u).\n",
+ i, error, test_paths[i].error);
+ if(test_paths[i].todo_error) winetest_end_todo("wine");
+ }
+ }
}
static void test_GetVolumePathNamesForVolumeNameA(void)
More information about the wine-patches
mailing list