Regression test for files with zero length

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

 




A test for my previous patch.


ChangeLog:
* Regression test for files with zero length
Index: dlls/kernel/tests/file.c
===================================================================
RCS file: /home/wine/wine/dlls/kernel/tests/file.c,v
retrieving revision 1.26
diff -u -r1.26 file.c
--- dlls/kernel/tests/file.c	15 Dec 2003 20:15:20 -0000	1.26
+++ dlls/kernel/tests/file.c	8 Jan 2004 06:58:33 -0000
@@ -931,6 +931,37 @@
     ok ( err == ERROR_NO_MORE_FILES, "GetLastError should return ERROR_NO_MORE_FILES");
 }
 
+static void test_MapFile()
+{
+    HANDLE handle, hmap;
+
+    /* be sure to remove stale files */
+    SetFileAttributesA(filename,FILE_ATTRIBUTE_NORMAL);
+    DeleteFile(filename);
+    handle = CreateFile( filename, GENERIC_READ|GENERIC_WRITE, 0, 0,
+                         CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );
+    ok( handle != INVALID_HANDLE_VALUE, "couldn't create test file\n");
+
+    hmap = CreateFileMapping( handle, NULL, PAGE_READWRITE, 0, 0, NULL );
+    ok( hmap == NULL, "mapped zero size file\n");
+    ok( GetLastError() == ERROR_FILE_INVALID, "not ERROR_FILE_INVALID\n");
+
+    hmap = CreateFileMapping( handle, NULL, PAGE_READWRITE, 0x1000, 0, NULL );
+    ok( hmap == NULL, "mapping should fail\n");
+    /* GetLastError() varies between win9x and WinNT */
+
+    hmap = CreateFileMapping( handle, NULL, PAGE_READWRITE, 0x1000, 0x10000, NULL );
+    ok( hmap == NULL, "mapping should fail\n");
+    /* GetLastError() varies between win9x and WinNT */
+
+    hmap = CreateFileMapping( handle, NULL, PAGE_READWRITE, 0, 0x1000, NULL );
+    ok( hmap != NULL, "mapping should succeed\n");
+
+    ok( CloseHandle( hmap ), "can't close mapping handle\n");
+    ok( CloseHandle( handle ), "can't close file handle\n");
+    ok( DeleteFileA( filename ), "DeleteFile failed after map" );
+}
+
 START_TEST(file)
 {
     test__hread(  );
@@ -953,4 +984,5 @@
     test_FindNextFileA();
     test_LockFile();
     test_offset_in_overlapped_structure();
+    test_MapFile();
 }

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

  Powered by Linux