ntdll/tests: Add tests for reading 0 bytes at end of file.

This commit is contained in:
Dmitry Timoshkov 2013-10-29 16:10:02 +09:00 committed by Alexandre Julliard
parent 4befefa94d
commit 3a41ebfbf2
1 changed files with 147 additions and 0 deletions

View File

@ -2131,6 +2131,20 @@ todo_wine
ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %d\n", GetLastError());
ok(bytes == 0, "bytes %u\n", bytes);
bytes = -1;
SetLastError(0xdeadbeef);
ret = ReadFile(hfile, buf, 0, &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);
bytes = -1;
SetLastError(0xdeadbeef);
ret = ReadFile(hfile, NULL, 0, &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;
@ -2146,6 +2160,23 @@ 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);
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, 0, &bytes, &ovl);
todo_wine
ok(ret, "ReadFile error %d\n", GetLastError());
todo_wine
ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %d\n", GetLastError());
ok(bytes == 0, "bytes %u\n", bytes);
todo_wine
ok((NTSTATUS)ovl.Internal == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#lx\n", ovl.Internal);
ok(ovl.InternalHigh == 0, "expected 0, got %lu\n", ovl.InternalHigh);
U(iob).Status = -1;
iob.Information = -1;
status = pNtReadFile(hfile, 0, NULL, NULL, &iob, buf, sizeof(buf), NULL, NULL);
@ -2155,6 +2186,16 @@ todo_wine
todo_wine
ok(iob.Information == 0, "expected 0, got %lu\n", iob.Information);
U(iob).Status = -1;
iob.Information = -1;
status = pNtReadFile(hfile, 0, NULL, NULL, &iob, buf, 0, NULL, NULL);
todo_wine
ok(status == STATUS_SUCCESS, "NtReadFile error %#x\n", status);
todo_wine
ok(U(iob).Status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#x\n", U(iob).Status);
todo_wine
ok(iob.Information == 0, "expected 0, got %lu\n", iob.Information);
U(iob).Status = -1;
iob.Information = -1;
offset.QuadPart = sizeof(contents);
@ -2165,6 +2206,17 @@ todo_wine
todo_wine
ok(iob.Information == 0, "expected 0, got %lu\n", iob.Information);
U(iob).Status = -1;
iob.Information = -1;
offset.QuadPart = sizeof(contents);
status = pNtReadFile(hfile, 0, NULL, NULL, &iob, buf, 0, &offset, NULL);
todo_wine
ok(status == STATUS_SUCCESS, "NtReadFile error %#x\n", status);
todo_wine
ok(U(iob).Status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#x\n", U(iob).Status);
todo_wine
ok(iob.Information == 0, "expected 0, got %lu\n", iob.Information);
U(iob).Status = -1;
iob.Information = -1;
offset.QuadPart = (LONGLONG)-2 /* FILE_USE_FILE_POINTER_POSITION */;
@ -2175,6 +2227,17 @@ todo_wine
todo_wine
ok(iob.Information == 0, "expected 0, got %lu\n", iob.Information);
U(iob).Status = -1;
iob.Information = -1;
offset.QuadPart = (LONGLONG)-2 /* FILE_USE_FILE_POINTER_POSITION */;
status = pNtReadFile(hfile, 0, NULL, NULL, &iob, buf, 0, &offset, NULL);
todo_wine
ok(status == STATUS_SUCCESS, "NtReadFile error %#x\n", status);
todo_wine
ok(U(iob).Status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#x\n", U(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;
@ -2392,6 +2455,68 @@ todo_wine
off = SetFilePointer(hfile, 0, NULL, FILE_CURRENT);
ok(off == 0, "expected 0, got %u\n", off);
offset.QuadPart = sizeof(contents);
S(U(ovl)).Offset = offset.u.LowPart;
S(U(ovl)).OffsetHigh = offset.u.HighPart;
ovl.Internal = -1;
ovl.InternalHigh = -1;
ovl.hEvent = 0;
bytes = 0xdeadbeef;
SetLastError(0xdeadbeef);
ret = ReadFile(hfile, buf, 0, &bytes, &ovl);
/* ReadFile return value depends on Windows version and testing it is not practical */
if (!ret)
todo_wine
ok(GetLastError() == ERROR_IO_PENDING, "expected ERROR_IO_PENDING, got %d\n", GetLastError());
ret = GetLastError();
ok(bytes == 0, "bytes %u\n", bytes);
off = SetFilePointer(hfile, 0, NULL, FILE_CURRENT);
ok(off == 0, "expected 0, got %u\n", off);
if (ret == ERROR_IO_PENDING)
{
bytes = 0xdeadbeef;
SetLastError(0xdeadbeef);
ret = GetOverlappedResult(hfile, &ovl, &bytes, TRUE);
ok(ret, "GetOverlappedResult should report TRUE\n");
ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %d\n", GetLastError());
ok(bytes == 0, "expected 0, read %u\n", bytes);
ok((NTSTATUS)ovl.Internal == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#lx\n", ovl.Internal);
ok(ovl.InternalHigh == 0, "expected 0, got %lu\n", ovl.InternalHigh);
}
offset.QuadPart = sizeof(contents);
S(U(ovl)).Offset = offset.u.LowPart;
S(U(ovl)).OffsetHigh = offset.u.HighPart;
ovl.Internal = -1;
ovl.InternalHigh = -1;
ovl.hEvent = 0;
bytes = 0xdeadbeef;
SetLastError(0xdeadbeef);
ret = ReadFile(hfile, NULL, 0, &bytes, &ovl);
/* ReadFile return value depends on Windows version and testing it is not practical */
if (!ret)
todo_wine
ok(GetLastError() == ERROR_IO_PENDING, "expected ERROR_IO_PENDING, got %d\n", GetLastError());
ret = GetLastError();
ok(bytes == 0, "bytes %u\n", bytes);
off = SetFilePointer(hfile, 0, NULL, FILE_CURRENT);
ok(off == 0, "expected 0, got %u\n", off);
if (ret == ERROR_IO_PENDING)
{
bytes = 0xdeadbeef;
SetLastError(0xdeadbeef);
ret = GetOverlappedResult(hfile, &ovl, &bytes, TRUE);
ok(ret, "GetOverlappedResult should report TRUE\n");
ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %d\n", GetLastError());
ok(bytes == 0, "expected 0, read %u\n", bytes);
ok((NTSTATUS)ovl.Internal == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#lx\n", ovl.Internal);
ok(ovl.InternalHigh == 0, "expected 0, got %lu\n", ovl.InternalHigh);
}
U(iob).Status = -1;
iob.Information = -1;
offset.QuadPart = sizeof(contents);
@ -2411,6 +2536,28 @@ todo_wine
off = SetFilePointer(hfile, 0, NULL, FILE_CURRENT);
ok(off == 0, "expected 0, got %u\n", off);
U(iob).Status = -1;
iob.Information = -1;
offset.QuadPart = sizeof(contents);
status = pNtReadFile(hfile, 0, NULL, NULL, &iob, buf, 0, &offset, NULL);
if (status == STATUS_PENDING)
{
ok(U(iob).Status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#x\n", U(iob).Status);
ok(iob.Information == 0, "expected 0, got %lu\n", iob.Information);
}
else
{
todo_wine
ok(status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#x\n", status);
todo_wine
ok(U(iob).Status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#x\n", U(iob).Status);
todo_wine
ok(iob.Information == 0, "expected 0, got %lu\n", iob.Information);
}
off = SetFilePointer(hfile, 0, NULL, FILE_CURRENT);
ok(off == 0, "expected 0, got %u\n", off);
S(U(ovl)).Offset = 0;
S(U(ovl)).OffsetHigh = 0;
ovl.Internal = -1;