kernel32/tests: Add a couple of tests for error handling when reading past EOF.

Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2021-10-15 17:26:46 -05:00 committed by Alexandre Julliard
parent 0925a73027
commit 80b35103df
1 changed files with 17 additions and 0 deletions

View File

@ -5927,6 +5927,7 @@ static void test_move_file(void)
static void test_eof(void)
{
char temp_path[MAX_PATH], filename[MAX_PATH], buffer[20];
OVERLAPPED overlapped = {0};
LARGE_INTEGER file_size;
HANDLE file, mapping;
unsigned int i;
@ -5961,9 +5962,25 @@ static void test_eof(void)
ok(ret, "failed to get size, error %u\n", GetLastError());
ok(!file_size.QuadPart, "got size %I64d\n", file_size.QuadPart);
SetLastError(0xdeadbeef);
ret = ReadFile(file, buffer, sizeof(buffer), &size, NULL);
ok(ret, "failed to read, error %u\n", GetLastError());
ok(!size, "got size %u\n", size);
ok(GetLastError() == 0xdeadbeef, "got error %u\n", GetLastError());
SetFilePointer(file, 2, NULL, SEEK_SET);
SetLastError(0xdeadbeef);
size = 0xdeadbeef;
overlapped.Offset = 2;
ret = ReadFile(file, buffer, sizeof(buffer), &size, &overlapped);
ok(!ret, "expected failure\n");
ok(GetLastError() == ERROR_HANDLE_EOF, "got error %u\n", GetLastError());
ok(!size, "got size %u\n", size);
todo_wine ok((NTSTATUS)overlapped.Internal == STATUS_PENDING, "got status %#x\n", (NTSTATUS)overlapped.Internal);
ok(!overlapped.InternalHigh, "got size %Iu\n", overlapped.InternalHigh);
SetFilePointer(file, 2, NULL, SEEK_SET);
ret = SetEndOfFile(file);
ok(ret, "failed to set EOF, error %u\n", GetLastError());