Fix for the kernel32/file tests

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Enio Schutt put me on the right track for fixing these tests. Basically
Win9x does not support overlapped I/O except on serial and parallel
ports. Since our tests perform overlapped I/O on files, we must skip
them when running the tests on Win9x. Hence the following patch.


Changelog:

 * dlls/kernel/tests/file.c

   Francois Gouget <fgouget@free.fr>
   With help from Enio Schutt Jr <enio.s.jr@operamail.com>
   Skip the overlapped I/O tests on files on Win9x


Index: dlls/kernel/tests/file.c
===================================================================
RCS file: /home/wine/wine/dlls/kernel/tests/file.c,v
retrieving revision 1.13
diff -u -r1.13 file.c
--- dlls/kernel/tests/file.c	18 Dec 2002 02:22:51 -0000	1.13
+++ dlls/kernel/tests/file.c	4 Feb 2003 02:21:59 -0000
@@ -609,6 +609,7 @@
     HANDLE hFile;
     OVERLAPPED ov;
     DWORD done;
+    BOOL rc;
     BYTE buf[256], pattern[] = "TeSt";
     UINT i;
     char temp_path[MAX_PATH], temp_fname[MAX_PATH];
@@ -628,19 +629,23 @@
     memset(&ov, 0, sizeof(ov));
     ov.Offset = PATTERN_OFFSET;
     ov.OffsetHigh = 0;
-    ok(WriteFile(hFile, pattern, sizeof(pattern), &done, &ov), "WriteFile error %ld", GetLastError());
-    ok(done == sizeof(pattern), "expected number of bytes written %lu", done);
-    trace("Current offset = %04lx\n", SetFilePointer(hFile, 0, NULL, FILE_CURRENT));
-    ok(SetFilePointer(hFile, 0, NULL, FILE_CURRENT) == (PATTERN_OFFSET + sizeof(pattern)),
-       "expected file offset %d", PATTERN_OFFSET + sizeof(pattern));
-
-    ov.Offset = sizeof(buf) * 2;
-    ov.OffsetHigh = 0;
-    ok(WriteFile(hFile, pattern, sizeof(pattern), &done, &ov), "WriteFile error %ld", GetLastError());
-    ok(done == sizeof(pattern), "expected number of bytes written %lu", done);
-    /*trace("Current offset = %04lx\n", SetFilePointer(hFile, 0, NULL, FILE_CURRENT));*/
-    ok(SetFilePointer(hFile, 0, NULL, FILE_CURRENT) == (sizeof(buf) * 2 + sizeof(pattern)),
-       "expected file offset %d", sizeof(buf) * 2 + sizeof(pattern));
+    rc=WriteFile(hFile, pattern, sizeof(pattern), &done, &ov);
+    /* Win 9x does not support the overlapped I/O on files */
+    if (rc || GetLastError()!=ERROR_INVALID_PARAMETER) {
+        ok(rc, "WriteFile error %ld", GetLastError());
+        ok(done == sizeof(pattern), "expected number of bytes written %lu", done);
+        trace("Current offset = %04lx\n", SetFilePointer(hFile, 0, NULL, FILE_CURRENT));
+        ok(SetFilePointer(hFile, 0, NULL, FILE_CURRENT) == (PATTERN_OFFSET + sizeof(pattern)),
+           "expected file offset %d", PATTERN_OFFSET + sizeof(pattern));
+
+        ov.Offset = sizeof(buf) * 2;
+        ov.OffsetHigh = 0;
+        ok(WriteFile(hFile, pattern, sizeof(pattern), &done, &ov), "WriteFile error %ld", GetLastError());
+        ok(done == sizeof(pattern), "expected number of bytes written %lu", done);
+        /*trace("Current offset = %04lx\n", SetFilePointer(hFile, 0, NULL, FILE_CURRENT));*/
+        ok(SetFilePointer(hFile, 0, NULL, FILE_CURRENT) == (sizeof(buf) * 2 + sizeof(pattern)),
+           "expected file offset %d", sizeof(buf) * 2 + sizeof(pattern));
+    }

     CloseHandle(hFile);

@@ -653,12 +658,16 @@
     memset(&ov, 0, sizeof(ov));
     ov.Offset = PATTERN_OFFSET;
     ov.OffsetHigh = 0;
-    ok(ReadFile(hFile, buf, sizeof(pattern), &done, &ov), "ReadFile error %ld", GetLastError());
-    ok(done == sizeof(pattern), "expected number of bytes read %lu", done);
-    trace("Current offset = %04lx\n", SetFilePointer(hFile, 0, NULL, FILE_CURRENT));
-    ok(SetFilePointer(hFile, 0, NULL, FILE_CURRENT) == (PATTERN_OFFSET + sizeof(pattern)),
-       "expected file offset %d", PATTERN_OFFSET + sizeof(pattern));
-    ok(!memcmp(buf, pattern, sizeof(pattern)), "pattern match failed");
+    rc=ReadFile(hFile, buf, sizeof(pattern), &done, &ov);
+    /* Win 9x does not support the overlapped I/O on files */
+    if (rc || GetLastError()!=ERROR_INVALID_PARAMETER) {
+        ok(rc, "ReadFile error %ld", GetLastError());
+        ok(done == sizeof(pattern), "expected number of bytes read %lu", done);
+        trace("Current offset = %04lx\n", SetFilePointer(hFile, 0, NULL, FILE_CURRENT));
+        ok(SetFilePointer(hFile, 0, NULL, FILE_CURRENT) == (PATTERN_OFFSET + sizeof(pattern)),
+           "expected file offset %d", PATTERN_OFFSET + sizeof(pattern));
+        ok(!memcmp(buf, pattern, sizeof(pattern)), "pattern match failed");
+    }

     CloseHandle(hFile);



-- 
Francois Gouget         fgouget@free.fr        http://fgouget.free.fr/
               RFC 2549: ftp://ftp.isi.edu/in-notes/rfc2549.txt
                IP over Avian Carriers with Quality of Service





[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux