[1/2] shell32/tests: Make sure the test executable has an executable name.

Francois Gouget fgouget at codeweavers.com
Mon Dec 28 17:44:16 CST 2015


ShellExecute() will not run files that don't have an 'executable extension' like '.exe'. So make sure our test executable has a valid name so as to not break the tests.

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

Without this patch renaming the test executable on Windows to match the 
name it has in Wine (shell32_test.exe.so) causes some tests to fail.

diff --git a/dlls/shell32/tests/shlexec.c b/dlls/shell32/tests/shlexec.c
index 3d95b41..0a041fa 100644
--- a/dlls/shell32/tests/shlexec.c
+++ b/dlls/shell32/tests/shlexec.c
@@ -52,6 +52,7 @@
 
 
 static char argv0[MAX_PATH];
+static char testexe[MAX_PATH];
 static int myARGC;
 static char** myARGV;
 static char tmpdir[MAX_PATH];
@@ -2487,7 +2488,7 @@ static void test_dde_default_app(void)
     ok(b, "got %d\n", b);
 }
 
-static void init_test(void)
+static int init_test(void)
 {
     HMODULE hdll;
     HRESULT (WINAPI *pDllGetVersion)(DLLVERSIONINFO*);
@@ -2519,15 +2520,6 @@ static void init_test(void)
     if (FAILED(r))
         exit(1);
 
-    rc=GetModuleFileNameA(NULL, argv0, sizeof(argv0));
-    ok(rc != 0 && rc < sizeof(argv0), "got %d\n", rc);
-    if (GetFileAttributesA(argv0)==INVALID_FILE_ATTRIBUTES)
-    {
-        strcat(argv0, ".so");
-        ok(GetFileAttributesA(argv0)!=INVALID_FILE_ATTRIBUTES,
-           "unable to find argv0!\n");
-    }
-
     /* Older versions (win 2k) fail tests if there is a space in
        the path. */
     if (dllver.dwMajorVersion <= 5)
@@ -2542,6 +2534,25 @@ static void init_test(void)
     /* Set %TMPDIR% for the tests */
     SetEnvironmentVariableA("TMPDIR", tmpdir);
 
+    /* Make sure the test executable has an executable name (i.e. not .so) */
+    rc=GetModuleFileNameA(NULL, testexe, sizeof(testexe));
+    ok(rc != 0 && rc < sizeof(testexe), "got %d\n", rc);
+    if (GetFileAttributesA(testexe)==INVALID_FILE_ATTRIBUTES)
+        strcat(testexe, ".so");
+    if (GetFileAttributesA(testexe)==INVALID_FILE_ATTRIBUTES)
+    {
+        ok(0, "unable to find the test executable: %s\n", testexe);
+        return FALSE;
+    }
+
+    if (lstrcmpA(testexe+strlen(testexe)-4, ".exe"))
+    {
+        sprintf(argv0, "%s\\shlexec_test.exe", tmpdir);
+        CopyFileA(testexe, argv0, FALSE);
+    }
+    else
+        strcpy(argv0, testexe);
+
     rc = GetTempFileNameA(tmpdir, "wt", 0, child_file);
     ok(rc != 0, "got %d\n", rc);
     init_event(child_file);
@@ -2598,7 +2609,7 @@ static void init_test(void)
     {
         skip_shlexec_tests = TRUE;
         skip("Unable to create association for '.shlexec'\n");
-        return;
+        return TRUE; /* we can still run some tests */
     }
     create_test_verb(".shlexec", "Open", 0, "Open \"%1\"");
     create_test_verb(".shlexec", "NoQuotes", 0, "NoQuotes %1");
@@ -2606,6 +2617,7 @@ static void init_test(void)
     create_test_verb(".shlexec", "QuotedLowerL", 0, "QuotedLowerL \"%l\"");
     create_test_verb(".shlexec", "UpperL", 0, "UpperL %L");
     create_test_verb(".shlexec", "QuotedUpperL", 0, "QuotedUpperL \"%L\"");
+    return TRUE;
 }
 
 static void cleanup_test(void)
@@ -2632,6 +2644,8 @@ static void cleanup_test(void)
     CloseHandle(hEvent);
 
     CoUninitialize();
+    if (lstrcmpA(testexe, argv0))
+        DeleteFileA(argv0);
 }
 
 static void test_directory(void)
@@ -2697,7 +2711,8 @@ START_TEST(shlexec)
         exit(0);
     }
 
-    init_test();
+    if (!init_test())
+        return;
 
     test_commandline2argv();
     test_argify();
-- 
2.6.4




More information about the wine-patches mailing list