]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Fix running bsdcpio_test in a dir with spaces by quoting the program name appropriately.
authorTim Kientzle <kientzle@gmail.com>
Sun, 28 Jun 2009 08:00:33 +0000 (04:00 -0400)
committerTim Kientzle <kientzle@gmail.com>
Sun, 28 Jun 2009 08:00:33 +0000 (04:00 -0400)
SVN-Revision: 1199

cpio/test/main.c
cpio/test/test.h
cpio/test/test_0.c

index e5fa77d7d03e991f226a5b49e74d8af17f679624..42d4cb95d7272f139cc8e7e422462d148706ba11 100644 (file)
@@ -1016,7 +1016,7 @@ int main(int argc, char **argv)
 
 #ifdef PROGRAM
        /* Get the target program from environment, if available. */
-       testprog = getenv(ENVBASE);
+       testprogfile = getenv(ENVBASE);
 #endif
 
        if (getenv("TMPDIR") != NULL)
@@ -1073,7 +1073,7 @@ int main(int argc, char **argv)
                                break;
                        case 'p':
 #ifdef PROGRAM
-                               testprog = opt_arg;
+                               testprogfile = opt_arg;
 #else
                                usage(progname);
 #endif
@@ -1098,21 +1098,26 @@ int main(int argc, char **argv)
         * Sanity-check that our options make sense.
         */
 #ifdef PROGRAM
-       if (testprog == NULL)
+       if (testprogfile == NULL)
                usage(progname);
 #endif
 #if defined(_WIN32) && !defined(__CYGWIN__)
        /*
-        * Command.exe cannot accept the command used '/' with drive
+        * command.com cannot accept the command used '/' with drive
         * name such as c:/xxx/command.exe when use '|' pipe handling.
         */
-       testprg = strdup(testprog);
+       testprg = strdup(testprogfile);
        for (i = 0; testprg[i] != '\0'; i++) {
                if (testprg[i] == '/')
                        testprg[i] = '\\';
        }
-       testprog = testprg;
+       testprogfile = testprg;
 #endif
+       testprg = malloc(strlen(testprogfile) + 3);
+       strcpy(testprg, "\"");
+       strcat(testprg, testprogfile);
+       strcat(testprg, "\"");
+       testprog = testprg;
 
        /*
         * Create a temp directory for the following tests.
index 327668fa1b2106fe91df7123a0c7c0e0f15dbd4d..a112c625eb03c83a7ab6b2064190c41573171ce7 100644 (file)
@@ -167,5 +167,7 @@ void extract_reference_file(const char *);
  * Special interfaces for program test harness.
  */
 
-/* Pathname of exe to be tested. */
+/* Pathname of exe to be tested, with suitable quoting for building shell cmd lines. */
 const char *testprog;
+/* Raw pathname of exe to be tested. */
+const char *testprogfile; 
\ No newline at end of file
index d224daaeacc2df59ec9e6a5ed0a22f2df34d53ac..75a1437fd70e506e1576af576d84f988bcf13666 100644 (file)
@@ -39,11 +39,11 @@ DEFINE_TEST(test_0)
 {
        struct stat st;
 
-       failure("File %s does not exist?!", testprog);
-       if (!assertEqualInt(0, stat(testprog, &st)))
+       failure("File %s does not exist?!", testprogfile);
+       if (!assertEqualInt(0, stat(testprogfile, &st)))
                exit(1);
 
-       failure("%s is not executable?!", testprog);
+       failure("%s is not executable?!", testprogfile);
        if (!assert((st.st_mode & 0111) != 0))
                exit(1);