[1/2] shell32/tests: Trace the last ShellExecute command whenever a corresponding test fails.

Francois Gouget fgouget at codeweavers.com
Tue Jan 19 18:38:18 CST 2016


Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
---
 dlls/shell32/tests/shlexec.c | 75 ++++++++++++++++++++++++++++++--------------
 1 file changed, 52 insertions(+), 23 deletions(-)

diff --git a/dlls/shell32/tests/shlexec.c b/dlls/shell32/tests/shlexec.c
index 8f03799..360fb2b 100644
--- a/dlls/shell32/tests/shlexec.c
+++ b/dlls/shell32/tests/shlexec.c
@@ -94,6 +94,28 @@ static int _todo_wait = 0;
 #define todo_wait for (_todo_wait = 1; _todo_wait; _todo_wait = 0)
 
 static char shell_call[2048]="";
+static char last_shell_call[2048]="";
+static void WINETEST_PRINTF_ATTR(2,3) _okShell(int condition, const char *msg, ...)
+{
+    va_list valist;
+
+    /* Note: if winetest_debug > 1 the ShellExecute() command has already been
+     * traced.
+     */
+    if (winetest_debug <= 1 && !condition && strcmp(last_shell_call, shell_call))
+    {
+        winetest_trace("Called %s\n", shell_call);
+        strcpy(last_shell_call, shell_call);
+    }
+
+    va_start(valist, msg);
+    winetest_vok(condition, msg, valist);
+    va_end(valist);
+}
+#define okShell_(file, line) (winetest_set_location(file, line), 0) ? (void)0 : _okShell
+#define okShell okShell_(__FILE__, __LINE__)
+
+
 static int bad_shellexecute = 0;
 static INT_PTR shell_execute_(const char* file, int line, LPCSTR verb, LPCSTR filename, LPCSTR parameters, LPCSTR directory)
 {
@@ -138,11 +160,11 @@ static INT_PTR shell_execute_(const char* file, int line, LPCSTR verb, LPCSTR fi
             }
         }
         if (!_todo_wait)
-            ok_(file, line)(wait_rc==WAIT_OBJECT_0 || rc <= 32,
-                            "%s WaitForSingleObject returned %d\n", shell_call, wait_rc);
+            okShell_(file, line)(wait_rc==WAIT_OBJECT_0 || rc <= 32,
+                                 "WaitForSingleObject returned %d\n", wait_rc);
         else todo_wine
-            ok_(file, line)(wait_rc==WAIT_OBJECT_0 || rc <= 32,
-                            "%s WaitForSingleObject returned %d\n", shell_call, wait_rc);
+            okShell_(file, line)(wait_rc==WAIT_OBJECT_0 || rc <= 32,
+                                 "WaitForSingleObject returned %d\n", wait_rc);
     }
     /* The child process may have changed the result file, so let profile
      * functions know about it
@@ -155,8 +177,9 @@ static INT_PTR shell_execute_(const char* file, int line, LPCSTR verb, LPCSTR fi
     {
         if (rc != rcEmpty && rcEmpty == SE_ERR_NOASSOC) /* NT4 */
             bad_shellexecute = 1;
-        ok_(file, line)(rc == rcEmpty || broken(rc != rcEmpty && rcEmpty == SE_ERR_NOASSOC) /* NT4 */,
-                        "%s Got different return value with empty string: %lu %lu\n", shell_call, rc, rcEmpty);
+        okShell_(file, line)(rc == rcEmpty ||
+                             broken(rc != rcEmpty && rcEmpty == SE_ERR_NOASSOC) /* NT4 */,
+                             "Got different return value with empty string: %lu %lu\n", rc, rcEmpty);
     }
 
     return rc;
