shell32/tests: add tests for the parser of SHELLEXECUTEINFO.lpFile [try 2]

Ilya Basin basinilya at gmail.com
Wed Feb 17 02:51:47 CST 2010


Hi! Please comment on "try 2" of the patch. Will you accept it?

IB> Hi! This should expose this bug:
IB> http://bugs.winehq.org/show_bug.cgi?id=19385 ( the 'wine start'
IB> launcher does not open MS Office documents that have spaces in their
IB> path ). Although the title is misleading, many other tickets are
IB> marked as duplicates of it.
IB> It's not about spaces. It's about sometimes unneeded parsing of
IB> SHELLEXECUTEINFO.lpFile, trying to extract arguments from it. Why?
IB> Or maybe some other part of wine relies on this behavior?

IB> Succeeds on 98 se, 2k & xp.
IB> 4 tests fail on wine
IB> ---
IB>  dlls/shell32/tests/shlexec.c |   87 ++++++++++++++++++++++++++++++++++++++++++
IB>  1 files changed, 87 insertions(+), 0 deletions(-)

IB> diff --git a/dlls/shell32/tests/shlexec.c b/dlls/shell32/tests/shlexec.c
IB> index c673f0a..d575d22 100644
IB> --- a/dlls/shell32/tests/shlexec.c
IB> +++ b/dlls/shell32/tests/shlexec.c
IB> @@ -797,6 +797,10 @@ static const char* testfiles[]=
IB>      "%s\\test file.sde",
IB>      "%s\\test file.exe",
IB>      "%s\\test2.exe",
IB> +    "%s\\simple.shlexec",
IB> +    "%s\\drawback_file.noassoc",
IB> +    "%s\\drawback_file.noassoc foo.shlexec",
IB> +    "%s\\drawback_nonexist.noassoc foo.shlexec",
IB>      NULL
IB>  };
IB>  
IB> @@ -852,6 +856,88 @@ static filename_tests_t noquotes_tests[]=
IB>      {NULL, NULL, 0}
IB>  };
IB>  
IB> +static void test_lpFile_parsed(void)
IB> +{
IB> +    /* basename tmpdir */
IB> +    const char* shorttmpdir;
IB> +
IB> +    const char *testfile;
IB> +    char fileA[MAX_PATH];
IB> +
IB> +    int rc;
IB> +    int expected;
IB> +
IB> +    HMODULE hkernel32 = GetModuleHandle("kernel32");
IB> +    BOOL isreallyXP2k3plus = NULL != GetProcAddress(hkernel32, "AttachConsole");
IB> +
IB> +    GetTempPathA(sizeof(fileA), fileA);
IB> +    shorttmpdir = tmpdir + strlen(fileA);
IB> +
IB> +    /* ensure tmpdir is in %TEMP%: GetTempPath() can succeed even if TEMP is undefined */
IB> +    SetEnvironmentVariableA("TEMP", fileA);
IB> +
IB> +    #define TEST_LPFILE_PARSED_OK_() (rc==expected || rc>32 && expected>32)
IB> +    #define TEST_LPFILE_PARSED_OK() ok(TEST_LPFILE_PARSED_OK_(), "expected %s (%d), got %s (%d), lpFile: %s \n", expected==33 ? "success" : "failure", expected, rc > 32 ? "success" : "failure", rc, fileA)
IB> +
IB> +    /* existing "drawback_file.noassoc" prevents finding "drawback_file.noassoc foo.shlexec" on wine */
IB> +    testfile = "%s\\drawback_file.noassoc foo.shlexec";
IB> +    expected = 33; sprintf(fileA, testfile, tmpdir);
IB> +    rc=shell_execute(NULL, fileA, NULL, NULL);
IB> +    todo_wine { TEST_LPFILE_PARSED_OK(); }
IB> +
IB> +    /* if quoted, existing "drawback_file.noassoc" not prevents finding "drawback_file.noassoc foo.shlexec" on wine */
IB> +    testfile = "\"%s\\drawback_file.noassoc foo.shlexec\"";
IB> +    expected = 33; sprintf(fileA, testfile, tmpdir);
IB> +    rc=shell_execute(NULL, fileA, NULL, NULL);
IB> +    TEST_LPFILE_PARSED_OK();
IB> +
IB> +    /* error should be 2, not 31 */
IB> +    testfile = "\"%s\\drawback_file.noassoc\" foo.shlexec";
IB> +    expected = 2; sprintf(fileA, testfile, tmpdir);
IB> +    rc=shell_execute(NULL, fileA, NULL, NULL);
IB> +    TEST_LPFILE_PARSED_OK();
IB> +
IB> +    /* ""command"" not works on wine (and real win9x and w2k) */
IB> +    if (isreallyXP2k3plus) {
IB> +        testfile = "\"\"%s\\simple.shlexec\"\"";
IB> +        expected = 33; sprintf(fileA, testfile, tmpdir);
IB> +        rc=shell_execute(NULL, fileA, NULL, NULL);
IB> +        todo_wine { TEST_LPFILE_PARSED_OK(); }
IB> +    } else {
IB> +        win_skip("ShellExecute('\"\"command\"\"', ...) only works on XP/2k3 or newer\n");
IB> +    }
IB> +
IB> +    /* nonexisting "drawback_nonexist.noassoc" not prevents finding "drawback_nonexist.noassoc foo.shlexec" on wine */
IB> +    testfile = "%s\\drawback_nonexist.noassoc foo.shlexec";
IB> +    expected = 33; sprintf(fileA, testfile, tmpdir);
IB> +    rc=shell_execute(NULL, fileA, NULL, NULL);
IB> +    TEST_LPFILE_PARSED_OK();
IB> +
IB> +    /* is SEE_MASK_DOENVSUBST default flag? Should only be when XP emulates 9x (XP bug or real 95 or ME behavior ?) */
IB> +    testfile = "%%TEMP%%\\%s\\simple.shlexec";
IB> +    expected = 2; sprintf(fileA, testfile, shorttmpdir);
IB> +    rc=shell_execute(NULL, fileA, NULL, NULL);
IB> +    todo_wine { TEST_LPFILE_PARSED_OK(); }
IB> +
IB> +    /* quoted */
IB> +    testfile = "\"%%TEMP%%\\%s\\simple.shlexec\"";
IB> +    expected = 2; sprintf(fileA, testfile, shorttmpdir);
IB> +    rc=shell_execute(NULL, fileA, NULL, NULL);
IB> +    todo_wine { TEST_LPFILE_PARSED_OK(); }
IB> +
IB> +    /* test SEE_MASK_DOENVSUBST works */
IB> +    testfile = "%%TEMP%%\\%s\\simple.shlexec";
IB> +    expected = 33; sprintf(fileA, testfile, shorttmpdir);
IB> +    rc=shell_execute_ex(SEE_MASK_DOENVSUBST | SEE_MASK_FLAG_NO_UI, NULL, fileA, NULL, NULL);
IB> +    TEST_LPFILE_PARSED_OK();
IB> +
IB> +    /* quoted */
IB> +    testfile = "\"%%TEMP%%\\%s\\simple.shlexec\"";
IB> +    expected = 33; sprintf(fileA, testfile, shorttmpdir);
IB> +    rc=shell_execute_ex(SEE_MASK_DOENVSUBST | SEE_MASK_FLAG_NO_UI, NULL, fileA, NULL, NULL);
IB> +    TEST_LPFILE_PARSED_OK();
IB> +}
IB> +
IB>  static void test_filename(void)
IB>  {
IB>      char filename[MAX_PATH];
IB> @@ -1938,6 +2024,7 @@ START_TEST(shlexec)
IB>  
IB>      init_test();
IB>  
IB> +    test_lpFile_parsed();
IB>      test_filename();
IB>      test_find_executable();
IB>      test_lnks();



-- 




More information about the wine-devel mailing list