[PATCH 12/12] shell32/tests: Make sure the test executable has an executable name.
Francois Gouget
fgouget at codeweavers.com
Mon Jan 4 16:32:28 CST 2016
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 | 38 ++++++++++++++++++++++++++------------
1 file changed, 26 insertions(+), 12 deletions(-)
diff --git a/dlls/shell32/tests/shlexec.c b/dlls/shell32/tests/shlexec.c
index 14fb75f..45de544 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];
@@ -2753,7 +2754,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*);
@@ -2785,15 +2786,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)
@@ -2808,6 +2800,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);
@@ -2864,7 +2875,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.shlexec", "Open", 0, "Open \"%1\"");
create_test_verb("shlexec.shlexec", "NoQuotes", 0, "NoQuotes %1");
@@ -2898,6 +2909,8 @@ static void cleanup_test(void)
CloseHandle(hEvent);
CoUninitialize();
+ if (lstrcmpA(testexe, argv0))
+ DeleteFileA(argv0);
}
static void test_directory(void)
@@ -2963,7 +2976,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