ntdll/tests: Add more tests for reading beyond EOF.

This commit is contained in:
Dmitry Timoshkov 2013-10-11 13:39:39 +09:00 committed by Alexandre Julliard
parent 2f26e38580
commit fa2ca8f6b4
1 changed files with 49 additions and 19 deletions

View File

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