From 70930fa12cf9d6d8240af3e842260e6f7e38cd73 Mon Sep 17 00:00:00 2001 From: Dmitry Timoshkov Date: Wed, 18 Sep 2013 15:54:32 +0900 Subject: [PATCH] kernel32/tests: Add 0-length read tests for a pipe. --- dlls/kernel32/tests/pipe.c | 50 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/dlls/kernel32/tests/pipe.c b/dlls/kernel32/tests/pipe.c index 923c0e7adc3..07e82a8c582 100644 --- a/dlls/kernel32/tests/pipe.c +++ b/dlls/kernel32/tests/pipe.c @@ -21,6 +21,8 @@ #include #include +#include "ntstatus.h" +#define WIN32_NO_STATUS #include #include #include @@ -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);