#!/bin/sh NAME="$1" if [ -z "${COMPILE_TEST+x}" -o -z "${TEST_LIBS+x}" ]; then echo "Test runner script must have COMPILE_TEST and TEST_LIBS defined." exit 1 fi try_vg() { if [ "x$VALGRIND" != "x0" ] && which valgrind > /dev/null >&1; then eval "valgrind -q --leak-check=full --error-exitcode=169 $1" else eval "$1" fi RETVAL=$? return "$RETVAL" } I=0 while :; do if try_vg "../fwd $NAME/$NAME.fwd" \ 1> "reports/$NAME/gen.c" \ 2> "reports/$NAME/run-$I" then # fwd succeeded, compile and run program to check result # remove possible COVSRV lines in output sed -i "s/COVSRV:.*$//" "reports/$NAME/gen.c" eval "$COMPILE_TEST reports/$NAME/gen.c -o reports/$NAME/$NAME $TEST_LIBS" ./reports/$NAME/$NAME > reports/$NAME/OK 2>&1 exit 0 fi if [ "$RETVAL" = 169 ]; then echo "VALGRIND" > reports/$NAME/OK # don't return on an error so that makefile continues running # other tests that are maybe failing, and reports the status # after all tests have been run exit 0 fi # correctly handled coverage exception, continue to next run if grep 'COVSRV: EXIT' "reports/$NAME/gen.c" > /dev/null \ && grep 'internal error:' "reports/$NAME/run-$I" > /dev/null; then I=$((I+1)) continue fi # incorrectly handled coverage exception, stop run echo "MEMERR" > reports/$NAME/OK exit 0 done