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
95988a9f
Commit
95988a9f
authored
Mar 28, 2017
by
Jacek Caban
Committed by
Alexandre Julliard
Mar 28, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32/tests: Added tests of pipe write cancelled on process termintation.
Signed-off-by:
Jacek Caban
<
jacek@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
d12728a8
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
1 deletion
+63
-1
pipe.c
dlls/kernel32/tests/pipe.c
+63
-1
No files found.
dlls/kernel32/tests/pipe.c
View file @
95988a9f
...
...
@@ -2807,6 +2807,34 @@ static void test_blocking_rw(HANDLE writer, HANDLE reader, DWORD buf_size, BOOL
test_flush_done
(
flush_thread
);
}
static
void
child_process_write_pipe
(
HANDLE
pipe
)
{
OVERLAPPED
overlapped
;
char
buf
[
10000
];
memset
(
buf
,
'x'
,
sizeof
(
buf
));
overlapped_write_async
(
pipe
,
buf
,
sizeof
(
buf
),
&
overlapped
);
/* sleep until parent process terminates this process */
Sleep
(
INFINITE
);
}
static
HANDLE
create_writepipe_process
(
HANDLE
pipe
)
{
STARTUPINFOA
si
=
{
sizeof
(
si
)
};
PROCESS_INFORMATION
info
;
char
**
argv
,
buf
[
MAX_PATH
];
BOOL
res
;
winetest_get_mainargs
(
&
argv
);
sprintf
(
buf
,
"
\"
%s
\"
pipe writepipe %lx"
,
argv
[
0
],
(
UINT_PTR
)
pipe
);
res
=
CreateProcessA
(
NULL
,
buf
,
NULL
,
NULL
,
TRUE
,
0L
,
NULL
,
NULL
,
&
si
,
&
info
);
ok
(
res
,
"CreateProcess failed: %u
\n
"
,
GetLastError
());
CloseHandle
(
info
.
hThread
);
return
info
.
hProcess
;
}
static
void
create_overlapped_pipe
(
DWORD
mode
,
HANDLE
*
client
,
HANDLE
*
server
)
{
SECURITY_ATTRIBUTES
sec_attr
=
{
sizeof
(
sec_attr
),
NULL
,
TRUE
};
...
...
@@ -2826,7 +2854,7 @@ static void create_overlapped_pipe(DWORD mode, HANDLE *client, HANDLE *server)
test_not_signaled
(
*
server
);
test_not_signaled
(
overlapped
.
hEvent
);
*
client
=
CreateFileA
(
PIPENAME
,
GENERIC_READ
|
GENERIC_WRITE
,
0
,
NULL
,
OPEN_EXISTING
,
FILE_FLAG_OVERLAPPED
,
NULL
);
*
client
=
CreateFileA
(
PIPENAME
,
GENERIC_READ
|
GENERIC_WRITE
,
0
,
&
sec_attr
,
OPEN_EXISTING
,
FILE_FLAG_OVERLAPPED
,
NULL
);
ok
(
*
server
!=
INVALID_HANDLE_VALUE
,
"CreateFile failed: %u
\n
"
,
GetLastError
());
res
=
SetNamedPipeHandleState
(
*
client
,
&
read_mode
,
NULL
,
NULL
);
...
...
@@ -2841,6 +2869,8 @@ static void test_overlapped_transport(BOOL msg_mode, BOOL msg_read_mode)
{
OVERLAPPED
overlapped
,
overlapped2
;
HANDLE
server
,
client
,
flush
;
DWORD
read_bytes
;
HANDLE
process
;
char
buf
[
60000
];
BOOL
res
;
...
...
@@ -2890,10 +2920,32 @@ static void test_overlapped_transport(BOOL msg_mode, BOOL msg_read_mode)
test_flush_done
(
flush
);
CloseHandle
(
server
);
CloseHandle
(
client
);
/* terminate process with pending write */
create_overlapped_pipe
(
create_flags
,
&
client
,
&
server
);
process
=
create_writepipe_process
(
client
);
/* succesfully read part of write that is pending in child process */
res
=
ReadFile
(
server
,
buf
,
10
,
&
read_bytes
,
NULL
);
if
(
!
msg_read_mode
)
ok
(
res
,
"ReadFile failed: %u
\n
"
,
GetLastError
());
else
ok
(
!
res
&&
GetLastError
()
==
ERROR_MORE_DATA
,
"ReadFile returned: %x %u
\n
"
,
res
,
GetLastError
());
ok
(
read_bytes
==
10
,
"read_bytes = %u
\n
"
,
read_bytes
);
TerminateProcess
(
process
,
0
);
winetest_wait_child_process
(
process
);
/* after terminating process, there is no pending write and pipe buffer is empty */
overlapped_read_async
(
server
,
buf
,
10
,
&
overlapped
);
overlapped_write_sync
(
client
,
buf
,
1
);
test_overlapped_result
(
server
,
&
overlapped
,
1
,
FALSE
);
CloseHandle
(
process
);
CloseHandle
(
server
);
CloseHandle
(
client
);
}
START_TEST
(
pipe
)
{
char
**
argv
;
int
argc
;
HMODULE
hmod
;
hmod
=
GetModuleHandleA
(
"advapi32.dll"
);
...
...
@@ -2902,6 +2954,16 @@ START_TEST(pipe)
pQueueUserAPC
=
(
void
*
)
GetProcAddress
(
hmod
,
"QueueUserAPC"
);
pCancelIoEx
=
(
void
*
)
GetProcAddress
(
hmod
,
"CancelIoEx"
);
argc
=
winetest_get_mainargs
(
&
argv
);
if
(
argc
>
3
&&
!
strcmp
(
argv
[
2
],
"writepipe"
))
{
UINT_PTR
handle
;
sscanf
(
argv
[
3
],
"%lx"
,
&
handle
);
child_process_write_pipe
((
HANDLE
)
handle
);
return
;
}
if
(
test_DisconnectNamedPipe
())
return
;
test_CreateNamedPipe_instances_must_match
();
...
...
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