Signed-off-by: Francois Gouget fgouget@codeweavers.com ---
v2: This should catch all troublesome failure messages.
dlls/shell32/tests/shlexec.c | 55 ++++++++++++++++++++++++++++++------ 1 file changed, 46 insertions(+), 9 deletions(-)
diff --git a/dlls/shell32/tests/shlexec.c b/dlls/shell32/tests/shlexec.c index 030ab54525a..1e7fd2140b1 100644 --- a/dlls/shell32/tests/shlexec.c +++ b/dlls/shell32/tests/shlexec.c @@ -350,6 +350,43 @@ static void dump_child_(const char* file, int line) * ***/
+static const char* substTmpPath(const char* str, const char *path, char rep) +{ + static char buffer[1024]; + char *p; + + if (!str || strlen(str) >= sizeof(buffer)) + return str; + + /* Only modify the last component of the path */ + p = strrchr(path, '\'); + if (p) path = p + 1; + p = strrchr(path, '/'); + if (p) path = p + 1; + + p = strstr(str, path); + if (!p) + return str; + + strcpy(buffer, str); + p = buffer + (p - str); + while (p) + { + p += 2; /* skip the 'wt' prefix */ + /* and only replace the random part of the path */ + while (*p && *p != '.') + *p++ = rep; + p = strstr(p, path); + } + return buffer; +} + +static const char* derandomizeString(const char* str) +{ + str = substTmpPath(str, child_file, 'C'); + return substTmpPath(str, tmpdir, 'D'); +} + static char shell_call[2048]; static void WINAPIV __WINE_PRINTF_ATTR(2,3) _okShell(int condition, const char *msg, ...) { @@ -507,9 +544,9 @@ static INT_PTR shell_execute_(const char* file, int line, LPCSTR verb, LPCSTR fi
strcpy(shell_call, "ShellExecute("); strcat_param(shell_call, "verb", verb); - strcat_param(shell_call, "file", filename); - strcat_param(shell_call, "params", parameters); - strcat_param(shell_call, "dir", directory); + strcat_param(shell_call, "file", derandomizeString(filename)); + strcat_param(shell_call, "params", derandomizeString(parameters)); + strcat_param(shell_call, "dir", derandomizeString(directory)); strcat(shell_call, ")"); strcat(shell_call, assoc_desc); if (winetest_debug > 1) @@ -591,9 +628,9 @@ static INT_PTR shell_execute_ex_(const char* file, int line, sprintf(smask, "0x%x", mask); strcat_param(shell_call, "mask", smask); strcat_param(shell_call, "verb", verb); - strcat_param(shell_call, "file", filename); - strcat_param(shell_call, "params", parameters); - strcat_param(shell_call, "dir", directory); + strcat_param(shell_call, "file", derandomizeString(filename)); + strcat_param(shell_call, "params", derandomizeString(parameters)); + strcat_param(shell_call, "dir", derandomizeString(directory)); strcat_param(shell_call, "class", class); strcat(shell_call, ")"); strcat(shell_call, assoc_desc); @@ -832,7 +869,7 @@ static void create_test_verb_dde(const char* classname, const char* verb, sprintf(shell, "%d", rawcmd); strcat_param(assoc_desc, "rawcmd", shell); strcat_param(assoc_desc, "cmdtail", cmdtail); - strcat_param(assoc_desc, "ddeexec", ddeexec); + strcat_param(assoc_desc, "ddeexec", derandomizeString(ddeexec)); strcat_param(assoc_desc, "app", application); strcat_param(assoc_desc, "topic", topic); strcat_param(assoc_desc, "ifexec", ifexec); @@ -1737,7 +1774,7 @@ static void test_filename(void) okChildInt("argcA", 5); todo_wine okChildString("argvA3", "averb"); sprintf(filename, "%s\test file.sha", tmpdir); - todo_wine okChildPath("argvA4", filename); + todo_wine okChildPath("argvA4", derandomizeString(filename)); }
typedef struct @@ -2080,7 +2117,7 @@ static void test_find_executable(void) if (rc > 32) rc=33; todo_wine_if(test->todo & 0x10) - ok(rc==test->rc, "FindExecutable(%s) failed: rc=%ld\n", filename, rc); + ok(rc==test->rc, "FindExecutable(%s) failed: rc=%ld\n", derandomizeString(filename), rc); if (rc > 32) { BOOL equal;