Hi Brendan, On 10/1/19 6:16 PM, Brendan Shanks wrote:
Signed-off-by: Brendan Shanks <bshanks(a)codeweavers.com> --- dlls/kernel32/tests/pipe.c | 108 +++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+)
diff --git a/dlls/kernel32/tests/pipe.c b/dlls/kernel32/tests/pipe.c index f61d441303..227575ece3 100644 --- a/dlls/kernel32/tests/pipe.c +++ b/dlls/kernel32/tests/pipe.c @@ -3887,6 +3887,113 @@ static void test_wait_pipe(void) CloseHandle(ov.hEvent); }
+static DWORD CALLBACK test_nowait_read_thread(LPVOID arg) +{ + HANDLE *pipewrite = arg; + static const char buf[] = "bits"; + DWORD written; + + Sleep(2000); + WriteFile(*pipewrite, buf, sizeof(buf), &written, NULL); + return 0; +} +static DWORD CALLBACK test_nowait_write_thread(LPVOID arg) +{ + HANDLE *piperead = arg; + char buf[32768]; + DWORD read; + + Sleep(2000); + ReadFile(*piperead, buf, sizeof(buf), &read, NULL); + return 0; +} +static DWORD CALLBACK test_nowait_connect_thread(LPVOID arg) +{ + HANDLE hFile; + + Sleep(2000); + hFile = CreateFileA(PIPENAME, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0); + ok(hFile != INVALID_HANDLE_VALUE, "CreateFileA failed\n"); + ok(CloseHandle(hFile), "CloseHandle failed\n"); + return 0; +}
I'd expect that those tests would be more reliable and cleaner if you used overlapped handles. You could have one pipe end non-blocking and the other end overlapped to test everything using one thread in a predictable way. If you carefully choose buffer sizes, you could make those tests more precise. See test_blocking_rw for an example.
+ /* WriteFile only documents that 'write < sizeof(readbuf)' for this case, but Windows + * doesn't seem to do partial writes ('write == 0' always) + */
If Windows doesn't do partial writes, it would be actually interesting to test and implement. Thanks, Jacek