Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
1e7ba7c2
Commit
1e7ba7c2
authored
Jan 08, 2007
by
Dmitry Timoshkov
Committed by
Alexandre Julliard
Jan 08, 2007
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32: Fix the file sharing test to pass cleanly under XP and Win9x.
parent
cda39686
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
19 deletions
+45
-19
file.c
dlls/kernel32/tests/file.c
+45
-19
No files found.
dlls/kernel32/tests/file.c
View file @
1e7ba7c2
...
...
@@ -36,9 +36,10 @@ static int dll_capable(const char *dll, const char *function)
return
(
GetProcAddress
(
module
,
function
)
!=
NULL
);
}
LPCSTR
filename
=
"testfile.xxx"
;
LPCSTR
sillytext
=
/* keep filename and filenameW the same */
static
const
char
filename
[]
=
"testfile.xxx"
;
static
const
WCHAR
filenameW
[]
=
{
't'
,
'e'
,
's'
,
't'
,
'f'
,
'i'
,
'l'
,
'e'
,
'.'
,
'x'
,
'x'
,
'x'
,
0
};
static
const
char
sillytext
[]
=
"en larvig liten text dx
\033
gx hej 84 hej 4484 !
\001\033
bla bl
\n
a.. bla bla."
"1234 43 4kljf lf &%%%&&&&&& 34 4 34 3############# 33 3 3 3 # 3## 3"
"1234 43 4kljf lf &%%%&&&&&& 34 4 34 3############# 33 3 3 3 # 3## 3"
...
...
@@ -1075,9 +1076,22 @@ static void test_LockFile(void)
DeleteFileA
(
filename
);
}
static
inline
int
is_sharing_compatible
(
DWORD
access1
,
DWORD
sharing1
,
DWORD
access2
,
DWORD
sharing2
)
static
inline
int
is_sharing_compatible
(
DWORD
access1
,
DWORD
sharing1
,
DWORD
access2
,
DWORD
sharing2
,
BOOL
is_win9x
)
{
if
(
!
access1
||
!
access2
)
return
1
;
if
(
!
is_win9x
)
{
if
(
!
access1
)
sharing1
=
FILE_SHARE_READ
|
FILE_SHARE_WRITE
|
FILE_SHARE_DELETE
;
if
(
!
access2
)
sharing2
=
FILE_SHARE_READ
|
FILE_SHARE_WRITE
|
FILE_SHARE_DELETE
;
}
else
{
access1
&=
~
DELETE
;
if
(
!
access1
)
access1
=
GENERIC_READ
;
access2
&=
~
DELETE
;
if
(
!
access2
)
access2
=
GENERIC_READ
;
}
if
((
access1
&
GENERIC_READ
)
&&
!
(
sharing2
&
FILE_SHARE_READ
))
return
0
;
if
((
access1
&
GENERIC_WRITE
)
&&
!
(
sharing2
&
FILE_SHARE_WRITE
))
return
0
;
if
((
access1
&
DELETE
)
&&
!
(
sharing2
&
FILE_SHARE_DELETE
))
return
0
;
...
...
@@ -1100,6 +1114,7 @@ static void test_file_sharing(void)
int
a1
,
s1
,
a2
,
s2
;
int
ret
;
HANDLE
h
,
h2
;
BOOL
is_win9x
=
FALSE
;
/* make sure the file exists */
h
=
CreateFileA
(
filename
,
GENERIC_READ
|
GENERIC_WRITE
,
0
,
NULL
,
CREATE_ALWAYS
,
0
,
0
);
...
...
@@ -1108,12 +1123,18 @@ static void test_file_sharing(void)
ok
(
0
,
"couldn't create file
\"
%s
\"
(err=%d)
\n
"
,
filename
,
GetLastError
());
return
;
}
is_win9x
=
GetFileAttributesW
(
filenameW
)
==
INVALID_FILE_ATTRIBUTES
;
CloseHandle
(
h
);
for
(
a1
=
0
;
a1
<
sizeof
(
access_modes
)
/
sizeof
(
access_modes
[
0
]);
a1
++
)
{
for
(
s1
=
0
;
s1
<
sizeof
(
sharing_modes
)
/
sizeof
(
sharing_modes
[
0
]);
s1
++
)
{
/* Win9x doesn't support FILE_SHARE_DELETE */
if
(
is_win9x
&&
(
sharing_modes
[
s1
]
&
FILE_SHARE_DELETE
))
continue
;
SetLastError
(
0xdeadbeef
);
h
=
CreateFileA
(
filename
,
access_modes
[
a1
],
sharing_modes
[
s1
],
NULL
,
OPEN_EXISTING
,
0
,
0
);
if
(
h
==
INVALID_HANDLE_VALUE
)
...
...
@@ -1125,35 +1146,40 @@ static void test_file_sharing(void)
{
for
(
s2
=
0
;
s2
<
sizeof
(
sharing_modes
)
/
sizeof
(
sharing_modes
[
0
]);
s2
++
)
{
/* Win9x doesn't support FILE_SHARE_DELETE */
if
(
is_win9x
&&
(
sharing_modes
[
s2
]
&
FILE_SHARE_DELETE
))
continue
;
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
]
))
access_modes
[
a2
],
sharing_modes
[
s2
]
,
is_win9x
))
{
ret
=
GetLastError
();
ok
(
ERROR_SHARING_VIOLATION
==
ret
||
0
==
ret
,
"Windows 95 sets GetLastError() = ERROR_SHARING_VIOLATION and
\n
"
" Windows XP GetLastError() = 0, but now it is %d.
\n
"
" indexes = %d, %d, %d, %d
\n
"
" modes =
\n
%x/%x/%x/%x
\n
"
,
ret
,
a1
,
s1
,
a2
,
s2
,
ok
(
h2
!=
INVALID_HANDLE_VALUE
,
"open failed for modes %x/%x/%x/%x
\n
"
,
access_modes
[
a1
],
sharing_modes
[
s1
],
access_modes
[
a2
],
sharing_modes
[
s2
]
);
access_modes
[
a2
],
sharing_modes
[
s2
]
);
ok
(
ret
==
0xdeadbeef
/* Win9x */
||
ret
==
0
,
/* XP */
"wrong error code %d
\n
"
,
ret
);
CloseHandle
(
h2
);
}
else
{
ret
=
GetLastError
();
ok
(
h2
==
INVALID_HANDLE_VALUE
,
"open succeeded for modes %x/%x/%x/%x
\n
"
,
access_modes
[
a1
],
sharing_modes
[
s1
],
access_modes
[
a2
],
sharing_modes
[
s2
]
);
if
(
h2
==
INVALID_HANDLE_VALUE
)
ok
(
GetLastError
()
==
ERROR_SHARING_VIOLATION
,
"wrong error code %d
\n
"
,
GetLastError
()
);
ok
(
ret
==
ERROR_SHARING_VIOLATION
,
"wrong error code %d
\n
"
,
ret
);
}
if
(
h2
!=
INVALID_HANDLE_VALUE
)
CloseHandle
(
h2
);
}
}
CloseHandle
(
h
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment