[2/5] kernel32/tests: Add tests for sending empty message in combination with CloseHandle.

Sebastian Lackner sebastian at fds-team.de
Mon Nov 23 00:22:43 CST 2015


Signed-off-by: Sebastian Lackner <sebastian at fds-team.de>
---
 dlls/kernel32/tests/pipe.c |   58 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 58 insertions(+)

diff --git a/dlls/kernel32/tests/pipe.c b/dlls/kernel32/tests/pipe.c
index 7ce6ae3..4f1b238 100644
--- a/dlls/kernel32/tests/pipe.c
+++ b/dlls/kernel32/tests/pipe.c
@@ -1432,6 +1432,35 @@ static void test_CloseHandle(void)
 
     CloseHandle(hfile);
 
+    hpipe = CreateNamedPipeA(PIPENAME, PIPE_ACCESS_DUPLEX,
+                             PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT,
+                             1, 1024, 1024, NMPWAIT_USE_DEFAULT_WAIT, NULL);
+    ok(hpipe != INVALID_HANDLE_VALUE, "CreateNamedPipe failed with %u\n", GetLastError());
+
+    hfile = CreateFileA(PIPENAME, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0);
+    ok(hfile != INVALID_HANDLE_VALUE, "CreateFile failed with %u\n", GetLastError());
+
+    numbytes = 0xdeadbeef;
+    ret = WriteFile(hpipe, testdata, 0, &numbytes, NULL);
+    ok(ret, "WriteFile failed with %u\n", GetLastError());
+    ok(numbytes == 0, "expected 0, got %u\n", numbytes);
+
+    ret = CloseHandle(hpipe);
+    ok(ret, "CloseHandle failed with %u\n", GetLastError());
+
+    numbytes = 0xdeadbeef;
+    memset(buffer, 0, sizeof(buffer));
+    ret = ReadFile(hfile, buffer, sizeof(buffer), &numbytes, NULL);
+    todo_wine ok(ret, "ReadFile failed with %u\n", GetLastError());
+    ok(numbytes == 0, "expected 0, got %u\n", numbytes);
+
+    SetLastError(0xdeadbeef);
+    ret = ReadFile(hfile, buffer, 0, &numbytes, NULL);
+    ok(!ret, "ReadFile unexpectedly succeeded\n");
+    todo_wine ok(GetLastError() == ERROR_BROKEN_PIPE, "expected ERROR_BROKEN_PIPE, got %u\n", GetLastError());
+
+    CloseHandle(hfile);
+
     /* repeat test with hpipe <-> hfile swapped */
 
     hpipe = CreateNamedPipeA(PIPENAME, PIPE_ACCESS_DUPLEX,
@@ -1474,6 +1503,35 @@ static void test_CloseHandle(void)
     ok(GetLastError() == ERROR_BROKEN_PIPE, "expected ERROR_BROKEN_PIPE, got %u\n", GetLastError());
 
     CloseHandle(hpipe);
+
+    hpipe = CreateNamedPipeA(PIPENAME, PIPE_ACCESS_DUPLEX,
+                             PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT,
+                             1, 1024, 1024, NMPWAIT_USE_DEFAULT_WAIT, NULL);
+    ok(hpipe != INVALID_HANDLE_VALUE, "CreateNamedPipe failed with %u\n", GetLastError());
+
+    hfile = CreateFileA(PIPENAME, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0);
+    ok(hfile != INVALID_HANDLE_VALUE, "CreateFile failed with %u\n", GetLastError());
+
+    numbytes = 0xdeadbeef;
+    ret = WriteFile(hfile, testdata, 0, &numbytes, NULL);
+    ok(ret, "WriteFile failed with %u\n", GetLastError());
+    ok(numbytes == 0, "expected 0, got %u\n", numbytes);
+
+    ret = CloseHandle(hfile);
+    ok(ret, "CloseHandle failed with %u\n", GetLastError());
+
+    numbytes = 0xdeadbeef;
+    memset(buffer, 0, sizeof(buffer));
+    ret = ReadFile(hpipe, buffer, sizeof(buffer), &numbytes, NULL);
+    todo_wine ok(ret, "ReadFile failed with %u\n", GetLastError());
+    ok(numbytes == 0, "expected 0, got %u\n", numbytes);
+
+    SetLastError(0xdeadbeef);
+    ret = ReadFile(hpipe, buffer, 0, &numbytes, NULL);
+    ok(!ret, "ReadFile unexpectedly succeeded\n");
+    ok(GetLastError() == ERROR_BROKEN_PIPE, "expected ERROR_BROKEN_PIPE, got %u\n", GetLastError());
+
+    CloseHandle(hpipe);
 }
 
 struct named_pipe_client_params
-- 
2.6.2



More information about the wine-patches mailing list