@@ -209,8 +232,9 @@ static INT_PTR shell_execute_ex_(const char* file, int line,
     SetLastError(0xcafebabe);
     success=ShellExecuteExA(&sei);
     rc=(INT_PTR)sei.hInstApp;
-    ok_(file, line)((success && rc > 32) || (!success && rc <= 32),
-                    "%s rc=%d and hInstApp=%ld is not allowed\n", shell_call, success, rc);
+    okShell_(file, line)((success && rc > 32) || (!success && rc <= 32),
+                         "rc=%d and hInstApp=%ld is not allowed\n",
+                         success, rc);
 
     if (rc > 32)
     {
@@ -218,16 +242,21 @@ static INT_PTR shell_execute_ex_(const char* file, int line,
         if (sei.hProcess!=NULL)
         {
             wait_rc=WaitForSingleObject(sei.hProcess, 5000);
-            ok_(file, line)(wait_rc==WAIT_OBJECT_0, "WaitForSingleObject(hProcess) returned %d\n", wait_rc);
+            okShell_(file, line)(wait_rc==WAIT_OBJECT_0,
+                                 "WaitForSingleObject(hProcess) returned %d\n",
+                                 wait_rc);
         }
         wait_rc=WaitForSingleObject(hEvent, 5000);
         if (!_todo_wait)
-            ok_(file, line)(wait_rc==WAIT_OBJECT_0, "WaitForSingleObject returned %d\n", wait_rc);
+            okShell_(file, line)(wait_rc==WAIT_OBJECT_0,
+                                 "WaitForSingleObject returned %d\n", wait_rc);
         else todo_wine
-            ok_(file, line)(wait_rc==WAIT_OBJECT_0, "WaitForSingleObject returned %d\n", wait_rc);
+            okShell_(file, line)(wait_rc==WAIT_OBJECT_0,
+                                 "WaitForSingleObject returned %d\n", wait_rc);
     }
     else
-       ok_(file, line)(sei.hProcess==NULL, "%s returned a process handle %p\n", shell_call, sei.hProcess);
+        okShell_(file, line)(sei.hProcess==NULL,
+                             "returned a process handle %p\n", sei.hProcess);
 
     /* The child process may have changed the result file, so let profile
      * functions know about it
@@ -731,12 +760,12 @@ static void _okChildString(const char* file, int line, const char* key, const ch
     result=getChildString("Arguments", key);
     if (!result)
     {
-        ok_(file, line)(FALSE, "%s expected '%s', but key not found or empty\n", key, expected);
+        okShell_(file, line)(FALSE, "%s expected '%s', but key not found or empty\n", key, expected);
         return;
     }
-    ok_(file, line)(lstrcmpiA(result, expected) == 0 ||
-                    broken(lstrcmpiA(result, bad) == 0),
-                    "%s expected '%s', got '%s'\n", key, expected, result);
+    okShell_(file, line)(lstrcmpiA(result, expected) == 0 ||
+                         broken(lstrcmpiA(result, bad) == 0),
+                         "%s expected '%s', got '%s'\n", key, expected, result);
 }
 
 static void _okChildPath(const char* file, int line, const char* key, const char* expected)
@@ -745,27 +774,27 @@ static void _okChildPath(const char* file, int line, const char* key, const char
     result=getChildString("Arguments", key);
     if (!result)
     {
-        ok_(file, line)(FALSE, "%s expected '%s', but key not found or empty\n", key, expected);
+        okShell_(file,line)(FALSE, "%s expected '%s', but key not found or empty\n", key, expected);
         return;
     }
-    ok_(file, line)(StrCmpPath(result, expected) == 0,
-                    "%s expected '%s', got '%s'\n", key, expected, result);
+    okShell_(file,line)(StrCmpPath(result, expected) == 0,
+                        "%s expected '%s', got '%s'\n", key, expected, result);
 }
 
 static void _okChildInt(const char* file, int line, const char* key, int expected)
 {
     INT result;
     result=GetPrivateProfileIntA("Arguments", key, expected, child_file);
-    ok_(file, line)(result == expected,
-                    "%s expected %d, but got %d\n", key, expected, result);
+    okShell_(file,line)(result == expected,
+                        "%s expected %d, but got %d\n", key, expected, result);
 }
 
 static void _okChildIntBroken(const char* file, int line, const char* key, int expected)
 {
     INT result;
     result=GetPrivateProfileIntA("Arguments", key, expected, child_file);
-    ok_(file, line)(result == expected || broken(result != expected),
-                    "%s expected %d, but got %d\n", key, expected, result);
+    okShell_(file,line)(result == expected || broken(result != expected),
+                        "%s expected %d, but got %d\n", key, expected, result);
 }
 
 #define okChildString(key, expected) _okChildString(__FILE__, __LINE__, (key), (expected), (expected))
-- 
2.7.0.rc3




More information about the wine-patches mailing list