From c840cd4334c086f5ce4d9144d9fac75643824a38 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Thu, 16 Aug 2007 16:28:11 +0200 Subject: Parallel "make check" support. * build-aux/check.mk: New file, from The Vaucanson Group. * .x-sc_GPL_version: New file, to allow "version 2 or later" in build-aux/check.mk. * Makefile.am (EXTRA_DIST): Add .x-sc_GPL_version. * tests/check.mk: New file. * tests/Makefile.am (EXTRA_DIST): Add check.mk, mkdtemp and test-lib.sh. Begin factoring "sample-test" out of test scripts. * tests/test-lib.sh: New file, to be sourced by all tests that were previously derived from the "sample-test" template. * tests/mkdtemp: New file. * tests/touch/dir-1: Use test-lib.sh. * tests/touch/empty-file: Likewise. * tests/touch/fail-diag: Likewise. * tests/touch/fifo: Likewise. * tests/touch/no-create-missing: Likewise. * tests/touch/no-rights: Likewise. Also, don't sleep. * tests/touch/not-owner: Likewise. * tests/touch/obsolescent: Likewise. * tests/touch/read-only: Likewise. * tests/touch/relative: Likewise. * tests/touch/Makefile.am: Include $(top_srcdir)/tests/check.mk, to get the parallel-"make check" bits. Move a slow test into tests/misc. * tests/check.mk: Wrapper. * tests/ls/time-1: Move this file to tests/misc/ls-time. * tests/misc/ls-time: New file. From tests/ls/time-1. * tests/ls/Makefile.am (TESTS): Remove time-1. * tests/misc/Makefile.am (TESTS): Add ls-time. --- tests/test-lib.sh | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 tests/test-lib.sh (limited to 'tests/test-lib.sh') diff --git a/tests/test-lib.sh b/tests/test-lib.sh new file mode 100644 index 000000000..79d0ef2c7 --- /dev/null +++ b/tests/test-lib.sh @@ -0,0 +1,40 @@ +# source this file; set up for tests + +# Skip this test if the shell lacks support for functions. +unset function_test +eval 'function_test() { return 11; }; function_test' +if test $? != 11; then + echo "$0: /bin/sh lacks support for functions; skipping this test." 1>&2 + (exit 77); exit 77 +fi + +test_dir_=$(pwd) + +this_test_() { echo "./$0" | sed 's,.*/,,'; } +this_test=$(this_test_) + +. $srcdir/../envvar-check + +# This is a stub function that is run upon trap (upon regular exit and +# interrupt). Override it with a per-test function, e.g., to unmount +# a partition, or to undo any other global state changes. +cleanup_() { :; } + +t_=$($abs_top_srcdir/tests/mkdtemp $test_dir_ cu-$this_test.XXXXXXXXXX) \ + || error "failed to create temporary directory in $test_dir_" + +# Run each test from within a temporary sub-directory named after the +# test itself, and arrange to remove it upon exception or normal exit. +trap 'st=$?; cleanup_; d='"$t_"'; + cd '"$test_dir_"' && chmod -R u+rwx "$d" && rm -rf "$d" && exit $st' 0 +trap '(exit $?); exit $?' 1 2 13 15 + +cd $t_ || error "failed to cd to $t_" + +if ( diff --version < /dev/null 2>&1 | grep GNU ) 2>&1 > /dev/null; then + compare() { diff -u "$@"; } +elif ( cmp --version < /dev/null 2>&1 | grep GNU ) 2>&1 > /dev/null; then + compare() { cmp -s "$@"; } +else + compare() { cmp "$@"; } +fi -- cgit v1.2.3-54-g00ecf