Module: wine Branch: master Commit: f0bf098e163c0ce027acb3d8b843f88a8a4d8f76 URL: http://source.winehq.org/git/wine.git/?a=commit;h=f0bf098e163c0ce027acb3d8b8...
Author: Alexandre Julliard julliard@winehq.org Date: Thu Sep 11 13:49:16 2008 +0200
kernel32/tests: Fix the async I/O test to handle errors properly.
---
dlls/kernel32/tests/file.c | 10 +++++++--- 1 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/dlls/kernel32/tests/file.c b/dlls/kernel32/tests/file.c index 94bc975..722e892 100644 --- a/dlls/kernel32/tests/file.c +++ b/dlls/kernel32/tests/file.c @@ -1612,18 +1612,22 @@ static void test_async_file_errors(void) szFile[0] = '\0'; GetWindowsDirectoryA(szFile, sizeof(szFile)/sizeof(szFile[0])-1-strlen("\win.ini")); strcat(szFile, "\win.ini"); - hFile = CreateFileA(szFile, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, OPEN_ALWAYS, FILE_FLAG_OVERLAPPED, NULL); - ok(hFile != NULL, "CreateFileA(%s ...) failed\n", szFile); + hFile = CreateFileA(szFile, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, + NULL, OPEN_ALWAYS, FILE_FLAG_OVERLAPPED, NULL); + ok(hFile != INVALID_HANDLE_VALUE, "CreateFileA(%s ...) failed\n", szFile); while (TRUE) { BOOL res; + DWORD count; while (WaitForSingleObjectEx(hSem, INFINITE, TRUE) == WAIT_IO_COMPLETION) ; res = ReadFileEx(hFile, lpBuffer, 4096, &ovl, FileIOComplete); /*printf("Offset = %ld, result = %s\n", ovl.Offset, res ? "TRUE" : "FALSE");*/ if (!res) break; - S(U(ovl)).Offset += 4096; + if (!GetOverlappedResult(hFile, &ovl, &count, FALSE)) + break; + S(U(ovl)).Offset += count; /* i/o completion routine only called if ReadFileEx returned success. * we only care about violations of this rule so undo what should have * been done */