2003-01-19 21:07:38 +03:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Program: RunSafely.sh
|
|
|
|
#
|
|
|
|
# Synopsis: This script simply runs another program. If the program works
|
|
|
|
# correctly, this script has no effect, otherwise it will do things
|
|
|
|
# like print a stack trace of a core dump. It always returns
|
|
|
|
# "successful" so that tests will continue to be run.
|
|
|
|
#
|
2003-05-11 21:34:14 +04:00
|
|
|
# This script funnels stdout and stderr from the program into the
|
|
|
|
# first argument specified, and outputs a <outputfile>.time file which
|
|
|
|
# contains a timing of the program.
|
2003-01-19 21:07:38 +03:00
|
|
|
#
|
2003-06-01 03:16:10 +04:00
|
|
|
# Syntax: ./RunSafely.sh <ulimit> <stdinfile> <stdoutfile> <program> <args...>
|
2003-05-11 21:34:14 +04:00
|
|
|
#
|
2003-05-18 02:32:43 +04:00
|
|
|
ULIMIT=$1
|
|
|
|
shift
|
2003-06-01 03:16:10 +04:00
|
|
|
INFILE=$1
|
|
|
|
shift
|
2003-05-11 21:34:14 +04:00
|
|
|
OUTFILE=$1
|
|
|
|
shift
|
2003-01-19 21:07:38 +03:00
|
|
|
PROGRAM=$1
|
|
|
|
shift
|
|
|
|
|
2003-05-18 02:32:43 +04:00
|
|
|
ulimit -t $ULIMIT
|
2003-05-11 21:34:14 +04:00
|
|
|
rm -f core core.*
|
2003-05-11 22:55:29 +04:00
|
|
|
ulimit -c unlimited
|
2003-06-18 19:41:02 +04:00
|
|
|
(time -p $PROGRAM $* 2> $OUTFILE > $OUTFILE < $INFILE) 2> $OUTFILE.time
|
2003-07-01 22:04:43 +04:00
|
|
|
if test $? -eq 0
|
|
|
|
then
|
|
|
|
touch $OUTFILE.exitok
|
|
|
|
fi
|
|
|
|
|
2003-01-19 21:07:38 +03:00
|
|
|
if ls | egrep "^core" > /dev/null
|
|
|
|
then
|
|
|
|
corefile=`ls core* | head -1`
|
|
|
|
echo "where" > StackTrace.$$
|
|
|
|
gdb -q -batch --command=StackTrace.$$ --core=$corefile $PROGRAM < /dev/null
|
|
|
|
rm -f StackTrace.$$ $corefile
|
|
|
|
fi
|
|
|
|
|
|
|
|
exit 0
|