Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
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-winehq
Commits
752416f7
Commit
752416f7
authored
Nov 20, 2008
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32/tests: Fix the mailslot tests on Win9x.
parent
d523c86a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
30 deletions
+47
-30
mailslot.c
dlls/kernel32/tests/mailslot.c
+47
-30
No files found.
dlls/kernel32/tests/mailslot.c
View file @
752416f7
...
...
@@ -34,6 +34,7 @@ static int mailslot_test(void)
HANDLE
hSlot
,
hSlot2
,
hWriter
,
hWriter2
;
unsigned
char
buffer
[
16
];
DWORD
count
,
dwMax
,
dwNext
,
dwMsgCount
,
dwTimeout
;
BOOL
ret
;
/* sanity check on GetMailslotInfo */
dwMax
=
dwNext
=
dwMsgCount
=
dwTimeout
=
0
;
...
...
@@ -54,10 +55,13 @@ static int mailslot_test(void)
/* open a mailslot with a null name */
hSlot
=
CreateMailslot
(
NULL
,
0
,
0
,
NULL
);
ok
(
hSlot
==
INVALID_HANDLE_VALUE
,
"Created mailslot with invalid name
\n
"
);
ok
(
GetLastError
()
==
ERROR_PATH_NOT_FOUND
,
ok
(
hSlot
==
INVALID_HANDLE_VALUE
||
broken
(
hSlot
!=
INVALID_HANDLE_VALUE
),
/* win9x */
"Created mailslot with invalid name
\n
"
);
if
(
hSlot
==
INVALID_HANDLE_VALUE
)
ok
(
GetLastError
()
==
ERROR_PATH_NOT_FOUND
,
"error should be ERROR_PATH_NOT_FOUND
\n
"
);
else
/* succeeds on win9x */
CloseHandle
(
hSlot
);
/* valid open, but with wacky parameters ... then check them */
hSlot
=
CreateMailslot
(
szmspath
,
-
1
,
-
1
,
NULL
);
...
...
@@ -80,32 +84,36 @@ static int mailslot_test(void)
/* try and read/write to it */
count
=
0
;
memset
(
buffer
,
0
,
sizeof
buffer
);
ok
(
!
ReadFile
(
hSlot
,
buffer
,
sizeof
buffer
,
&
count
,
NULL
),
"slot read
\n
"
);
ok
(
GetLastError
()
==
ERROR_SEM_TIMEOUT
,
"wrong error %u
\n
"
,
GetLastError
()
);
ret
=
ReadFile
(
hSlot
,
buffer
,
sizeof
buffer
,
&
count
,
NULL
);
ok
(
!
ret
||
broken
(
ret
),
/* win9x */
"slot read
\n
"
);
if
(
!
ret
)
ok
(
GetLastError
()
==
ERROR_SEM_TIMEOUT
,
"wrong error %u
\n
"
,
GetLastError
()
);
else
ok
(
count
==
0
,
"wrong count %u
\n
"
,
count
);
ok
(
!
WriteFile
(
hSlot
,
buffer
,
sizeof
buffer
,
&
count
,
NULL
),
"slot write
\n
"
);
ok
(
GetLastError
()
==
ERROR_ACCESS_DENIED
,
"wrong error %u
\n
"
,
GetLastError
()
);
/* now try and openthe client, but with the wrong sharing mode */
hWriter
=
CreateFile
(
szmspath
,
GENERIC_
READ
|
GENERIC_
WRITE
,
/* now try and open
the client, but with the wrong sharing mode */
hWriter
=
CreateFile
(
szmspath
,
GENERIC_WRITE
,
0
,
NULL
,
OPEN_EXISTING
,
0
,
NULL
);
ok
(
hWriter
!=
INVALID_HANDLE_VALUE
/* vista */
||
GetLastError
()
==
ERROR_SHARING_VIOLATION
,
"error should be ERROR_SHARING_VIOLATION
\n
"
);
"error should be ERROR_SHARING_VIOLATION got %p / %u
\n
"
,
hWriter
,
GetLastError
()
);
if
(
hWriter
!=
INVALID_HANDLE_VALUE
)
CloseHandle
(
hWriter
);
/* now open the client with the correct sharing mode */
hWriter
=
CreateFile
(
szmspath
,
GENERIC_READ
|
GENERIC_WRITE
,
FILE_SHARE_READ
,
NULL
,
OPEN_EXISTING
,
0
,
NULL
);
ok
(
hWriter
!=
INVALID_HANDLE_VALUE
,
"existing mailslot
\n
"
);
if
(
hWriter
==
INVALID_HANDLE_VALUE
)
/* win9x doesn't like GENERIC_READ */
hWriter
=
CreateFile
(
szmspath
,
GENERIC_WRITE
,
FILE_SHARE_READ
,
NULL
,
OPEN_EXISTING
,
0
,
NULL
);
ok
(
hWriter
!=
INVALID_HANDLE_VALUE
,
"existing mailslot err %u
\n
"
,
GetLastError
());
/*
* opening a client should make no difference to
* whether we can read or write the mailslot
*/
ok
(
!
ReadFile
(
hSlot
,
buffer
,
sizeof
buffer
/
2
,
&
count
,
NULL
),
"slot read
\n
"
);
ok
(
GetLastError
()
==
ERROR_SEM_TIMEOUT
,
"wrong error %u
\n
"
,
GetLastError
()
);
ret
=
ReadFile
(
hSlot
,
buffer
,
sizeof
buffer
/
2
,
&
count
,
NULL
);
ok
(
!
ret
||
broken
(
ret
),
/* win9x */
"slot read
\n
"
);
if
(
!
ret
)
ok
(
GetLastError
()
==
ERROR_SEM_TIMEOUT
,
"wrong error %u
\n
"
,
GetLastError
()
);
else
ok
(
count
==
0
,
"wrong count %u
\n
"
,
count
);
ok
(
!
WriteFile
(
hSlot
,
buffer
,
sizeof
buffer
/
2
,
&
count
,
NULL
),
"slot write
\n
"
);
ok
(
GetLastError
()
==
ERROR_ACCESS_DENIED
,
"wrong error %u
\n
"
,
GetLastError
()
);
...
...
@@ -116,12 +124,14 @@ static int mailslot_test(void)
*/
ok
(
!
ReadFile
(
hWriter
,
buffer
,
sizeof
buffer
/
2
,
&
count
,
NULL
),
"can read client
\n
"
);
todo_wine
ok
(
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"wrong error %u
\n
"
,
GetLastError
()
);
ok
(
GetLastError
()
==
ERROR_INVALID_PARAMETER
||
GetLastError
()
==
ERROR_ACCESS_DENIED
,
"wrong error %u
\n
"
,
GetLastError
()
);
ok
(
WriteFile
(
hWriter
,
buffer
,
sizeof
buffer
/
2
,
&
count
,
NULL
),
"can't write client
\n
"
);
ok
(
!
ReadFile
(
hWriter
,
buffer
,
sizeof
buffer
/
2
,
&
count
,
NULL
),
"can read client
\n
"
);
todo_wine
ok
(
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"wrong error %u
\n
"
,
GetLastError
()
);
ok
(
GetLastError
()
==
ERROR_INVALID_PARAMETER
||
GetLastError
()
==
ERROR_ACCESS_DENIED
,
"wrong error %u
\n
"
,
GetLastError
()
);
/*
* seeing as there's something in the slot,
...
...
@@ -132,9 +142,10 @@ static int mailslot_test(void)
ok
(
count
==
(
sizeof
buffer
/
2
),
"short read
\n
"
);
/* but not again */
ok
(
!
ReadFile
(
hSlot
,
buffer
,
sizeof
buffer
,
&
count
,
NULL
),
"slot read
\n
"
);
ok
(
GetLastError
()
==
ERROR_SEM_TIMEOUT
,
"wrong error %u
\n
"
,
GetLastError
()
);
ret
=
ReadFile
(
hSlot
,
buffer
,
sizeof
buffer
,
&
count
,
NULL
);
ok
(
!
ret
||
broken
(
ret
),
/* win9x */
"slot read
\n
"
);
if
(
!
ret
)
ok
(
GetLastError
()
==
ERROR_SEM_TIMEOUT
,
"wrong error %u
\n
"
,
GetLastError
()
);
else
ok
(
count
==
0
,
"wrong count %u
\n
"
,
count
);
/* now try open another writer... should fail */
hWriter2
=
CreateFile
(
szmspath
,
GENERIC_READ
|
GENERIC_WRITE
,
...
...
@@ -193,8 +204,10 @@ static int mailslot_test(void)
ok
(
dwTimeout
==
0
,
"dwTimeout incorrect
\n
"
);
/* check there's still no data */
ok
(
!
ReadFile
(
hSlot
,
buffer
,
sizeof
buffer
,
&
count
,
NULL
),
"slot read
\n
"
);
ok
(
GetLastError
()
==
ERROR_SEM_TIMEOUT
,
"wrong error %u
\n
"
,
GetLastError
()
);
ret
=
ReadFile
(
hSlot
,
buffer
,
sizeof
buffer
,
&
count
,
NULL
);
ok
(
!
ret
||
broken
(
ret
),
/* win9x */
"slot read
\n
"
);
if
(
!
ret
)
ok
(
GetLastError
()
==
ERROR_SEM_TIMEOUT
,
"wrong error %u
\n
"
,
GetLastError
()
);
else
ok
(
count
==
0
,
"wrong count %u
\n
"
,
count
);
/* write two messages */
buffer
[
0
]
=
'a'
;
...
...
@@ -228,9 +241,9 @@ static int mailslot_test(void)
ok
(
GetMailslotInfo
(
hSlot
,
NULL
,
&
dwNext
,
&
dwMsgCount
,
NULL
),
"getmailslotinfo failed
\n
"
);
ok
(
dwNext
==
1
,
"dwNext incorrect
\n
"
);
todo_wine
{
ok
(
dwMsgCount
==
3
,
"dwMsgCount incorrect
\n
"
);
}
todo_wine
ok
(
dwMsgCount
==
3
||
broken
(
dwMsgCount
==
2
),
/* win9x */
"dwMsgCount incorrect %u
\n
"
,
dwMsgCount
);
buffer
[
0
]
=
buffer
[
1
]
=
0
;
...
...
@@ -249,7 +262,8 @@ static int mailslot_test(void)
"getmailslotinfo failed
\n
"
);
ok
(
dwNext
==
2
,
"dwNext incorrect
\n
"
);
todo_wine
{
ok
(
dwMsgCount
==
2
,
"dwMsgCount incorrect
\n
"
);
ok
(
dwMsgCount
==
2
||
broken
(
dwMsgCount
==
1
),
/* win9x */
"dwMsgCount incorrect %u
\n
"
,
dwMsgCount
);
}
/* read the second message */
...
...
@@ -262,9 +276,10 @@ static int mailslot_test(void)
dwNext
=
dwMsgCount
=
0
;
ok
(
GetMailslotInfo
(
hSlot
,
NULL
,
&
dwNext
,
&
dwMsgCount
,
NULL
),
"getmailslotinfo failed
\n
"
);
ok
(
dwNext
==
0
,
"dwNext incorrect
\n
"
);
ok
(
dwNext
==
0
||
broken
(
dwNext
==
~
0u
),
/* win9x */
"dwNext incorrect %u
\n
"
,
dwNext
);
todo_wine
{
ok
(
dwMsgCount
==
1
,
"dwMsgCount incorrect
\n
"
);
ok
(
dwMsgCount
==
1
||
broken
(
dwMsgCount
==
0
),
/* win9x */
"dwMsgCount incorrect %u
\n
"
,
dwMsgCount
);
}
/* read the 3rd (zero length) message */
...
...
@@ -285,9 +300,10 @@ static int mailslot_test(void)
ok
(
dwMsgCount
==
0
,
"dwMsgCount incorrect
\n
"
);
/* check that reads fail */
ok
(
!
ReadFile
(
hSlot
,
buffer
,
sizeof
buffer
,
&
count
,
NULL
),
"3rd slot read succeeded
\n
"
);
ok
(
GetLastError
()
==
ERROR_SEM_TIMEOUT
,
"wrong error %u
\n
"
,
GetLastError
()
);
ret
=
ReadFile
(
hSlot
,
buffer
,
sizeof
buffer
,
&
count
,
NULL
);
ok
(
!
ret
||
broken
(
ret
),
/* win9x */
"3rd slot read succeeded
\n
"
);
if
(
!
ret
)
ok
(
GetLastError
()
==
ERROR_SEM_TIMEOUT
,
"wrong error %u
\n
"
,
GetLastError
()
);
else
ok
(
count
==
0
,
"wrong count %u
\n
"
,
count
);
/* finally close the mailslot and its client */
ok
(
CloseHandle
(
hWriter2
),
"closing 2nd client
\n
"
);
...
...
@@ -301,7 +317,8 @@ static int mailslot_test(void)
memset
(
buffer
,
0
,
sizeof
buffer
);
dwTimeout
=
GetTickCount
();
ok
(
!
ReadFile
(
hSlot
,
buffer
,
sizeof
buffer
,
&
count
,
NULL
),
"slot read
\n
"
);
ok
(
GetLastError
()
==
ERROR_SEM_TIMEOUT
,
"wrong error %u
\n
"
,
GetLastError
()
);
ok
(
GetLastError
()
==
ERROR_SEM_TIMEOUT
||
broken
(
GetLastError
()
==
ERROR_ACCESS_DENIED
),
/* win9x */
"wrong error %u
\n
"
,
GetLastError
()
);
dwTimeout
=
GetTickCount
()
-
dwTimeout
;
ok
(
dwTimeout
>=
990
,
"timeout too short %u
\n
"
,
dwTimeout
);
ok
(
CloseHandle
(
hSlot
),
"closing the mailslot
\n
"
);
...
...
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