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