From fa2ca8f6b46127a35f07ce522bdc5723a588ec7c Mon Sep 17 00:00:00 2001 From: Dmitry Timoshkov Date: Fri, 11 Oct 2013 13:39:39 +0900 Subject: [PATCH] ntdll/tests: Add more tests for reading beyond EOF. --- dlls/ntdll/tests/file.c | 68 +++++++++++++++++++++++++++++------------ 1 file changed, 49 insertions(+), 19 deletions(-) diff --git a/dlls/ntdll/tests/file.c b/dlls/ntdll/tests/file.c index 66786ef15bd..7b644d1a351 100644 --- a/dlls/ntdll/tests/file.c +++ b/dlls/ntdll/tests/file.c @@ -2123,6 +2123,31 @@ todo_wine off = SetFilePointer(hfile, 0, NULL, FILE_CURRENT); ok(off == sizeof(contents), "expected sizeof(contents), got %u\n", off); + /* test reading beyond EOF */ + bytes = -1; + SetLastError(0xdeadbeef); + ret = ReadFile(hfile, buf, sizeof(buf), &bytes, NULL); + ok(ret, "ReadFile error %d\n", GetLastError()); + ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %d\n", GetLastError()); + ok(bytes == 0, "bytes %u\n", bytes); + + S(U(ovl)).Offset = sizeof(contents); + S(U(ovl)).OffsetHigh = 0; + ovl.Internal = -1; + ovl.InternalHigh = -1; + ovl.hEvent = 0; + bytes = -1; + SetLastError(0xdeadbeef); + ret = ReadFile(hfile, buf, sizeof(buf), &bytes, &ovl); +todo_wine + ok(!ret, "ReadFile should fail\n"); +todo_wine + ok(GetLastError() == ERROR_HANDLE_EOF, "expected ERROR_HANDLE_EOF, got %d\n", GetLastError()); + ok(bytes == 0, "bytes %u\n", bytes); +todo_wine + ok((NTSTATUS)ovl.Internal == STATUS_END_OF_FILE, "expected STATUS_END_OF_FILE, got %#lx\n", ovl.Internal); + ok(ovl.InternalHigh == 0, "expected 0, got %lu\n", ovl.InternalHigh); + iob.Status = -1; iob.Information = -1; status = pNtReadFile(hfile, 0, NULL, NULL, &iob, buf, sizeof(buf), NULL, NULL); @@ -2132,6 +2157,26 @@ todo_wine todo_wine ok(iob.Information == 0, "expected 0, got %lu\n", iob.Information); + iob.Status = -1; + iob.Information = -1; + offset.QuadPart = sizeof(contents); + status = pNtReadFile(hfile, 0, NULL, NULL, &iob, buf, sizeof(buf), &offset, NULL); + ok(status == STATUS_END_OF_FILE, "expected STATUS_END_OF_FILE, got %#x\n", status); +todo_wine + ok(iob.Status == STATUS_END_OF_FILE, "expected STATUS_END_OF_FILE, got %#x\n", iob.Status); +todo_wine + ok(iob.Information == 0, "expected 0, got %lu\n", iob.Information); + + iob.Status = -1; + iob.Information = -1; + offset.QuadPart = (LONGLONG)-2 /* FILE_USE_FILE_POINTER_POSITION */; + status = pNtReadFile(hfile, 0, NULL, NULL, &iob, buf, sizeof(buf), &offset, NULL); + ok(status == STATUS_END_OF_FILE, "expected STATUS_END_OF_FILE, got %#x\n", status); +todo_wine + ok(iob.Status == STATUS_END_OF_FILE, "expected STATUS_END_OF_FILE, got %#x\n", iob.Status); +todo_wine + ok(iob.Information == 0, "expected 0, got %lu\n", iob.Information); + for (i = -20; i < 0; i++) { if (i == -2) continue; @@ -2145,16 +2190,6 @@ todo_wine ok(iob.Information == -1, "expected -1, got %ld\n", iob.Information); } - iob.Status = -1; - iob.Information = -1; - offset.QuadPart = (LONGLONG)-2 /* FILE_USE_FILE_POINTER_POSITION */; - status = pNtReadFile(hfile, 0, NULL, NULL, &iob, buf, sizeof(buf), &offset, NULL); - ok(status == STATUS_END_OF_FILE, "expected STATUS_END_OF_FILE, got %#x\n", status); -todo_wine - ok(iob.Status == STATUS_END_OF_FILE, "expected STATUS_END_OF_FILE, got %#x\n", iob.Status); -todo_wine - ok(iob.Information == 0, "expected 0, got %lu\n", iob.Information); - SetFilePointer(hfile, 0, NULL, FILE_BEGIN); bytes = 0; @@ -2167,15 +2202,6 @@ todo_wine off = SetFilePointer(hfile, 0, NULL, FILE_CURRENT); ok(off == sizeof(contents), "expected sizeof(contents), got %u\n", off); - iob.Status = -1; - iob.Information = -1; - status = pNtReadFile(hfile, 0, NULL, NULL, &iob, buf, sizeof(buf), NULL, NULL); - ok(status == STATUS_END_OF_FILE, "expected STATUS_END_OF_FILE, got %#x\n", status); -todo_wine - ok(iob.Status == STATUS_END_OF_FILE, "expected STATUS_END_OF_FILE, got %#x\n", iob.Status); -todo_wine - ok(iob.Information == 0, "expected 0, got %lu\n", iob.Information); - iob.Status = -1; iob.Information = -1; offset.QuadPart = 0; @@ -2333,6 +2359,10 @@ todo_wine ok(iob.Information == -1, "expected -1, got %ld\n", iob.Information); } + off = SetFilePointer(hfile, 0, NULL, FILE_CURRENT); + ok(off == 0, "expected 0, got %u\n", off); + + /* test reading beyond EOF */ offset.QuadPart = sizeof(contents); S(U(ovl)).Offset = offset.u.LowPart; S(U(ovl)).OffsetHigh = offset.u.HighPart;