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

This commit is contained in:
Dmitry Timoshkov 2013-09-18 15:54:32 +09:00 committed by Alexandre Julliard
parent 0c024503db
commit 70930fa12c
1 changed files with 50 additions and 0 deletions

View File

@ -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);