kernel32/tests: Fix tests to pass on Win9x and WinME.

This commit is contained in:
Guy Albertelli 2009-06-06 20:56:01 -04:00 committed by Alexandre Julliard
parent 5fbf895da6
commit 7c4939cbaa
1 changed files with 43 additions and 29 deletions

View File

@ -55,10 +55,11 @@ static const char sillytext[] =
"sdlkfjasdlkfj a dslkj adsklf \n \nasdklf askldfa sdlkf \nsadklf asdklf asdf ";
struct test_list {
const char *file;
const DWORD err;
const DWORD options;
const BOOL todo_flag;
const char *file; /* file string to test */
const DWORD err; /* Win NT and further error code */
const LONG err2; /* Win 9x & ME error code or -1 */
const DWORD options; /* option flag to use for open */
const BOOL todo_flag; /* todo_wine indicator */
} ;
static void InitFunctionPointers(void)
@ -717,19 +718,19 @@ static void test_CreateFileA(void)
static const char nt_drive[] = "\\\\?\\A:";
DWORD i, ret, len;
struct test_list p[] = {
{"", ERROR_PATH_NOT_FOUND, FILE_ATTRIBUTE_NORMAL, TRUE }, /* dir as file w \ */
{"", ERROR_SUCCESS, FILE_FLAG_BACKUP_SEMANTICS, FALSE }, /* dir as dir w \ */
{"a", ERROR_FILE_NOT_FOUND, FILE_ATTRIBUTE_NORMAL, FALSE }, /* non-exist file */
{"a\\", ERROR_FILE_NOT_FOUND, FILE_ATTRIBUTE_NORMAL, FALSE }, /* non-exist dir */
{"removeme", ERROR_ACCESS_DENIED, FILE_ATTRIBUTE_NORMAL, FALSE }, /* exist dir w/o \ */
{"removeme\\", ERROR_PATH_NOT_FOUND, FILE_ATTRIBUTE_NORMAL, TRUE }, /* exst dir w \ */
{"c:", ERROR_ACCESS_DENIED, FILE_ATTRIBUTE_NORMAL, FALSE }, /* device in file namespace */
{"c:", ERROR_SUCCESS, FILE_FLAG_BACKUP_SEMANTICS, FALSE }, /* device in file namespace as dir */
{"c:\\", ERROR_PATH_NOT_FOUND, FILE_ATTRIBUTE_NORMAL, TRUE }, /* root dir w \ */
{"c:\\", ERROR_SUCCESS, FILE_FLAG_BACKUP_SEMANTICS, FALSE }, /* root dir w \ as dir */
{"\\\\?\\c:", ERROR_SUCCESS, FILE_ATTRIBUTE_NORMAL,FALSE }, /* dev namespace drive */
{"\\\\?\\c:\\", ERROR_PATH_NOT_FOUND, FILE_ATTRIBUTE_NORMAL, TRUE }, /* dev namespace drive w \ */
{NULL, 0, 0, FALSE}
{"", ERROR_PATH_NOT_FOUND, -1, FILE_ATTRIBUTE_NORMAL, TRUE }, /* dir as file w \ */
{"", ERROR_SUCCESS, ERROR_PATH_NOT_FOUND, FILE_FLAG_BACKUP_SEMANTICS, FALSE }, /* dir as dir w \ */
{"a", ERROR_FILE_NOT_FOUND, -1, FILE_ATTRIBUTE_NORMAL, FALSE }, /* non-exist file */
{"a\\", ERROR_FILE_NOT_FOUND, ERROR_PATH_NOT_FOUND, FILE_ATTRIBUTE_NORMAL, FALSE }, /* non-exist dir */
{"removeme", ERROR_ACCESS_DENIED, -1, FILE_ATTRIBUTE_NORMAL, FALSE }, /* exist dir w/o \ */
{"removeme\\", ERROR_PATH_NOT_FOUND, -1, FILE_ATTRIBUTE_NORMAL, TRUE }, /* exst dir w \ */
{"c:", ERROR_ACCESS_DENIED, ERROR_PATH_NOT_FOUND, FILE_ATTRIBUTE_NORMAL, FALSE }, /* device in file namespace */
{"c:", ERROR_SUCCESS, ERROR_PATH_NOT_FOUND, FILE_FLAG_BACKUP_SEMANTICS, FALSE }, /* device in file namespace as dir */
{"c:\\", ERROR_PATH_NOT_FOUND, ERROR_ACCESS_DENIED, FILE_ATTRIBUTE_NORMAL, TRUE }, /* root dir w \ */
{"c:\\", ERROR_SUCCESS, ERROR_ACCESS_DENIED, FILE_FLAG_BACKUP_SEMANTICS, FALSE }, /* root dir w \ as dir */
{"\\\\?\\c:", ERROR_SUCCESS, ERROR_BAD_NETPATH, FILE_ATTRIBUTE_NORMAL,FALSE }, /* dev namespace drive */
{"\\\\?\\c:\\", ERROR_PATH_NOT_FOUND, ERROR_BAD_NETPATH, FILE_ATTRIBUTE_NORMAL, TRUE }, /* dev namespace drive w \ */
{NULL, 0, -1, 0, FALSE}
};
BY_HANDLE_FILE_INFORMATION Finfo;
@ -829,12 +830,16 @@ static void test_CreateFileA(void)
}
/* otherwise validate results with expectations */
else if (p[i].todo_flag)
todo_wine ok((hFile == INVALID_HANDLE_VALUE && p[i].err == GetLastError()) ||
todo_wine ok(
(hFile == INVALID_HANDLE_VALUE &&
(p[i].err == GetLastError() || p[i].err2 == GetLastError())) ||
(hFile != INVALID_HANDLE_VALUE && p[i].err == ERROR_SUCCESS),
"CreateFileA failed on %s, hFile %p, err=%u, should be %u\n",
filename, hFile, GetLastError(), p[i].err);
else
ok((hFile == INVALID_HANDLE_VALUE && p[i].err == GetLastError()) ||
ok(
(hFile == INVALID_HANDLE_VALUE &&
(p[i].err == GetLastError() || p[i].err2 == GetLastError())) ||
(hFile != INVALID_HANDLE_VALUE && p[i].err == ERROR_SUCCESS),
"CreateFileA failed on %s, hFile %p, err=%u, should be %u\n",
filename, hFile, GetLastError(), p[i].err);
@ -852,6 +857,8 @@ static void test_CreateFileA(void)
NULL,
OPEN_EXISTING,
FILE_FLAG_BACKUP_SEMANTICS, NULL );
if (hFile != INVALID_HANDLE_VALUE && GetLastError() != ERROR_PATH_NOT_FOUND)
{
ok(hFile != INVALID_HANDLE_VALUE && GetLastError() == ERROR_SUCCESS,
"CreateFileA did not work, last error %u on volume <%s>\n",
GetLastError(), temp_path );
@ -867,6 +874,9 @@ static void test_CreateFileA(void)
}
CloseHandle( hFile );
}
}
else
skip("Probable Win9x, got ERROR_PATH_NOT_FOUND w/ FILE_FLAG_BACKUP_SEMANTICS or %s\n", temp_path);
/* *** Test opening volumes/devices using drive letter *** */
@ -879,7 +889,8 @@ static void test_CreateFileA(void)
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_NO_BUFFERING, NULL );
if (hFile != INVALID_HANDLE_VALUE || GetLastError() != ERROR_ACCESS_DENIED)
if (hFile != INVALID_HANDLE_VALUE ||
(GetLastError() != ERROR_ACCESS_DENIED && GetLastError() != ERROR_BAD_NETPATH))
{
/* if we have adm rights to volume, then try rest of tests */
ok(hFile != INVALID_HANDLE_VALUE, "CreateFileA did not open %s, last error=%u\n",
@ -946,6 +957,9 @@ static void test_CreateFileA(void)
if (hFile != INVALID_HANDLE_VALUE)
CloseHandle( hFile );
}
/* If we see ERROR_BAD_NETPATH then on Win9x or WinME, so skip */
else if (GetLastError() == ERROR_BAD_NETPATH)
skip("Probable Win9x, got ERROR_BAD_NETPATH (53)\n");
else
skip("Do not have authority to access volumes. Tests skipped\n");