[test-suite] r254836 - RunSafely.sh: Allow the specification of a working directory

Matthias Braun via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 4 20:39:36 PST 2015


Author: matze
Date: Fri Dec  4 22:39:36 2015
New Revision: 254836

URL: http://llvm.org/viewvc/llvm-project?rev=254836&view=rev
Log:
RunSafely.sh: Allow the specification of a working directory

As discussed in D14678 I am going for post-commit review as cmake/lit
test-suite support is still in early development.

Differential Revision: http://reviews.llvm.org/D14680

Modified:
    test-suite/trunk/RunSafely.sh
    test-suite/trunk/cmake/modules/SingleMultiSource.cmake
    test-suite/trunk/lit.cfg

Modified: test-suite/trunk/RunSafely.sh
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/RunSafely.sh?rev=254836&r1=254835&r2=254836&view=diff
==============================================================================
--- test-suite/trunk/RunSafely.sh (original)
+++ test-suite/trunk/RunSafely.sh Fri Dec  4 22:39:36 2015
@@ -16,11 +16,12 @@
 #
 # Syntax:
 #
-#   RunSafely.sh [-r <rhost>] [-l <ruser>] [-rc <client>] [-rp <port>]
-#                [-u <under>] [--show-errors] [--omit-exitval] -t <timeit>
-#                <timeout> <infile> <outfile> <program> <args...>
+#   RunSafely.sh [--omit-exitval] [-d <workdir>] [-r <rhost>] [-l <ruser>]
+#                [-rc <client>] [-rp <port>] [-u <under>] [--show-errors]
+#                -t <timeit> <timeout> <infile> <outfile> <program> <args...>
 #
 #   where:
+#     <workdir> is the directory where the program is executed
 #     <rhost>   is the remote host to execute the program
 #     <ruser>   is the username on the remote host
 #     <client>  is the remote client used to execute the program
@@ -57,9 +58,14 @@ RUN_UNDER=
 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 @@ LIMITARGS="$LIMITARGS --limit-rss-size 8
 
 # 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"

Modified: test-suite/trunk/cmake/modules/SingleMultiSource.cmake
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/cmake/modules/SingleMultiSource.cmake?rev=254836&r1=254835&r2=254836&view=diff
==============================================================================
--- test-suite/trunk/cmake/modules/SingleMultiSource.cmake (original)
+++ test-suite/trunk/cmake/modules/SingleMultiSource.cmake Fri Dec  4 22:39:36 2015
@@ -187,7 +187,7 @@ macro(llvm_multisource)
 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 @@ macro(llvm_test_run)
   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}")

Modified: test-suite/trunk/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/lit.cfg?rev=254836&r1=254835&r2=254836&view=diff
==============================================================================
--- test-suite/trunk/lit.cfg (original)
+++ test-suite/trunk/lit.cfg Fri Dec  4 22:39:36 2015
@@ -84,6 +84,7 @@ def prepareRunSafely(config, commandline
     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 @@ def prepareRunSafely(config, commandline
             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 @@ def prepareRunSafely(config, commandline
     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:




More information about the llvm-commits mailing list