Dmitry Timoshkov : kernel32/tests: Add 0-length read tests for a pipe.

Alexandre Julliard julliard at winehq.org
Fri Sep 20 14:21:30 CDT 2013


Module: wine
Branch: master
Commit: 70930fa12cf9d6d8240af3e842260e6f7e38cd73
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=70930fa12cf9d6d8240af3e842260e6f7e38cd73

Author: Dmitry Timoshkov <dmitry at baikal.ru>
Date:   Wed Sep 18 15:54:32 2013 +0900

kernel32/tests: Add 0-length read tests for a pipe.

---

 dlls/kernel32/tests/pipe.c |   50 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 50 insertions(+), 0 deletions(-)

diff --git a/dlls/kernel32/tests/pipe.c b/dlls/kernel32/tests/pipe.c
index 923c0e7..07e82a8 100644
--- a/dlls/kernel32/tests/pipe.c
+++ b/dlls/kernel32/tests/pipe.c
@@ -21,6 +21,8 @@
 #include <stdarg.h>
 #include <stdio.h>
 
+#include "ntstatus.h"
+#define WIN32_NO_STATUS
 #include <windef.h>
 #include <winbase.h>
 #include <winsock.h>
@@ -1855,6 +1857,54 @@ static void test_readfileex_pending(void)
     ok(completion_errorcode == 0, "completion called with error %x\n", completion_errorcode);
     ok(completion_lpoverlapped == &overlapped, "completion called with wrong overlapped pointer\n");
 
+    num_bytes = 0xdeadbeef;
+    SetLastError(0xdeadbeef);
+    ret = ReadFile(INVALID_HANDLE_VALUE, read_buf, 0, &num_bytes, NULL);
+todo_wine
+    ok(!ret, "ReadFile should fail\n");
+todo_wine
+    ok(GetLastError() == ERROR_INVALID_HANDLE, "wrong error %u\n", GetLastError());
+    ok(num_bytes == 0, "expected 0, got %u\n", num_bytes);
+
+    S(U(overlapped)).Offset = 0;
+    S(U(overlapped)).OffsetHigh = 0;
+    overlapped.Internal = -1;
+    overlapped.InternalHigh = -1;
+    overlapped.hEvent = event;
+    num_bytes = 0xdeadbeef;
+    SetLastError(0xdeadbeef);
+    ret = ReadFile(server, read_buf, 0, &num_bytes, &overlapped);
+todo_wine
+    ok(GetLastError() == ERROR_IO_PENDING, "expected ERROR_IO_PENDING, got %d\n", GetLastError());
+    ok(num_bytes == 0, "bytes %u\n", num_bytes);
+todo_wine
+    ok((NTSTATUS)overlapped.Internal == STATUS_PENDING, "expected STATUS_PENDING, got %#lx\n", overlapped.Internal);
+    ok(overlapped.InternalHigh == -1, "expected -1, got %lu\n", overlapped.InternalHigh);
+
+    wait = WaitForSingleObject(event, 100);
+todo_wine
+    ok(wait == WAIT_TIMEOUT, "WaitForSingleObject returned %x\n", wait);
+
+    num_bytes = 0xdeadbeef;
+    ret = WriteFile(client, test_string, 1, &num_bytes, NULL);
+    ok(ret, "WriteFile failed\n");
+    ok(num_bytes == 1, "bytes %u\n", num_bytes);
+
+    wait = WaitForSingleObject(event, 0);
+    ok(wait == WAIT_OBJECT_0, "WaitForSingleObject returned %x\n", wait);
+
+    ok(num_bytes == 1, "bytes %u\n", num_bytes);
+todo_wine
+    ok((NTSTATUS)overlapped.Internal == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#lx\n", overlapped.Internal);
+todo_wine
+    ok(overlapped.InternalHigh == 0, "expected 0, got %lu\n", overlapped.InternalHigh);
+
+    /* read the pending byte and clear the pipe */
+    num_bytes = 0xdeadbeef;
+    ret = ReadFile(server, read_buf, 1, &num_bytes, &overlapped);
+    ok(ret, "ReadFile failed\n");
+    ok(num_bytes == 1, "bytes %u\n", num_bytes);
+
     CloseHandle(client);
     CloseHandle(server);
     CloseHandle(event);




More information about the wine-cvs mailing list