Commit fa2ca8f6 authored by Dmitry Timoshkov's avatar Dmitry Timoshkov Committed by Alexandre Julliard

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

parent 2f26e385
......@@ -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,18 +2157,15 @@ todo_wine
todo_wine
ok(iob.Information == 0, "expected 0, got %lu\n", iob.Information);
for (i = -20; i < 0; i++)
{
if (i == -2) continue;
iob.Status = -1;
iob.Information = -1;
offset.QuadPart = (LONGLONG)i;
offset.QuadPart = sizeof(contents);
status = pNtReadFile(hfile, 0, NULL, NULL, &iob, buf, sizeof(buf), &offset, NULL);
ok(status == STATUS_INVALID_PARAMETER, "%d: expected STATUS_INVALID_PARAMETER, got %#x\n", i, status);
ok(iob.Status == -1, "expected -1, got %#x\n", iob.Status);
ok(iob.Information == -1, "expected -1, got %ld\n", iob.Information);
}
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;
......@@ -2155,6 +2177,19 @@ todo_wine
todo_wine
ok(iob.Information == 0, "expected 0, got %lu\n", iob.Information);
for (i = -20; i < 0; i++)
{
if (i == -2) continue;
iob.Status = -1;
iob.Information = -1;
offset.QuadPart = (LONGLONG)i;
status = pNtReadFile(hfile, 0, NULL, NULL, &iob, buf, sizeof(buf), &offset, NULL);
ok(status == STATUS_INVALID_PARAMETER, "%d: expected STATUS_INVALID_PARAMETER, got %#x\n", i, status);
ok(iob.Status == -1, "expected -1, got %#x\n", iob.Status);
ok(iob.Information == -1, "expected -1, got %ld\n", iob.Information);
}
SetFilePointer(hfile, 0, NULL, FILE_BEGIN);
bytes = 0;
......@@ -2169,15 +2204,6 @@ todo_wine
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;
status = pNtReadFile(hfile, 0, NULL, NULL, &iob, buf, sizeof(buf), &offset, NULL);
ok(status == STATUS_SUCCESS, "NtReadFile error %#x\n", status);
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment