With this patch the kernel/file tests should pass successfully on NT4 and on Win95/Win98, except for the overlapped tests for this latter platform. Apparently Win9x does not support overlapped file access so all the related tests fail. Help with cleanly skipping these tests when on Win9x would be appreciated. This patch also fixes the error code returned by DeleteFileW to match the NT ones. Before the returned code did not match the one returned by either Win9x or NT. Changelog: * files/file.c, dlls/kernel/tests/file.c Fix the error codes returned by DeleteFile{A,W} to match NT Adapt the DeleteFileA error code checks to take into account vaiations between Win9x and NT Test DeleteFile(NULL) Add tests for DeleteFileW On NT, calling _lclose on an already closed handle will cause memory corruption and thus sometimes crash -> removed the relevant test Skip the Unicode tests when on Win9x Index: files/file.c =================================================================== RCS file: /home/wine/wine/files/file.c,v retrieving revision 1.171 diff -u -r1.171 file.c --- files/file.c 30 Nov 2002 01:48:32 -0000 1.171 +++ files/file.c 11 Dec 2002 02:55:04 -0000 @@ -2418,17 +2418,10 @@ DOS_FULL_NAME full_name; HANDLE hFile; - if (!path) - { - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } TRACE("%s\n", debugstr_w(path) ); - - if (!*path) + if (!path || !*path) { - WARN("Empty path passed\n"); - SetLastError( ERROR_FILE_NOT_FOUND ); + SetLastError(ERROR_PATH_NOT_FOUND); return FALSE; } if (DOSFS_GetDevice( path )) Index: dlls/kernel/tests/file.c =================================================================== RCS file: /home/wine/wine/dlls/kernel/tests/file.c,v retrieving revision 1.11 diff -u -r1.11 file.c --- dlls/kernel/tests/file.c 12 Nov 2002 02:11:52 -0000 1.11 +++ dlls/kernel/tests/file.c 11 Dec 2002 02:54:55 -0000 @@ -184,10 +184,6 @@ ok( HFILE_ERROR != _lclose(filehandle), "_lclose complains" ); - ok( HFILE_ERROR == _lclose(filehandle), "_lclose should whine about this" ); - - ok( HFILE_ERROR == _lclose(filehandle), "_lclose should whine about this" ); - ok( DeleteFileA( filename ) != 0, "DeleteFile failed (%ld)", GetLastError( ) ); } @@ -501,6 +497,8 @@ DWORD ret; ret = GetTempPathW(MAX_PATH, temp_path); + if (ret==0 && GetLastError()==ERROR_CALL_NOT_IMPLEMENTED) + return; ok(ret != 0, "GetTempPathW error %ld", GetLastError()); ok(ret < MAX_PATH, "temp path should fit into MAX_PATH"); @@ -556,6 +554,8 @@ DWORD ret; ret = GetTempPathW(MAX_PATH, temp_path); + if (ret==0 && GetLastError()==ERROR_CALL_NOT_IMPLEMENTED) + return; ok(ret != 0, "GetTempPathW error %ld", GetLastError()); ok(ret < MAX_PATH, "temp path should fit into MAX_PATH"); @@ -574,12 +574,35 @@ static void test_DeleteFileA( void ) { BOOL ret; + + ret = DeleteFileA(NULL); + ok(!ret && (GetLastError() == ERROR_INVALID_PARAMETER || + GetLastError() == ERROR_PATH_NOT_FOUND), + "DeleteFileA(NULL) returned ret=%d error=%ld",ret,GetLastError()); + ret = DeleteFileA(""); - ok((!ret) && (GetLastError() == ERROR_FILE_NOT_FOUND), - "DeleteFile should fail with an empty path, and last error value should be ERROR_FILE_NOT_FOUND"); + ok(!ret && (GetLastError() == ERROR_PATH_NOT_FOUND || + GetLastError() == ERROR_BAD_PATHNAME), + "DeleteFileA(\"\") returned ret=%d error=%ld",ret,GetLastError()); +} + +static void test_DeleteFileW( void ) +{ + BOOL ret; + WCHAR emptyW[]={'\0'}; + + ret = DeleteFileW(NULL); + if (ret==0 && GetLastError()==ERROR_CALL_NOT_IMPLEMENTED) + return; + ok(!ret && GetLastError() == ERROR_PATH_NOT_FOUND, + "DeleteFileW(NULL) returned ret=%d error=%ld",ret,GetLastError()); + + ret = DeleteFileW(emptyW); + ok(!ret && GetLastError() == ERROR_PATH_NOT_FOUND, + "DeleteFileW(\"\") returned ret=%d error=%ld",ret,GetLastError()); } -#define PATTERN_OFFSET 0x10 +#define PATTERN_OFFSET 0x10 void test_offset_in_overlapped_structure(void) { @@ -657,5 +680,6 @@ test_CreateFileA(); test_CreateFileW(); test_DeleteFileA(); + test_DeleteFileW(); test_offset_in_overlapped_structure(); } -- Francois Gouget fgouget@free.fr http://fgouget.free.fr/ Linux: the choice of a GNU generation