regress.m4 revision 98758
1# $FreeBSD: head/tools/regression/usr.bin/regress.m4 98758 2002-06-24 14:19:57Z jmallett $ 2 3dnl A library of routines for doing regression tests for userland utilities. 4 5dnl Start up. We initialise the exit status to 0 (no failure) and change 6dnl into the directory specified by our first argument, which is the 7dnl directory to run the tests inside. 8define(`REGRESSION_START', 9TESTDIR=$1 10if [ -z "$TESTDIR" ]; then 11 TESTDIR=. 12fi 13cd $TESTDIR 14 15STATUS=0) 16 17dnl An actual test. The first parameter is the test name. The second is the 18dnl command/commands to execute for the actual test. Their exit status is 19dnl checked. It is assumed that the test will output to stdout, and that the 20dnl output to be used to check for regression will be in regress.TESTNAME.out. 21define(`REGRESSION_TEST', 22echo "Running test $1" 23$2 | diff -u regress.$1.out - 24if [ $? -eq 0 ]; then 25 echo "PASS: Test $1 detected no regression." 26else 27 STATUS=$? 28 echo "FAIL: Test $1 failed: regression detected. See above." 29fi) 30 31dnl A freeform regression test. Only exit status is checked. 32define(`REGRESSION_TEST_FREEFORM', 33$2 34if [ $? -eq 0 ]; then 35 echo "PASS: Test $1 detected no regression." 36else 37 STATUS=$? 38 echo "FAIL: Test $1 failed: regression detected. See above." 39fi) 40 41dnl A regression test like REGRESSION_TEST, except only regress.out is used 42dnl for checking output differences. The first argument is the command, the 43dnl second argument (which may be empty) is the test name. 44define(`REGRESSION_TEST_ONE', 45echo "Running test $2" 46$1 | diff -u regress.out - 47if [ $? -eq 0 ]; then 48 echo "PASS: Test $2 detected no regression." 49else 50 STATUS=$? 51 echo "FAIL: Test $2 failed: regression detected. See above." 52fi) 53 54dnl A fatal error. This will exit with the given status (first argument) and 55dnl print the message (second argument) prefixed with the string "FATAL :" to 56dnl the error stream. 57define(`REGRESSION_FATAL', 58echo "FATAL: $2" > /dev/stderr 59exit $1) 60 61dnl Cleanup. Exit with the status code of the last failure. Should probably 62dnl be the number of failed tests, but hey presto, this is what it does. This 63dnl could also clean up potential droppings, if some forms of regression tests 64dnl end up using mktemp(1) or such. 65define(`REGRESSION_END', 66exit $STATUS) 67