Add a trivial script to extract the times from *.report.txt files.
[llvm-testsuite.git] / RunToolSafely.sh
blobc3f9679a8cb321c5097563cc1164ec7d3de8a859
1 #!/bin/sh
3 set -eu
5 if [ $# -lt 2 ]; then
6 echo "usage: $0 <timeout> <program> <args...>"
7 echo
8 echo " This script simply runs another program under ulimit and always"
9 echo " returns true. It is used for invoking tools from the LLVM test suite"
10 echo " Makefiles, where we need them to always return true so that we don't"
11 echo " abort the test run."
12 exit 1
15 # Save a copy of the original arguments in a string before we
16 # clobber them with the shift command.
17 TIMEOUT=$1
18 shift
19 PROGRAM=$1
20 shift
22 SYSTEM=`uname -s`
24 ULIMITCMD=""
25 case $SYSTEM in
26 CYGWIN*)
28 Darwin*)
29 # Disable core file emission, the script doesn't find it anyway because it
30 # is put into /cores.
31 ULIMITCMD="$ULIMITCMD ulimit -c 0;"
32 ULIMITCMD="$ULIMITCMD ulimit -t $TIMEOUT;"
33 # To prevent infinite loops which fill up the disk, specify a limit on size
34 # of files being output by the tests. 10 MB should be enough for anybody. ;)
35 ULIMITCMD="$ULIMITCMD ulimit -f 10485760;"
38 ULIMITCMD="$ULIMITCMD ulimit -t $TIMEOUT;"
39 ULIMITCMD="$ULIMITCMD ulimit -c unlimited;"
40 # To prevent infinite loops which fill up the disk, specify a limit on size
41 # of files being output by the tests. 10 MB should be enough for anybody. ;)
42 ULIMITCMD="$ULIMITCMD ulimit -f 10485760;"
44 # virtual memory: 600 MB should be enough for anybody. ;)
45 ULIMITCMD="$ULIMITCMD ulimit -v 600000;"
46 esac
48 if ( ! sh -c "$ULIMITCMD sh -c '$PROGRAM $*'" ); then
49 echo "warning: command failed: '$PROGRAM $*'"
52 # Always return "successful" so that tests will continue to be run.
53 exit 0