1 # source this file; set up for tests
3 # Copyright (C) 2009-2010 Free Software Foundation, Inc.
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 # Skip this test if the shell lacks support for functions.
20 eval 'function_test() { return 11; }; function_test'
21 if test $?
!= 11; then
22 echo "$0: /bin/sh lacks support for functions; skipping this test." 1>&2
26 # We use a trap below for cleanup. This requires us to go through
27 # hoops to get the right exit status transported through the signal.
28 # So use `Exit STATUS' instead of `exit STATUS' inside of the tests.
29 # Turn off errexit here so that we don't trip the bug with OSF1/Tru64
30 # sh inside this function.
38 test -f "$srcdir/init.cfg" \
39 && .
"$srcdir/init.cfg"
43 this_test_
() { echo "./$0" |
sed 's,.*/,,'; }
44 this_test
=$
(this_test_
)
46 # This is a stub function that is run upon trap (upon regular exit and
47 # interrupt). Override it with a per-test function, e.g., to unmount
48 # a partition, or to undo any other global state changes.
51 t_
=$
("$abs_top_builddir/src/mktemp" -d --tmp="$test_dir_" cu-
$this_test.XXXXXXXXXX
)\
52 || error_
"failed to create temporary directory in $test_dir_"
58 cd "$test_dir_" && chmod -R u
+rwx
"$t_" && rm -rf "$t_" && exit $__st
61 # Run each test from within a temporary sub-directory named after the
62 # test itself, and arrange to remove it upon exception or normal exit.
70 cd "$t_" || error_
"failed to cd to $t_"
72 if ( diff --version < /dev
/null
2>&1 |
grep GNU
) 2>&1 > /dev
/null
; then
73 compare
() { diff -u "$@"; }
74 elif ( cmp --version < /dev
/null
2>&1 |
grep GNU
) 2>&1 > /dev
/null
; then
75 compare
() { cmp -s "$@"; }
77 compare
() { cmp "$@"; }
80 # Initialize; all bourne shell scripts end with "Exit $fail".