From 96aca1ad02a129f8bae5f0b9ad02cd59f6f74942 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20M=C3=BCller?= Date: Thu, 7 Apr 2016 08:45:53 +0200 Subject: [PATCH] kernel32/tests: Add additional tests for overlapped handling of CreateNamedPipe. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michael Müller Signed-off-by: Sebastian Lackner Signed-off-by: Alexandre Julliard --- dlls/kernel32/tests/pipe.c | 59 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/dlls/kernel32/tests/pipe.c b/dlls/kernel32/tests/pipe.c index 60336f86263..77381f2ac19 100644 --- a/dlls/kernel32/tests/pipe.c +++ b/dlls/kernel32/tests/pipe.c @@ -2091,6 +2091,64 @@ static void test_overlapped(void) CloseHandle(thread); } +static void test_overlapped_error(void) +{ + HANDLE pipe, file, event; + DWORD err, numbytes; + OVERLAPPED overlapped; + BOOL ret; + + event = CreateEventA(NULL, TRUE, FALSE, NULL); + ok(event != NULL, "CreateEventA failed with %u\n", GetLastError()); + + pipe = CreateNamedPipeA(PIPENAME, PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED, + PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT, + 1, 1024, 1024, NMPWAIT_WAIT_FOREVER, NULL); + ok(pipe != INVALID_HANDLE_VALUE, "CreateNamedPipe failed with %u\n", GetLastError()); + + memset(&overlapped, 0, sizeof(overlapped)); + overlapped.hEvent = event; + ret = ConnectNamedPipe(pipe, &overlapped); + err = GetLastError(); + ok(ret == FALSE, "ConnectNamedPipe succeeded\n"); + ok(err == ERROR_IO_PENDING, "expected ERROR_IO_PENDING, got %u\n", err); + + file = CreateFileA(PIPENAME, GENERIC_READ | GENERIC_WRITE, 0, NULL, + OPEN_EXISTING, FILE_FLAG_OVERLAPPED, 0); + ok(file != INVALID_HANDLE_VALUE, "CreateFile failed with %u\n", GetLastError()); + + numbytes = 0xdeadbeef; + ret = GetOverlappedResult(pipe, &overlapped, &numbytes, TRUE); + ok(ret == TRUE, "GetOverlappedResult failed\n"); + ok(numbytes == 0, "expected 0, got %u\n", numbytes); + ok(overlapped.Internal == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %08lx\n", overlapped.Internal); + + CloseHandle(file); + CloseHandle(pipe); + + pipe = CreateNamedPipeA(PIPENAME, PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED, + PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT, + 1, 1024, 1024, NMPWAIT_WAIT_FOREVER, NULL); + ok(pipe != INVALID_HANDLE_VALUE, "CreateNamedPipe failed with %u\n", GetLastError()); + + file = CreateFileA(PIPENAME, GENERIC_READ | GENERIC_WRITE, 0, NULL, + OPEN_EXISTING, FILE_FLAG_OVERLAPPED, 0); + ok(file != INVALID_HANDLE_VALUE, "CreateFile failed with %u\n", GetLastError()); + + memset(&overlapped, 0, sizeof(overlapped)); + overlapped.hEvent = event; + ret = ConnectNamedPipe(pipe, &overlapped); + err = GetLastError(); + ok(ret == FALSE, "ConnectNamedPipe succeeded\n"); + ok(err == ERROR_PIPE_CONNECTED, "expected ERROR_PIPE_CONNECTED, got %u\n", err); + todo_wine ok(overlapped.Internal == STATUS_PENDING, "expected STATUS_PENDING, got %08lx\n", overlapped.Internal); + + CloseHandle(file); + CloseHandle(pipe); + + CloseHandle(event); +} + static void test_NamedPipeHandleState(void) { HANDLE server, client; @@ -2372,6 +2430,7 @@ START_TEST(pipe) test_CloseHandle(); test_impersonation(); test_overlapped(); + test_overlapped_error(); test_NamedPipeHandleState(); test_readfileex_pending(); }