[PATCH 1/5] lz32/tests: Test more last errors set by LZOpenFile[AW].
Saulius Krasuckas
saulius.krasuckas at ieee.org
Thu Oct 5 12:48:10 CDT 2006
(Headers in this series of patches was slightly edited by hand due to lack
of internet connection and newer git version. Don't be surprised for
inconsistencies and just drop if that was the case)
---
dlls/lz32/tests/lzexpand_main.c | 76 ++++++++++++++++++++++++++++++++++++++-
1 files changed, 74 insertions(+), 2 deletions(-)
484c0e401dc09dd89fffb55da7f34599638bb1cd
diff --git a/dlls/lz32/tests/lzexpand_main.c b/dlls/lz32/tests/lzexpand_main.c
index eead144..17c2757 100644
--- a/dlls/lz32/tests/lzexpand_main.c
+++ b/dlls/lz32/tests/lzexpand_main.c
@@ -131,6 +131,7 @@ static void test_LZOpenFileA_existing_co
memset(&filled_0xA5, 0xA5, OFS_MAXPATHNAME);
memset(&test, 0xA5, sizeof(test));
full_file_path_name_in_a_CWD(filename_, expected, FALSE);
+ SetLastError(0xfaceabee);
/* a, using 8.3-conformant file name. */
file = LZOpenFileA(filename, &test, OF_EXIST);
@@ -148,6 +149,8 @@ static void test_LZOpenFileA_existing_co
test.szPathName, expected);
LZClose(file);
} else { /* Win9x */
+ ok(GetLastError() == ERROR_FILE_NOT_FOUND,
+ "GetLastError() returns %ld\n", GetLastError());
ok(test.cBytes == 0xA5,
"LZOpenFileA set test.cBytes to %d\n", test.cBytes);
ok(test.nErrCode == ERROR_FILE_NOT_FOUND,
@@ -160,6 +163,7 @@ static void test_LZOpenFileA_existing_co
memset(&filled_0xA5, 0xA5, OFS_MAXPATHNAME);
memset(&test, 0xA5, sizeof(test));
full_file_path_name_in_a_CWD(dotless_, expected, FALSE);
+ SetLastError(0xfaceabee);
/* b, using dotless file name. */
file = LZOpenFileA(dotless, &test, OF_EXIST);
@@ -173,6 +177,8 @@ static void test_LZOpenFileA_existing_co
test.szPathName, expected);
LZClose(file);
} else { /* Win9x */
+ ok(GetLastError() == ERROR_FILE_NOT_FOUND,
+ "GetLastError() returns %ld\n", GetLastError());
todo_wine
ok(test.cBytes == 0xA5,
"LZOpenFileA set test.cBytes to %d\n", test.cBytes);
@@ -187,6 +193,7 @@ static void test_LZOpenFileA_existing_co
memset(&filled_0xA5, 0xA5, OFS_MAXPATHNAME);
memset(&test, 0xA5, sizeof(test));
full_file_path_name_in_a_CWD(extless_, expected, FALSE);
+ SetLastError(0xfaceabee);
/* c, using extensionless file name. */
file = LZOpenFileA(extless, &test, OF_EXIST);
@@ -200,6 +207,8 @@ static void test_LZOpenFileA_existing_co
test.szPathName, expected);
LZClose(file);
} else { /* Win9x */
+ ok(GetLastError() == ERROR_FILE_NOT_FOUND,
+ "GetLastError() returns %ld\n", GetLastError());
ok(test.cBytes == 0xA5,
"LZOpenFileA set test.cBytes to %d\n", test.cBytes);
ok(test.nErrCode == ERROR_FILE_NOT_FOUND,
@@ -213,10 +222,13 @@ static void test_LZOpenFileA_existing_co
memset(&test, 0xA5, sizeof(test));
full_file_path_name_in_a_CWD(_terminated_, expected, FALSE);
full_file_path_name_in_a_CWD(_terminated_, short_expected, TRUE);
+ SetLastError(0xfaceabee);
/* d, using underscore-terminated file name. */
file = LZOpenFileA(_terminated, &test, OF_EXIST);
ok(file >= 0, "LZOpenFileA failed on switching to a compressed file name\n");
+ ok(GetLastError() == ERROR_SUCCESS || GetLastError() == ERROR_BAD_PATHNAME,
+ "GetLastError() returns %ld\n", GetLastError());
ok(test.cBytes == sizeof(OFSTRUCT),
"LZOpenFileA set test.cBytes to %d\n", test.cBytes);
ok(test.nErrCode == 0, "LZOpenFileA set test.nErrCode to %d\n",
@@ -244,6 +256,7 @@ static void test_LZOpenFileA_nonexisting
memset(&filled_0xA5, 0xA5, OFS_MAXPATHNAME);
memset(&test, 0xA5, sizeof(test));
full_file_path_name_in_a_CWD(filename_, expected, FALSE);
+ SetLastError(0xfaceabee);
/* a, using 8.3-conformant file name. */
file = LZOpenFileA(filename, &test, OF_EXIST);
@@ -253,6 +266,8 @@ static void test_LZOpenFileA_nonexisting
*/
ok(file == LZERROR_BADINHANDLE,
"LZOpenFileA succeeded on nonexistent file\n");
+ ok(GetLastError() == ERROR_FILE_NOT_FOUND,
+ "GetLastError() returns %ld\n", GetLastError());
todo_wine
ok(test.cBytes == 0xA5,
"LZOpenFileA set test.cBytes to %d\n", test.cBytes);
@@ -266,11 +281,14 @@ static void test_LZOpenFileA_nonexisting
memset(&filled_0xA5, 0xA5, OFS_MAXPATHNAME);
memset(&test, 0xA5, sizeof(test));
full_file_path_name_in_a_CWD(dotless_, expected, FALSE);
+ SetLastError(0xfaceabee);
/* b, using dotless file name. */
file = LZOpenFileA(dotless, &test, OF_EXIST);
ok(file == LZERROR_BADINHANDLE,
"LZOpenFileA succeeded on nonexistent file\n");
+ ok(GetLastError() == ERROR_FILE_NOT_FOUND,
+ "GetLastError() returns %ld\n", GetLastError());
todo_wine
ok(test.cBytes == 0xA5,
"LZOpenFileA set test.cBytes to %d\n", test.cBytes);
@@ -284,11 +302,14 @@ static void test_LZOpenFileA_nonexisting
memset(&filled_0xA5, 0xA5, OFS_MAXPATHNAME);
memset(&test, 0xA5, sizeof(test));
full_file_path_name_in_a_CWD(extless_, expected, FALSE);
+ SetLastError(0xfaceabee);
/* c, using extensionless file name. */
file = LZOpenFileA(extless, &test, OF_EXIST);
ok(file == LZERROR_BADINHANDLE,
"LZOpenFileA succeeded on nonexistent file\n");
+ ok(GetLastError() == ERROR_FILE_NOT_FOUND,
+ "GetLastError() returns %ld\n", GetLastError());
todo_wine
ok(test.cBytes == 0xA5,
"LZOpenFileA set test.cBytes to %d\n", test.cBytes);
@@ -302,11 +323,14 @@ static void test_LZOpenFileA_nonexisting
memset(&filled_0xA5, 0xA5, OFS_MAXPATHNAME);
memset(&test, 0xA5, sizeof(test));
full_file_path_name_in_a_CWD(_terminated_, expected, FALSE);
+ SetLastError(0xfaceabee);
/* d, using underscore-terminated file name. */
file = LZOpenFileA(_terminated, &test, OF_EXIST);
ok(file == LZERROR_BADINHANDLE,
"LZOpenFileA succeeded on nonexistent file\n");
+ ok(GetLastError() == ERROR_FILE_NOT_FOUND,
+ "GetLastError() returns %ld\n", GetLastError());
todo_wine
ok(test.cBytes == 0xA5,
"LZOpenFileA set test.cBytes to %d\n", test.cBytes);
@@ -334,31 +358,57 @@ static void test_LZOpenFileA(void)
"GetLastError() returns %ld\n", GetLastError());
LZClose(file);
+ SetLastError(0xfaceabee);
/* Create an empty file. */
file = LZOpenFileA(filename_, &test, OF_CREATE);
ok(file >= 0, "LZOpenFileA failed on creation\n");
+ ok(GetLastError() == ERROR_SUCCESS || GetLastError() == ERROR_FILE_NOT_FOUND,
+ "GetLastError() returns %ld\n", GetLastError());
LZClose(file);
retval = GetFileAttributesA(filename_);
ok(retval != INVALID_FILE_ATTRIBUTES, "GetFileAttributesA: error %ld\n",
GetLastError());
- /* Check various opening options. */
+ /* Check various opening options: */
+ SetLastError(0xfaceabee);
+ /* a, for reading. */
file = LZOpenFileA(filename_, &test, OF_READ);
ok(file >= 0, "LZOpenFileA failed on read\n");
+ ok(GetLastError() == ERROR_SUCCESS || GetLastError() == ERROR_BAD_PATHNAME,
+ "GetLastError() returns %ld\n", GetLastError());
LZClose(file);
+
+ SetLastError(0xfaceabee);
+ /* b, for writing. */
file = LZOpenFileA(filename_, &test, OF_WRITE);
ok(file >= 0, "LZOpenFileA failed on write\n");
+ ok(GetLastError() == ERROR_SUCCESS || GetLastError() == ERROR_BAD_PATHNAME,
+ "GetLastError() returns %ld\n", GetLastError());
LZClose(file);
+
+ SetLastError(0xfaceabee);
+ /* c, for reading and writing. */
file = LZOpenFileA(filename_, &test, OF_READWRITE);
ok(file >= 0, "LZOpenFileA failed on read/write\n");
+ ok(GetLastError() == ERROR_SUCCESS || GetLastError() == ERROR_BAD_PATHNAME,
+ "GetLastError() returns %ld\n", GetLastError());
LZClose(file);
+
+ SetLastError(0xfaceabee);
+ /* d, for checking file existance. */
file = LZOpenFileA(filename_, &test, OF_EXIST);
ok(file >= 0, "LZOpenFileA failed on read/write\n");
+ ok(GetLastError() == ERROR_SUCCESS || GetLastError() == ERROR_BAD_PATHNAME,
+ "GetLastError() returns %ld\n", GetLastError());
LZClose(file);
+ SetLastError(0xfaceabee);
/* Delete the file then make sure it doesn't exist anymore. */
file = LZOpenFileA(filename_, &test, OF_DELETE);
ok(file >= 0, "LZOpenFileA failed on delete\n");
+ todo_wine
+ ok(GetLastError() == ERROR_SUCCESS || GetLastError() == ERROR_BAD_PATHNAME,
+ "GetLastError() returns %ld\n", GetLastError());
LZClose(file);
retval = GetFileAttributesA(filename_);
@@ -575,6 +625,7 @@ static void test_LZOpenFileW_nonexisting
memset(&filled_0xA5, 0xA5, OFS_MAXPATHNAME);
memset(&test, 0xA5, sizeof(test));
full_file_path_name_in_a_CWD(filename_, expected, FALSE);
+ SetLastError(0xfaceabee);
/* a, using 8.3-conformant file name. */
file = LZOpenFileW(filenameW, &test, OF_EXIST);
@@ -584,6 +635,8 @@ static void test_LZOpenFileW_nonexisting
*/
ok(file == LZERROR_BADINHANDLE,
"LZOpenFileW succeeded on nonexistent file\n");
+ ok(GetLastError() == ERROR_FILE_NOT_FOUND,
+ "GetLastError() returns %ld\n", GetLastError());
todo_wine
ok(test.cBytes == 0xA5,
"LZOpenFileW set test.cBytes to %d\n", test.cBytes);
@@ -596,11 +649,14 @@ static void test_LZOpenFileW_nonexisting
memset(&filled_0xA5, 0xA5, OFS_MAXPATHNAME);
memset(&test, 0xA5, sizeof(test));
full_file_path_name_in_a_CWD(dotless_, expected, FALSE);
+ SetLastError(0xfaceabee);
/* b, using dotless file name. */
file = LZOpenFileW(dotlessW, &test, OF_EXIST);
ok(file == LZERROR_BADINHANDLE,
"LZOpenFileW succeeded on nonexistent file\n");
+ ok(GetLastError() == ERROR_FILE_NOT_FOUND,
+ "GetLastError() returns %ld\n", GetLastError());
todo_wine
ok(test.cBytes == 0xA5,
"LZOpenFileW set test.cBytes to %d\n", test.cBytes);
@@ -613,11 +669,14 @@ static void test_LZOpenFileW_nonexisting
memset(&filled_0xA5, 0xA5, OFS_MAXPATHNAME);
memset(&test, 0xA5, sizeof(test));
full_file_path_name_in_a_CWD(extless_, expected, FALSE);
+ SetLastError(0xfaceabee);
/* c, using extensionless file name. */
file = LZOpenFileW(extlessW, &test, OF_EXIST);
ok(file == LZERROR_BADINHANDLE,
"LZOpenFileW succeeded on nonexistent file\n");
+ ok(GetLastError() == ERROR_FILE_NOT_FOUND,
+ "GetLastError() returns %ld\n", GetLastError());
todo_wine
ok(test.cBytes == 0xA5,
"LZOpenFileW set test.cBytes to %d\n", test.cBytes);
@@ -630,11 +689,14 @@ static void test_LZOpenFileW_nonexisting
memset(&filled_0xA5, 0xA5, OFS_MAXPATHNAME);
memset(&test, 0xA5, sizeof(test));
full_file_path_name_in_a_CWD(_terminated_, expected, FALSE);
+ SetLastError(0xfaceabee);
/* d, using underscore-terminated file name. */
file = LZOpenFileW(_terminatedW, &test, OF_EXIST);
ok(file == LZERROR_BADINHANDLE,
"LZOpenFileW succeeded on nonexistent file\n");
+ ok(GetLastError() == ERROR_FILE_NOT_FOUND,
+ "GetLastError() returns %ld\n", GetLastError());
todo_wine
ok(test.cBytes == 0xA5,
"LZOpenFileW set test.cBytes to %d\n", test.cBytes);
@@ -655,6 +717,8 @@ static void test_LZOpenFileW(void)
SetLastError(0xfaceabee);
/* Check for nonexistent file. */
file = LZOpenFileW(badfilenameW, &test, OF_READ);
+ ok(GetLastError() == ERROR_FILE_NOT_FOUND || GetLastError() == ERROR_CALL_NOT_IMPLEMENTED,
+ "GetLastError() returns %ld\n", GetLastError());
if(GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
{
trace("LZOpenFileW call not implemented, skipping rest of the test\n");
@@ -667,21 +731,29 @@ static void test_LZOpenFileW(void)
/* Create an empty file. */
file = LZOpenFileW(filenameW_, &test, OF_CREATE);
ok(file >= 0, "LZOpenFile failed on creation\n");
+
LZClose(file);
retval = GetFileAttributesW(filenameW_);
ok(retval != INVALID_FILE_ATTRIBUTES, "GetFileAttributes: error %ld\n",
GetLastError());
- /* Check various opening options. */
+ /* Check various opening options: */
+ /* a, for reading. */
file = LZOpenFileW(filenameW_, &test, OF_READ);
ok(file >= 0, "LZOpenFileW failed on read\n");
LZClose(file);
+
+ /* b, for writing. */
file = LZOpenFileW(filenameW_, &test, OF_WRITE);
ok(file >= 0, "LZOpenFileW failed on write\n");
LZClose(file);
+
+ /* c, for reading and writing. */
file = LZOpenFileW(filenameW_, &test, OF_READWRITE);
ok(file >= 0, "LZOpenFileW failed on read/write\n");
LZClose(file);
+
+ /* d, for checking file existance. */
file = LZOpenFileW(filenameW_, &test, OF_EXIST);
ok(file >= 0, "LZOpenFileW failed on read/write\n");
LZClose(file);
--
1.3.3
More information about the wine-patches
mailing list