diff options
author | jmmv <jmmv@FreeBSD.org> | 2014-04-27 01:15:10 +0000 |
---|---|---|
committer | jmmv <jmmv@FreeBSD.org> | 2014-04-27 01:15:10 +0000 |
commit | 1e4589b921fdaa1b1d2fc6b6ed016f1e0a01cb8f (patch) | |
tree | 94c86cf13dedabad5bdc68f6f227b843a5161343 /usr.bin/tests | |
parent | 5b12da65bf9d40526ac9ca480d639bad3cd39cf6 (diff) | |
download | FreeBSD-src-1e4589b921fdaa1b1d2fc6b6ed016f1e0a01cb8f.zip FreeBSD-src-1e4589b921fdaa1b1d2fc6b6ed016f1e0a01cb8f.tar.gz |
MFC various moves of tools/regressions/ tests to the new infrastructure.
- r263220 Migrate tools/regression/sbin/ to the new tests layout.
- r263222 Add Makefile missed in r263220.
- r263226 Migrate tools/regression/{usr.bin/lastcomm,usr.sbin}/ to the new tests layout.
- r263227 Migrate most of tools/regression/usr.bin/ to the new tests layout.
- r263345 Expand tabs that sneaked in into spaces.
- r263346 Migrate tools/regression/usr.bin/make/ to the new tests layout.
- r263348 Add Makefiles missed in r263346.
- r263351 Migrate tools/regression/usr.bin/pkill/ to the new tests layout.
- r263388 Mark multi_test as requiring /usr/share/dict/words.
- r263814 Fix path to the run.pl script to let these tests run.
- r264742 Prevent building tests when bootstrapping make.
This is 'make tinderbox' clean.
Diffstat (limited to 'usr.bin/tests')
-rw-r--r-- | usr.bin/tests/Makefile | 3 | ||||
-rw-r--r-- | usr.bin/tests/regress.m4 | 59 |
2 files changed, 62 insertions, 0 deletions
diff --git a/usr.bin/tests/Makefile b/usr.bin/tests/Makefile index f8ead88..af7a8bf 100644 --- a/usr.bin/tests/Makefile +++ b/usr.bin/tests/Makefile @@ -7,4 +7,7 @@ TESTSDIR= ${TESTSBASE}/usr.bin .PATH: ${.CURDIR:H:H}/tests KYUAFILE= yes +FILESDIR= ${TESTSDIR} +FILES= regress.m4 + .include <bsd.test.mk> diff --git a/usr.bin/tests/regress.m4 b/usr.bin/tests/regress.m4 new file mode 100644 index 0000000..53dfb14 --- /dev/null +++ b/usr.bin/tests/regress.m4 @@ -0,0 +1,59 @@ +# $FreeBSD$ + +dnl A library of routines for doing regression tests for userland utilities. + +dnl Start up. We initialise the exit status to 0 (no failure) and change +dnl into the directory specified by our first argument, which is the +dnl directory to run the tests inside. +define(`REGRESSION_START', +TESTDIR=$1 +if [ -z "$TESTDIR" ]; then + TESTDIR=. +fi +cd $TESTDIR + +STATUS=0) + +dnl Check $? to see if we passed or failed. The first parameter is the test +dnl which passed or failed. It may be nil. +define(`REGRESSION_PASSFAIL', +if [ $? -eq 0 ]; then + echo "ok - $1 # Test detected no regression. (in $TESTDIR)" +else + STATUS=$? + echo "not ok - $1 # Test failed: regression detected. See above. (in $TESTDIR)" +fi) + +dnl An actual test. The first parameter is the test name. The second is the +dnl command/commands to execute for the actual test. Their exit status is +dnl checked. It is assumed that the test will output to stdout, and that the +dnl output to be used to check for regression will be in regress.TESTNAME.out. +define(`REGRESSION_TEST', +$2 | diff -u ${SRCDIR:-.}/regress.$1.out - +REGRESSION_PASSFAIL($1)) + +dnl A freeform regression test. Only exit status is checked. +define(`REGRESSION_TEST_FREEFORM', +$2 +REGRESSION_PASSFAIL($1)) + +dnl A regression test like REGRESSION_TEST, except only regress.out is used +dnl for checking output differences. The first argument is the command, the +dnl second argument (which may be empty) is the test name. +define(`REGRESSION_TEST_ONE', +$1 | diff -u ${SRCDIR:-.}/regress.out - +REGRESSION_PASSFAIL($2)) + +dnl A fatal error. This will exit with the given status (first argument) and +dnl print the message (second argument) prefixed with the string "FATAL :" to +dnl the error stream. +define(`REGRESSION_FATAL', +echo "Bail out! $2 (in $TESTDIR)" > /dev/stderr +exit $1) + +dnl Cleanup. Exit with the status code of the last failure. Should probably +dnl be the number of failed tests, but hey presto, this is what it does. This +dnl could also clean up potential droppings, if some forms of regression tests +dnl end up using mktemp(1) or such. +define(`REGRESSION_END', +exit $STATUS) |