Fix for errors in unit tests. file.c Verified on Win95
jakov at vmlinux.org
jakov at vmlinux.org
Tue May 21 17:07:39 CDT 2002
License: LGPL
Nice people pointed out errors in the unit tests in
dlls/kernel/tests/file.c
I fixed them and verified it all on Windows 95 by crosscompiling
with mingw-gcc.
To ease crosscompiling I created a small h-file "unittest.h" that
does magic to make the "ok()" macro work when run in a standalone EXE.
Attached is the cvs diff for file.c and
dlls/kernel/tests/unittest.h
-------------- next part --------------
A non-text attachment was scrubbed...
Name: unittest.h
Type: text/x-chdr
Size: 558 bytes
Desc: not available
Url : http://www.winehq.org/pipermail/wine-patches/attachments/20020522/00c693cd/unittest.h
-------------- next part --------------
? profile.c
? realfile.c
? unittest.diff
? unittest.h
Index: directory.c
===================================================================
RCS file: /home/wine/wine/dlls/kernel/tests/directory.c,v
retrieving revision 1.2
diff -u -r1.2 directory.c
--- directory.c 1 Apr 2002 21:00:26 -0000 1.2
+++ directory.c 21 May 2002 21:57:02 -0000
@@ -126,3 +126,4 @@
test_GetSystemDirectoryA();
test_GetSystemDirectoryW();
}
+
Index: file.c
===================================================================
RCS file: /home/wine/wine/dlls/kernel/tests/file.c,v
retrieving revision 1.4
diff -u -r1.4 file.c
--- file.c 10 May 2002 01:10:04 -0000 1.4
+++ file.c 21 May 2002 21:57:02 -0000
@@ -1,8 +1,10 @@
-/*
+/* -*- wine-c -*-
+ *
* Unit tests for file functions in Wine
*
* Copyright (c) 2002 Jakob Eriksson
*
+ *
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
@@ -19,11 +21,23 @@
*
*/
-#include "winbase.h"
-#include "winerror.h"
-#include "wine/test.h"
+
+/*
+ * Compile tests for Windows with:
+ *
+ * i586-mingw32msvc-gcc -DREAL_EXE -o file.exe file.c
+ *
+ *
+ * I'm planning on a unit test EXE builder with a twist. Stand by.
+ * Help very much appreciated!
+ * /jakob at vmlinux.org
+ *
+ */
+
+#include "unittest.h"
+
#include <stdlib.h>
#include <time.h>
@@ -209,8 +223,14 @@
ok( INVALID_HANDLE_VALUE != FindFirstFileA( filename, &search_results ), "should be able to find file" );
- ok( DeleteFileA( filename ) != 0, "DeleteFileA complains." );
-
+ todo_wine
+ {
+ ok( 0 == DeleteFileA( filename ), "shouldn't be able to delete a readonly file" );
+
+ ok( SetFileAttributesA(filename, FILE_ATTRIBUTE_NORMAL ) != 0, "couldn't change attributes on file" );
+
+ ok( DeleteFileA( filename ) != 0, "now it should be possible to delete the file!" );
+ }
filehandle = _lcreat( filename, 2 );
ok( HFILE_ERROR != filehandle, "couldn't create file. Wrong permissions on directory?" );
@@ -223,30 +243,25 @@
ok( HFILE_ERROR != _lclose(filehandle), "_lclose complains." );
- todo_wine
- {
- ok( INVALID_HANDLE_VALUE == FindFirstFileA( filename, &search_results ), "should NOT be able to find file" );
- }
+ ok( INVALID_HANDLE_VALUE != FindFirstFileA( filename, &search_results ), "should be able to find file" );
ok( DeleteFileA( filename ) != 0, "DeleteFileA complains." );
- filehandle = _lcreat( filename, 4 );
+ filehandle = _lcreat( filename, 4 ); /* SYSTEM file */
+
ok( HFILE_ERROR != filehandle, "couldn't create file. Wrong permissions on directory?" );
ok( HFILE_ERROR != _hwrite( filehandle, sillytext, strlen( sillytext ) ), "_hwrite complains." );
- ok( 0 == _llseek( filehandle, 0, FILE_BEGIN ), "_llseek complains." );
+ ok( 0 == _llseek( filehandle, 0, FILE_BEGIN ), "_llseek complains" );
ok( _hread( filehandle, buffer, strlen( sillytext ) ) == strlen( sillytext ), "erratic _hread return value." );
- ok( HFILE_ERROR != _lclose(filehandle), "_lclose complains." );
+ ok( HFILE_ERROR != _lclose(filehandle), "_lclose complains" );
- todo_wine
- {
- ok( INVALID_HANDLE_VALUE == FindFirstFileA( filename, &search_results ), "should NOT be able to find file" );
- }
+ ok( INVALID_HANDLE_VALUE != FindFirstFileA( filename, &search_results ), "should still be able to find file");
- ok( DeleteFileA( filename ) != 0, "DeleteFileA complains." );
+ ok( DeleteFileA( filename ) != 0, "DeleteFileA complains" );
}
@@ -287,7 +302,7 @@
HFILE filehandle;
UINT bytes_read;
char buffer[10000];
-
+
filehandle = _lcreat( filename, 0 );
ok( HFILE_ERROR != filehandle, "couldn't create file. Wrong permissions on directory?" );
ok( HFILE_ERROR != _hwrite( filehandle, sillytext, strlen( sillytext ) ), "_hwrite complains." );
@@ -430,6 +445,7 @@
ok( HFILE_ERROR != _lclose( filehandle ), "_lclose complains." );
ok( DeleteFileA( filename ) != 0, "DeleteFile complains." );
+ /* TODO - add tests for the SHARE modes - use two processes to pull this one off */
}
More information about the wine-patches
mailing list