#ifdef PROGRAM
/* Get the target program from environment, if available. */
- testprog = getenv(ENVBASE);
+ testprogfile = getenv(ENVBASE);
#endif
if (getenv("TMPDIR") != NULL)
break;
case 'p':
#ifdef PROGRAM
- testprog = opt_arg;
+ testprogfile = opt_arg;
#else
usage(progname);
#endif
* 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.
* 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
{
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);