summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmitay Isaacs <amitay@gmail.com>2015-07-06 15:14:53 +1000
committerMartin Schwenke <martins@samba.org>2015-07-09 06:23:21 +0200
commitaa9ca809bebb17136e05817bc4c89c208424f52f (patch)
treebe6cd606f3a90ebbbc385d290d1eaa7bc3205e5c
parent2290e7a01e606f3fe695301ffee846de9a28dd7f (diff)
downloadsamba-aa9ca809bebb17136e05817bc4c89c208424f52f.tar.gz
ctdb-tests: Add test cleanup hooks
To do any cleanup before exiting the test, register hooks with test_cleanup(). Multiple hooks can be registered. All the hooks will be called before exiting from the test. Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
-rw-r--r--ctdb/tests/onnode/scripts/local.sh2
-rw-r--r--ctdb/tests/scripts/unit.sh9
2 files changed, 10 insertions, 1 deletions
diff --git a/ctdb/tests/onnode/scripts/local.sh b/ctdb/tests/onnode/scripts/local.sh
index daefaa47201..b9f4f0ada4e 100644
--- a/ctdb/tests/onnode/scripts/local.sh
+++ b/ctdb/tests/onnode/scripts/local.sh
@@ -46,7 +46,7 @@ ctdb_set_output ()
_rc="$ONNODE_TESTS_VAR_DIR/ctdb.rc"
echo "${1:-0}" >"$_rc"
- trap "rm -f $_out $_rc" 0
+ test_cleanup "rm -f $_out $_rc"
}
extra_footer ()
diff --git a/ctdb/tests/scripts/unit.sh b/ctdb/tests/scripts/unit.sh
index e9a04e1433f..f52ef2c7efe 100644
--- a/ctdb/tests/scripts/unit.sh
+++ b/ctdb/tests/scripts/unit.sh
@@ -209,6 +209,15 @@ script_test ()
result_check || exit $?
}
+test_cleanup_hooks=""
+
+test_cleanup ()
+{
+ test_cleanup_hooks="${test_cleanup_hooks}${test_cleanup_hooks:+ ; }$*"
+}
+
+trap 'eval $test_cleanup_hooks' 0
+
local="${TEST_SUBDIR}/scripts/local.sh"
if [ -r "$local" ] ; then
. "$local"