Index: RunSafely.sh =================================================================== --- RunSafely.sh +++ RunSafely.sh @@ -16,11 +16,12 @@ # # Syntax: # -# RunSafely.sh [-r ] [-l ] [-rc ] [-rp ] -# [-u ] [--show-errors] [--omit-exitval] -t -# +# RunSafely.sh [--omit-exitval] [-d ] [-r ] [-l ] +# [-rc ] [-rp ] [-u ] [--show-errors] +# -t # # where: +# is the directory where the program is executed # is the remote host to execute the program # is the username on the remote host # is the remote client used to execute the program @@ -58,9 +59,14 @@ TIMEIT= SHOW_ERRORS=0 OMIT_EXITVAL=0 +PWD=`pwd` if [ $1 = "--omit-exitval" ]; then - OMIT_EXITVAL=1 - shift 1 + OMIT_EXITVAL=1 + shift 1 +fi +if [ $1 = "-d" ]; then + PWD="$2" + shift 2 fi if [ $1 = "-r" ]; then RHOST=$2 @@ -126,7 +132,6 @@ # Run the command, timing its execution and logging the status summary to # $OUTFILE.time. -PWD=`pwd` COMMAND="$RUN_UNDER $PROGRAM $*" TIMEITCMD="$TIMEIT $LIMITARGS --timeout $TIMELIMIT --chdir $PWD" Index: cmake/modules/SingleMultiSource.cmake =================================================================== --- cmake/modules/SingleMultiSource.cmake +++ cmake/modules/SingleMultiSource.cmake @@ -187,7 +187,7 @@ endmacro() macro(llvm_test_run) - CMAKE_PARSE_ARGUMENTS(ARGS "" "RUN_TYPE;EXECUTABLE" "" ${ARGN}) + CMAKE_PARSE_ARGUMENTS(ARGS "" "RUN_TYPE;EXECUTABLE;WORKDIR" "" ${ARGN}) # If no executable is specified use $EXECUTABLE$ placeholder which will be # replaced later. if(NOT DEFINED ARGS_EXECUTABLE) @@ -196,6 +196,9 @@ if(NOT DEFINED TESTSCRIPT) set(TESTSCRIPT "" PARENT_SCOPE) endif() + if(DEFINED ARGS_WORKDIR) + set(ARGS_EXECUTABLE "cd ${ARGS_WORKDIR} ; ${ARGS_EXECUTABLE}") + endif() # ARGS_UNPARSED_ARGUMENTS is a semicolon-separated list. Change it into a # whitespace-separated string. string(REPLACE ";" " " JOINED_ARGUMENTS "${ARGS_UNPARSED_ARGUMENTS}") Index: lit.cfg =================================================================== --- lit.cfg +++ lit.cfg @@ -108,20 +108,36 @@ def prependRunSafely(line): # Search for "< INPUTFILE" in the line and use that for stdin stdin = "/dev/null" + stdout = outfile + workdir = None commandline = shlex.split(line) - for i in range(len(commandline)): - if commandline[i] == "<" and i+1 < len(commandline): + i = 0 + while i < len(commandline): + if i+2 < len(commandline) and commandline[i] == "cd" \ + and commandline[i+2] == ";": + workdir = commandline[i+1] + del commandline[i+2] + del commandline[i+1] + del commandline[i] + elif commandline[i] == "<" and i+1 < len(commandline): stdin = commandline[i+1] del commandline[i+1] del commandline[i] - break + elif commandline[i] == ">" and i+1 < len(commandline): + stdout = commandline[i+1] + del commandline[i+1] + del commandline[i] + else: + i += 1 timeit = "%s/tools/timeit" % config.test_source_root runsafely = "%s/RunSafely.sh" % config.test_suite_root timeout = "7200" - runsafely_prefix = [runsafely, "-t", timeit, timeout, stdin, - outfile] + runsafely_prefix = [runsafely] if not config.output_append_exitstatus: - runsafely_prefix.insert(1, "--omit-exitval") + runsafely_prefix += ["--omit-exitval"] + if workdir is not None: + runsafely_prefix += ["-d", workdir] + runsafely_prefix += ["-t", timeit, timeout, stdin, stdout] line = " ".join(map(quote, runsafely_prefix + commandline)) return line