Index: test-suite/trunk/RunSafely.sh =================================================================== --- test-suite/trunk/RunSafely.sh +++ test-suite/trunk/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 @@ -57,9 +58,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 @@ -125,7 +131,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: test-suite/trunk/cmake/modules/SingleMultiSource.cmake =================================================================== --- test-suite/trunk/cmake/modules/SingleMultiSource.cmake +++ test-suite/trunk/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: test-suite/trunk/lit.cfg =================================================================== --- test-suite/trunk/lit.cfg +++ test-suite/trunk/lit.cfg @@ -84,6 +84,7 @@ stdin = None stdout = None stderr = None + workdir = None tokens = shlex.split(commandline) # Parse "< INPUTFILE", "> OUTFILE", "2> OUTFILE" patterns for i in range(len(tokens)): @@ -102,6 +103,11 @@ del tokens[i+1] del tokens[i] break + if i+2 < len(tokens) and tokens[i] == "cd" and tokens[i+2] == ";": + workdir = tokens[i+1] + del tokens[i+2] + del tokens[i+1] + del tokens[i] if stdin is None: stdin = "/dev/null" @@ -111,7 +117,9 @@ runsafely = "%s/RunSafely.sh" % config.test_suite_root runsafely_prefix = [ runsafely ] if not config.output_append_exitstatus: - runsafely_prefix += ["--omit-exitval"] + runsafely_prefix += [ "--omit-exitval" ] + if workdir is not None: + runsafely_prefix += [ "-d", workdir ] if config.remote_host: runsafely_prefix += [ "-r", config.remote_host ] if config.remote_user: