[llvm-commits] [test-suite] r58154 - /test-suite/trunk/RunSafely.sh

Dan Gohman gohman at apple.com
Sat Oct 25 14:45:37 PDT 2008


Author: djg
Date: Sat Oct 25 16:45:37 2008
New Revision: 58154

URL: http://llvm.org/viewvc/llvm-project?rev=58154&view=rev
Log:
Treat exit statuses that indicate failure to execute the test program
and exit statuses that indicate that the test program was terminated
by a signal as failures.

Also, report failures by writing a string to the output file which
will trigger a diff when it is compared with output files from other
runs of the test.

And, having reported any detected errors in a way that will be
visible to the test system, always exit "successfully". RunSafely.sh's
own exit status is not used to determine if a test has passed or failed.

Modified:
    test-suite/trunk/RunSafely.sh

Modified: test-suite/trunk/RunSafely.sh
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/RunSafely.sh?rev=58154&r1=58153&r2=58154&view=diff

==============================================================================
--- test-suite/trunk/RunSafely.sh (original)
+++ test-suite/trunk/RunSafely.sh Sat Oct 25 16:45:37 2008
@@ -11,11 +11,13 @@
 #           fourth argument specified, and outputs a <outfile>.time file which
 #           contains a timing of the program and the program's exit code.
 #          
-#           If the <exitok> parameter is 0 then this script always returns 0,
-#           regardless of the actual exit of the <program>.
-#           If the <exitok> parameter is non-zero then this script returns
-#           the exit code of the <program>. If there is an error in getting
-#           the <program>'s exit code, this script returns 99.
+#           The <exitok> parameter specifies how the program's exit status
+#           is interpreted.  If the <exitok> parameter is non-zero, any
+#           non-zero exit status from the program is considered to indicate
+#           a test failure.  If the <exitok> parameter is zero, only exit
+#           statuses that indicates that the program could not be executed
+#           normally or that the program was terminated as a signal are
+#           considered to indicate a test failure.
 #
 #           If optional parameters -r <remote host> -l <remote user> are
 #           specified, it execute the program remotely using rsh.
@@ -42,6 +44,10 @@
   exit 1
 fi
 
+# Save a copy of the original arguments in a string before we
+# clobber them with the shift command.
+ORIG_ARGS="$*"
+
 DIR=${0%%`basename $0`}
 
 RHOST=
@@ -145,18 +151,34 @@
 fi
 
 exitval=`grep '^exit ' $OUTFILE.time | sed -e 's/^exit //'`
+fail=yes
 if [ -z "$exitval" ] ; then
   exitval=99
-  echo "TEST $PROGRAM FAILED:  CAN'T GET EXIT CODE!"
+  echo "TEST $PROGRAM FAILED: CAN'T GET EXIT CODE!"
+elif test "$exitval" -eq 126 ; then
+  echo "TEST $PROGRAM FAILED: command not executable (exit status 126)!"
+elif test "$exitval" -eq 127 ; then
+  echo "TEST $PROGRAM FAILED: command not found (exit status 127)!"
+elif test "$exitval" -eq 128 ; then
+  # Exit status 128 doesn't have a standard meaning, but it's unlikely
+  # to be expected program behavior.
+  echo "TEST $PROGRAM FAILED: exit status 128!"
+elif test "$exitval" -gt 128 ; then
+  echo "TEST $PROGRAM FAILED: process terminated by signal (exit status $exitval)!"
+elif [ "$EXITOK" -ne 0 -a "$exitval" -ne 0 ] ; then
+  echo "TEST $PROGRAM FAILED: EXIT != 0"
+else
+  fail=no
 fi
 echo "exit $exitval" >> $OUTFILE
 
-if [ "$EXITOK" -ne 0 ] ; then
-  if test "$exitval" -ne 0 ; then
-    echo "TEST $PROGRAM FAILED:  EXIT != 0"
-  fi
-else
-  exitval=0
+# If we detected a failure, print the name of the test executable to the
+# output file. This will cause it to compare as different with other runs
+# of the same test even if they fail in the same way, because they'll have
+# different command names.
+if [ "${fail}" != "no" ]; then
+  echo "RunSafely.sh detected a failure with these command-line arguments: " \
+       "$ORIG_ARGS" >> $OUTFILE
 fi
 
 if ls | egrep "^core" > /dev/null
@@ -176,4 +198,5 @@
     $GDB -q -batch --command=StackTrace.$$ --core=$corefile $PROGRAM < /dev/null
     rm -f StackTrace.$$ $corefile
 fi
-exit "$exitval"
+# Always return "successful" so that tests will continue to be run.
+exit 0





More information about the llvm-commits mailing list