Add another test case for file sharing
Dmitry Timoshkov
dmitry at baikal.ru
Mon Feb 28 00:02:22 CST 2005
Hello,
this test passes under Wine.
Changelog:
Dmitry Timoshkov <dmitry at codeweavers.com>
Add another test case for file sharing.
--- cvs/hq/wine/dlls/kernel/tests/file.c Fri Feb 11 03:46:52 2005
+++ wine/dlls/kernel/tests/file.c Mon Feb 28 05:54:11 2005
@@ -1076,17 +1076,23 @@ static void test_file_sharing(void)
static const DWORD sharing_modes[4] = { 0, FILE_SHARE_READ, FILE_SHARE_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE };
int a1, s1, a2, s2;
int ret;
+ HANDLE h, h2;
/* make sure the file exists */
- HANDLE h = CreateFileA( filename, GENERIC_READ|GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0 );
+ h = CreateFileA( filename, GENERIC_READ|GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0 );
+ if (h == INVALID_HANDLE_VALUE)
+ {
+ ok(0, "couldn't create file \"%s\" (err=%ld)\n", filename, GetLastError());
+ return;
+ }
CloseHandle( h );
for (a1 = 0; a1 < 4; a1++)
{
for (s1 = 0; s1 < 4; s1++)
{
- HANDLE h = CreateFileA( filename, access_modes[a1], sharing_modes[s1],
- NULL, OPEN_EXISTING, 0, 0 );
+ h = CreateFileA( filename, access_modes[a1], sharing_modes[s1],
+ NULL, OPEN_EXISTING, 0, 0 );
if (h == INVALID_HANDLE_VALUE)
{
ok(0,"couldn't create file \"%s\" (err=%ld)\n",filename,GetLastError());
@@ -1096,8 +1102,9 @@ static void test_file_sharing(void)
{
for (s2 = 0; s2 < 4; s2++)
{
- HANDLE h2 = CreateFileA( filename, access_modes[a2], sharing_modes[s2],
- NULL, OPEN_EXISTING, 0, 0 );
+ SetLastError(0xdeadbeef);
+ h2 = CreateFileA( filename, access_modes[a2], sharing_modes[s2],
+ NULL, OPEN_EXISTING, 0, 0 );
if (is_sharing_compatible( access_modes[a1], sharing_modes[s1],
access_modes[a2], sharing_modes[s2] ))
{
@@ -1129,6 +1136,22 @@ static void test_file_sharing(void)
CloseHandle( h );
}
}
+
+ SetLastError(0xdeadbeef);
+ h = CreateFileA( filename, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS, 0, 0 );
+ ok( h != INVALID_HANDLE_VALUE, "CreateFileA error %ld\n", GetLastError() );
+
+ SetLastError(0xdeadbeef);
+ h2 = CreateFileA( filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0 );
+ ok( h2 == INVALID_HANDLE_VALUE, "CreateFileA should fail\n");
+ ok( GetLastError() == ERROR_SHARING_VIOLATION, "wrong error code %ld\n", GetLastError() );
+
+ h2 = CreateFileA( filename, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0 );
+ ok( h2 != INVALID_HANDLE_VALUE, "CreateFileA error %ld\n", GetLastError() );
+
+ CloseHandle(h);
+ CloseHandle(h2);
+
DeleteFileA( filename );
}
More information about the wine-patches
mailing list