[test-suite] r255874 - RunSafely/lit: Allow separate stdout/stderr redirection.
Matthias Braun via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 16 20:33:51 PST 2015
Author: matze
Date: Wed Dec 16 22:33:50 2015
New Revision: 255874
URL: http://llvm.org/viewvc/llvm-project?rev=255874&view=rev
Log:
RunSafely/lit: Allow separate stdout/stderr redirection.
This will be necessary for the upcoming SPEC support for cmake/lit which will
use the reference data coming with SPEC instead of the custom one in
the Externals directory.
This commit also reverses the setting for the RunSafely output format to
produce the traditional output format by default because that is still
used by most benchmarks. That way fewer lit.local.cfg files are
necessary.
Removed:
test-suite/trunk/External/Nurbs/lit.local.cfg
test-suite/trunk/External/Povray/lit.local.cfg
test-suite/trunk/External/skidmarks10/lit.local.cfg
test-suite/trunk/MultiSource/lit.local.cfg
test-suite/trunk/SingleSource/lit.local.cfg
Modified:
test-suite/trunk/External/Nurbs/CMakeLists.txt
test-suite/trunk/External/Povray/CMakeLists.txt
test-suite/trunk/External/skidmarks10/CMakeLists.txt
test-suite/trunk/MultiSource/CMakeLists.txt
test-suite/trunk/RunSafely.sh
test-suite/trunk/SingleSource/CMakeLists.txt
test-suite/trunk/lit.cfg
Modified: test-suite/trunk/External/Nurbs/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/External/Nurbs/CMakeLists.txt?rev=255874&r1=255873&r2=255874&view=diff
==============================================================================
--- test-suite/trunk/External/Nurbs/CMakeLists.txt (original)
+++ test-suite/trunk/External/Nurbs/CMakeLists.txt Wed Dec 16 22:33:50 2015
@@ -19,5 +19,4 @@ if(ARCH STREQUAL "x86")
llvm_multisource()
endif()
- file(COPY lit.local.cfg DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
endif()
Removed: test-suite/trunk/External/Nurbs/lit.local.cfg
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/External/Nurbs/lit.local.cfg?rev=255873&view=auto
==============================================================================
--- test-suite/trunk/External/Nurbs/lit.local.cfg (original)
+++ test-suite/trunk/External/Nurbs/lit.local.cfg (removed)
@@ -1 +0,0 @@
-config.output_append_exitstatus = True
Modified: test-suite/trunk/External/Povray/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/External/Povray/CMakeLists.txt?rev=255874&r1=255873&r2=255874&view=diff
==============================================================================
--- test-suite/trunk/External/Povray/CMakeLists.txt (original)
+++ test-suite/trunk/External/Povray/CMakeLists.txt Wed Dec 16 22:33:50 2015
@@ -35,4 +35,3 @@ if(TEST_SUITE_POVRAY_ROOT)
llvm_multisource()
endif()
-file(COPY lit.local.cfg DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
Removed: test-suite/trunk/External/Povray/lit.local.cfg
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/External/Povray/lit.local.cfg?rev=255873&view=auto
==============================================================================
--- test-suite/trunk/External/Povray/lit.local.cfg (original)
+++ test-suite/trunk/External/Povray/lit.local.cfg (removed)
@@ -1 +0,0 @@
-config.output_append_exitstatus = True
Modified: test-suite/trunk/External/skidmarks10/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/External/skidmarks10/CMakeLists.txt?rev=255874&r1=255873&r2=255874&view=diff
==============================================================================
--- test-suite/trunk/External/skidmarks10/CMakeLists.txt (original)
+++ test-suite/trunk/External/skidmarks10/CMakeLists.txt Wed Dec 16 22:33:50 2015
@@ -15,4 +15,3 @@ if(TEST_SUITE_SKIDMARKS10_ROOT)
)
llvm_multisource()
endif()
-file(COPY lit.local.cfg DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
Removed: test-suite/trunk/External/skidmarks10/lit.local.cfg
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/External/skidmarks10/lit.local.cfg?rev=255873&view=auto
==============================================================================
--- test-suite/trunk/External/skidmarks10/lit.local.cfg (original)
+++ test-suite/trunk/External/skidmarks10/lit.local.cfg (removed)
@@ -1 +0,0 @@
-config.output_append_exitstatus = True
Modified: test-suite/trunk/MultiSource/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/CMakeLists.txt?rev=255874&r1=255873&r2=255874&view=diff
==============================================================================
--- test-suite/trunk/MultiSource/CMakeLists.txt (original)
+++ test-suite/trunk/MultiSource/CMakeLists.txt Wed Dec 16 22:33:50 2015
@@ -11,5 +11,3 @@ endif()
llvm_multisource()
llvm_add_subdirectories(${DIRS} ${PARALLEL_DIRS})
-
-file(COPY lit.local.cfg DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
Removed: test-suite/trunk/MultiSource/lit.local.cfg
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/lit.local.cfg?rev=255873&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/lit.local.cfg (original)
+++ test-suite/trunk/MultiSource/lit.local.cfg (removed)
@@ -1 +0,0 @@
-config.output_append_exitstatus = True
Modified: test-suite/trunk/RunSafely.sh
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/RunSafely.sh?rev=255874&r1=255873&r2=255874&view=diff
==============================================================================
--- test-suite/trunk/RunSafely.sh (original)
+++ test-suite/trunk/RunSafely.sh Wed Dec 16 22:33:50 2015
@@ -16,8 +16,9 @@
#
# Syntax:
#
-# RunSafely.sh [--omit-exitval] [-d <workdir>] [-r <rhost>] [-l <ruser>]
-# [-rc <client>] [-rp <port>] [-u <under>] [--show-errors]
+# RunSafely.sh [-d <workdir>] [-r <rhost>] [-l <ruser>] [-rc <client>]
+# [-rp <port>] [-u <under>] [--show-errors]
+# [-n [-o <stdoutfile>] [-e <stderrfile>]]
# -t <timeit> <timeout> <infile> <outfile> <program> <args...>
#
# where:
@@ -27,16 +28,23 @@
# <client> is the remote client used to execute the program
# <port> is the port used by the remote client
# <under> is a wrapper that the program is run under
+# <stdoutfile> file where standard output is written to
+# <stderrfile> file where standard error output is written to
# <timeit> is a wrapper that is used to collect timing data
# <timeout> is the maximum number of seconds to let the <program> run
# <infile> is a file from which standard input is directed
-# <outfile> is a file to which standard output and error are directed
+# <outfile> is a file to which standard output and error are directed.
+# If -n was specified this is just used as the basename for the
+# .time file.
# <program> is the path to the program to run
# <args...> are the arguments to pass to the program.
#
# If --show-errors is given, then the output file will be printed if the command
# fails (returns a non-zero exit code).
-# Unless --omit-exitval is given the last line of the outfile has the form
+# The -n switch will enable "new-style" output. This means the exit status is
+# not appended to the output anymore and stdout and stderr may be redirected
+# separately.
+# Without -n stdout and stderr will both be written to the <outfile> followed by
# "exit NN" with NN being the exit status number of the program.
if [ $# -lt 4 ]; then
@@ -57,12 +65,10 @@ RCLIENT=rsh
RUN_UNDER=
TIMEIT=
SHOW_ERRORS=0
-OMIT_EXITVAL=0
+NEW_MODE=0
+STDOUT_FILE=""
+STDERR_FILE=""
PWD=`pwd`
-if [ $1 = "--omit-exitval" ]; then
- OMIT_EXITVAL=1
- shift 1
-fi
if [ $1 = "-d" ]; then
PWD="$2"
shift 2
@@ -91,6 +97,18 @@ if [ $1 = "--show-errors" ]; then
SHOW_ERRORS=1
shift 1
fi
+if [ $1 = "-n" ]; then
+ NEW_MODE=1
+ shift 1
+ if [ $1 = "-o" ]; then
+ STDOUT_FILE="$2"
+ shift 2
+ fi
+ if [ $1 = "-e" ]; then
+ STDERR_FILE="$2"
+ shift 2
+ fi
+fi
if [ $1 = "-t" ]; then
TIMEIT=$2
shift 2
@@ -118,6 +136,18 @@ COMMAND="$RUN_UNDER $PROGRAM $*"
# Determine absolute paths of infiles/outfiles
INFILE="$(cd $(dirname $INFILE); pwd)/$(basename $INFILE)"
+if [ "$STDOUT_FILE" != "" ]; then
+ case "$STDOUT_FILE" in
+ /*) STDOUT_FILE="$STDOUT_FILE";;
+ *) STDOUT_FILE="$PWD/$STDOUT_FILE";;
+ esac
+fi
+if [ "$STDERR_FILE" != "" ]; then
+ case "$STDERR_FILE" in
+ /*) STDERR_FILE="$STDERR_FILE";;
+ *) STDERR_FILE="$PWD/$STDERR_FILE";;
+ esac
+fi
case "$OUTFILE" in
/*) OUTFILE="$OUTFILE";;
*) OUTFILE="$PWD/$OUTFILE";;
@@ -149,7 +179,16 @@ TIMEITFLAGS="$TIMEITFLAGS --limit-rss-si
TIMEITFLAGS="$TIMEITFLAGS --timeout $TIMELIMIT --chdir $PWD"
TIMEITFLAGS="$TIMEITFLAGS --redirect-input ${INFILE}"
TIMEITFLAGS="$TIMEITFLAGS --summary ${OUTFILE}.time${REMOTE_SUFFIX}"
-TIMEITFLAGS="$TIMEITFLAGS --redirect-output ${OUTFILE}${REMOTE_SUFFIX}"
+if [ "$NEW_MODE" = "0" ]; then
+ TIMEITFLAGS="$TIMEITFLAGS --redirect-output ${OUTFILE}${REMOTE_SUFFIX}"
+else
+ if [ "$STDERR_FILE" != "" ]; then
+ TIMEITFLAGS="$TIMEITFLAGS --redirect-stderr ${STDERR_FILE}${REMOTE_SUFFIX}"
+ fi
+ if [ "$STDOUT_FILE" != "" ]; then
+ TIMEITFLAGS="$TIMEITFLAGS --redirect-stdout ${STDOUT_FILE}${REMOTE_SUFFIX}"
+ fi
+fi
# Run the command
rm -f "${OUTFILE}.time" "${OUTFILE}" "${STDOUT_FILE}" "${STDERR_FILE}"
@@ -157,6 +196,7 @@ if [ "x$RHOST" = x ] ; then
$TIMEIT $TIMEITFLAGS $COMMAND
else
rm -f "${OUTFILE}.time${REMOTE_SUFFIX}" "${OUTFILE}${REMOTE_SUFFIX}"
+ rm -f "${STDOUT_FILE}${REMOTE_SUFFIX}" "${STDERR_FILE}${REMOTE_SUFFIX}"
# Create .command script
PROG_BASENAME="$(basename ${PROG})"
@@ -170,8 +210,19 @@ else
# Copy remote files back
cp -f "${OUTFILE}.time${REMOTE_SUFFIX}" "${OUTFILE}.time"
- cp -f "${OUTFILE}${REMOTE_SUFFIX}" "${OUTFILE}"
- rm -f "${OUTFILE}${REMOTE_SUFFIX}"
+ if [ "$NEW_MODE" = "0" ]; then
+ cp -f "${OUTFILE}${REMOTE_SUFFIX}" "${OUTFILE}"
+ rm -f "${OUTFILE}${REMOTE_SUFFIX}"
+ else
+ if [ "$STDERR_FILE" != "" ]; then
+ cp -f "${STDERR_FILE}${REMOTE_SUFFIX}" "${STDERR_FILE}"
+ rm -f "${STDERR_FILE}${REMOTE_SUFFIX}"
+ fi
+ if [ "$STDOUT_FILE" != "" ]; then
+ cp -f "${STDOUT_FILE}${REMOTE_SUFFIX}" "${STDOUT_FILE}"
+ rm -f "${STDOUT_FILE}${REMOTE_SUFFIX}"
+ fi
+ fi
fi
exitval=`grep '^exit ' $OUTFILE.time | sed -e 's/^exit //'`
@@ -194,7 +245,7 @@ elif [ "$SHOW_ERRORS" -eq 1 -a "$exitval
else
fail=no
fi
-if [ "$OMIT_EXITVAL" -ne 1 ]; then
+if [ "$NEW_MODE" = "0" ]; then
echo "exit $exitval" >> $OUTFILE
fi
Modified: test-suite/trunk/SingleSource/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/CMakeLists.txt?rev=255874&r1=255873&r2=255874&view=diff
==============================================================================
--- test-suite/trunk/SingleSource/CMakeLists.txt (original)
+++ test-suite/trunk/SingleSource/CMakeLists.txt Wed Dec 16 22:33:50 2015
@@ -11,5 +11,3 @@ endif()
llvm_singlesource()
llvm_add_subdirectories(${DIRS} ${PARALLEL_DIRS})
-
-file(COPY lit.local.cfg DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
Removed: test-suite/trunk/SingleSource/lit.local.cfg
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/lit.local.cfg?rev=255873&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/lit.local.cfg (original)
+++ test-suite/trunk/SingleSource/lit.local.cfg (removed)
@@ -1 +0,0 @@
-config.output_append_exitstatus = True
Modified: test-suite/trunk/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/lit.cfg?rev=255874&r1=255873&r2=255874&view=diff
==============================================================================
--- test-suite/trunk/lit.cfg (original)
+++ test-suite/trunk/lit.cfg Wed Dec 16 22:33:50 2015
@@ -87,37 +87,33 @@ def prepareRunSafely(config, commandline
workdir = None
tokens = shlex.split(commandline)
# Parse "< INPUTFILE", "> OUTFILE", "2> OUTFILE" patterns
- for i in range(len(tokens)):
+ i = 0
+ while i < len(tokens):
if tokens[i] == "<" and i+1 < len(tokens):
stdin = tokens[i+1]
del tokens[i+1]
del tokens[i]
- break
+ continue
elif tokens[i] == ">" and i+1 < len(tokens):
stdout = tokens[i+1]
del tokens[i+1]
del tokens[i]
- break
+ continue
elif tokens[i] == "2>" and i+1 < len(tokens):
stderr = tokens[i+1]
del tokens[i+1]
del tokens[i]
- break
+ continue
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"
- if stdout is not None or stderr is not None:
- raise Exception("stdout/stderr redirection in combination with RunSafely not implemented yet")
+ continue
+ i += 1
runsafely = "%s/RunSafely.sh" % config.test_suite_root
runsafely_prefix = [ runsafely ]
- if not config.output_append_exitstatus:
- runsafely_prefix += [ "--omit-exitval" ]
if workdir is not None:
runsafely_prefix += [ "-d", workdir ]
if config.remote_host:
@@ -130,8 +126,19 @@ def prepareRunSafely(config, commandline
runsafely_prefix += [ "-rp", config.remote_port ]
if config.run_under:
runsafely_prefix += [ "-u", config.run_under ]
+ if not config.traditional_output:
+ runsafely_prefix += [ "-n" ]
+ if stdout is not None:
+ runsafely_prefix += [ "-o", stdout ]
+ if stderr is not None:
+ runsafely_prefix += [ "-e", stderr ]
+ else:
+ if stdout is not None or stderr is not None:
+ raise Exception("separate stdout/stderr redirection not possible with traditional output")
timeit = "%s/tools/timeit-target" % config.test_source_root
timeout = "7200"
+ if stdin is None:
+ stdin = "/dev/null"
runsafely_prefix += [ "-t", timeit, timeout, stdin, outfile ]
new_commandline = " ".join(map(quote, runsafely_prefix + tokens))
@@ -225,6 +232,6 @@ config.name = 'test-suite'
config.test_format = TestSuiteTest()
config.suffixes = ['.test']
config.excludes = ['ABI-Testsuite']
-config.output_append_exitstatus = False
+config.traditional_output = True
if 'SSH_AUTH_SOCK' in os.environ:
config.environment['SSH_AUTH_SOCK'] = os.environ['SSH_AUTH_SOCK']
More information about the llvm-commits
mailing list