Test for DeleteFile
Uwe Bonnes
bon at elektron.ikp.physik.tu-darmstadt.de
Thu May 9 15:13:22 CDT 2002
Changelog:
dlls/kernel/file.c:
New DeleteFile test, account for DeleteFile Behaviour on R/O files
--
Uwe Bonnes bon at elektron.ikp.physik.tu-darmstadt.de
Free Software: If you contribute nothing, expect nothing
--
Index: wine/dlls/kernel/tests/file.c
===================================================================
RCS file: /home/wine/wine/dlls/kernel/tests/file.c,v
retrieving revision 1.2
diff -u -r1.2 file.c
--- wine/dlls/kernel/tests/file.c 6 May 2002 20:12:55 -0000 1.2
+++ wine/dlls/kernel/tests/file.c 9 May 2002 20:12:54 -0000
@@ -47,6 +47,8 @@
UINT bytes_wanted;
UINT i;
+ SetFileAttributesA(filename,FILE_ATTRIBUTE_NORMAL); /* be sure to remove stale files */
+ DeleteFileA( filename );
filehandle = _lcreat( filename, 0 );
ok( HFILE_ERROR != filehandle, "couldn't create file. Wrong permissions on directory?" );
@@ -195,7 +197,7 @@
ok( DeleteFileA( filename ) != 0, "DeleteFileA complains." );
- filehandle = _lcreat( filename, 1 );
+ filehandle = _lcreat( filename, 1 ); /* READONLY Delete should fail until attribute reset */
ok( HFILE_ERROR != filehandle, "couldn't create file!?" );
#if 0 /* FIXME: this fails on NT too */
@@ -206,8 +208,11 @@
ok( INVALID_HANDLE_VALUE != FindFirstFileA( filename, &search_results ), "should be able to find file" );
- ok( DeleteFileA( filename ) != 0, "DeleteFileA complains." );
+ ok( DeleteFileA( filename ) == 0, "DeleteFileA unexpectedly succeeded" );
+
+ ok( SetFileAttributesA(filename,FILE_ATTRIBUTE_NORMAL), "SetFileAttributes failed");
+ ok( DeleteFileA( filename ) != 0, "DeleteFileA complains." );
filehandle = _lcreat( filename, 2 );
ok( HFILE_ERROR != filehandle, "couldn't create file. Wrong permissions on directory?" );
@@ -226,7 +231,7 @@
}
ok( DeleteFileA( filename ) != 0, "DeleteFileA complains." );
-
+
filehandle = _lcreat( filename, 4 );
ok( HFILE_ERROR != filehandle, "couldn't create file. Wrong permissions on directory?" );
@@ -314,6 +319,25 @@
/* TODO - add tests for the SHARE modes - use two processes to pull this off */
}
+void test_DeleteFile( void )
+{
+ DWORD len, errnmb;
+
+ CHAR filename[MAX_PATH];
+ INT res;
+
+ /* Test if we can erase the running executable
+ More special cases are tested above
+ */
+ len = GetModuleFileNameA(0,filename,MAX_PATH);
+ ok(len,"Can't get name of running executable");
+ res=DeleteFileA(filename);
+ ok(!res,"Shouldn't succeed in deleting running executable");
+ errnmb = GetLastError();
+ ok(errnmb == ERROR_ACCESS_DENIED,"Got wrong error number %d expected %d", errnmb, ERROR_ACCESS_DENIED);
+
+}
+
START_TEST(file)
{
test__hread( );
@@ -322,4 +346,5 @@
test__lcreat( );
test__llseek( );
test__llopen( );
+ test_DeleteFile( );
}
More information about the wine-patches
mailing list