Module: wine Branch: master Commit: d6900fc55652edc2dc53d9859a487b0fc12ec7bd URL: http://source.winehq.org/git/wine.git/?a=commit;h=d6900fc55652edc2dc53d9859a...
Author: Dmitry Timoshkov dmitry@baikal.ru Date: Wed Sep 18 15:53:02 2013 +0900
ntdll/tests: Add 0-length read tests for a disk file.
---
dlls/ntdll/tests/file.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 files changed, 41 insertions(+), 0 deletions(-)
diff --git a/dlls/ntdll/tests/file.c b/dlls/ntdll/tests/file.c index 120fdac..5ae605b 100644 --- a/dlls/ntdll/tests/file.c +++ b/dlls/ntdll/tests/file.c @@ -1985,6 +1985,22 @@ static void test_read_write(void)
bytes = 0xdeadbeef; SetLastError(0xdeadbeef); + ret = ReadFile(INVALID_HANDLE_VALUE, buf, 0, &bytes, NULL); +todo_wine + ok(!ret, "ReadFile should fail\n"); +todo_wine + ok(GetLastError() == ERROR_INVALID_HANDLE, "expected ERROR_INVALID_HANDLE, got %d\n", GetLastError()); + ok(bytes == 0, "bytes %u\n", bytes); + + bytes = 0xdeadbeef; + 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 = 0xdeadbeef; + 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()); @@ -2184,6 +2200,31 @@ todo_wine
bytes = 0xdeadbeef; SetLastError(0xdeadbeef); + ret = ReadFile(INVALID_HANDLE_VALUE, buf, 0, &bytes, NULL); +todo_wine + ok(!ret, "ReadFile should fail\n"); +todo_wine + ok(GetLastError() == ERROR_INVALID_HANDLE, "expected ERROR_INVALID_HANDLE, got %d\n", GetLastError()); + ok(bytes == 0, "bytes %u\n", bytes); + + S(U(ovl)).Offset = 0; + S(U(ovl)).OffsetHigh = 0; + 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) ok(GetLastError() == ERROR_IO_PENDING, "expected ERROR_IO_PENDING, 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); +todo_wine + ok(ovl.InternalHigh == 0, "expected 0, got %lu\n", ovl.InternalHigh); + + bytes = 0xdeadbeef; + SetLastError(0xdeadbeef); ret = WriteFile(hfile, contents, sizeof(contents), &bytes, NULL); ok(!ret, "WriteFile should fail\n"); ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());