ntdll/tests: Don't test function directly when reporting GetLastError()

André Hentschel nerv at dawncrow.de
Tue Dec 28 14:10:40 CST 2010


if it's fine, there will be more to come
---
 dlls/ntdll/tests/directory.c |    9 +++++----
 dlls/ntdll/tests/exception.c |    6 ++++--
 dlls/ntdll/tests/file.c      |    5 +++--
 3 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/dlls/ntdll/tests/directory.c b/dlls/ntdll/tests/directory.c
index bc4ad39..be8dd13 100644
--- a/dlls/ntdll/tests/directory.c
+++ b/dlls/ntdll/tests/directory.c
@@ -71,9 +71,10 @@ static const int max_test_dir_size = 20;  /* size of above plus some for .. etc
 static void set_up_attribute_test(const char *testdirA)
 {
     int i;
+    BOOL ret;
 
-    ok(CreateDirectoryA(testdirA, NULL),
-       "couldn't create dir '%s', error %d\n", testdirA, GetLastError());
+    ret = CreateDirectoryA(testdirA, NULL);
+    ok(ret, "couldn't create dir '%s', error %d\n", testdirA, GetLastError());
 
     for (i=0; testfiles[i].name; i++) {
         char buf[MAX_PATH];
@@ -82,8 +83,8 @@ static void set_up_attribute_test(const char *testdirA)
         sprintf(buf, "%s\\%s", testdirA, testfiles[i].name);
         testfiles[i].nfound = 0;
         if (testfiles[i].attr & FILE_ATTRIBUTE_DIRECTORY) {
-            ok(CreateDirectoryA(buf, NULL),
-               "couldn't create dir '%s', error %d\n", buf, GetLastError());
+            ret = CreateDirectoryA(buf, NULL);
+            ok(ret, "couldn't create dir '%s', error %d\n", buf, GetLastError());
         } else {
             HANDLE h = CreateFileA(buf,
                                    GENERIC_READ|GENERIC_WRITE,
diff --git a/dlls/ntdll/tests/exception.c b/dlls/ntdll/tests/exception.c
index dd03d5f..386c5a6 100644
--- a/dlls/ntdll/tests/exception.c
+++ b/dlls/ntdll/tests/exception.c
@@ -828,8 +828,10 @@ static void test_debugger(void)
     } while (de.dwDebugEventCode != EXIT_PROCESS_DEBUG_EVENT);
 
     winetest_wait_child_process( pi.hProcess );
-    ok(CloseHandle(pi.hThread) != 0, "error %u\n", GetLastError());
-    ok(CloseHandle(pi.hProcess) != 0, "error %u\n", GetLastError());
+    ret = CloseHandle(pi.hThread);
+    ok(ret, "error %u\n", GetLastError());
+    ret = CloseHandle(pi.hProcess);
+    ok(ret, "error %u\n", GetLastError());
 
     return;
 }
diff --git a/dlls/ntdll/tests/file.c b/dlls/ntdll/tests/file.c
index c72e0f0..5afb025 100644
--- a/dlls/ntdll/tests/file.c
+++ b/dlls/ntdll/tests/file.c
@@ -456,6 +456,7 @@ static void read_file_test(void)
     char buffer[128];
     LARGE_INTEGER offset;
     HANDLE event = CreateEventA( NULL, TRUE, FALSE, NULL );
+    BOOL ret;
 
     buffer[0] = 1;
 
@@ -599,8 +600,8 @@ static void read_file_test(void)
     CloseHandle( read );
 
     if (!create_pipe( &read, &write, FILE_FLAG_OVERLAPPED, 4096 )) return;
-    ok(DuplicateHandle(GetCurrentProcess(), read, GetCurrentProcess(), &handle, 0, TRUE, DUPLICATE_SAME_ACCESS),
-        "Failed to duplicate handle: %d\n", GetLastError());
+    ret = DuplicateHandle(GetCurrentProcess(), read, GetCurrentProcess(), &handle, 0, TRUE, DUPLICATE_SAME_ACCESS);
+    ok(ret, "Failed to duplicate handle: %d\n", GetLastError());
 
     apc_count = 0;
     U(iosb).Status = 0xdeadbabe;
-- 

Best Regards, André Hentschel



More information about the wine-patches mailing list