From 514b5e3ed5c5b5a97ee9876cd900f22f57702fa5 Mon Sep 17 00:00:00 2001 From: Loic Dachary Date: Sun, 16 Mar 2014 16:16:26 +0100 Subject: [PATCH] mon: add helper to selection functions implementing tests The call_TEST_functions will lookup SHARE_MON_TEST_* shell functions and run them after creating a mon. Each is expected to clean up and avoid interferences. It will also lookup TEST_* shell functions and include them in setup/teardown to provide them with a clean environment. Signed-off-by: Loic Dachary --- src/test/mon/mon-test-helpers.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/test/mon/mon-test-helpers.sh b/src/test/mon/mon-test-helpers.sh index f3925af89e14..3ed178438bd0 100644 --- a/src/test/mon/mon-test-helpers.sh +++ b/src/test/mon/mon-test-helpers.sh @@ -66,6 +66,31 @@ function kill_daemons() { done } +function call_TEST_functions() { + local dir=$1 + shift + local id=$2 + shift + + setup $dir || return 1 + run_mon $dir $id "$@" + SHARE_MON_FUNCTIONS=${SHARE_MON_FUNCTIONS:-$(set | sed -n -e 's/^\(SHARE_MON_TEST_[0-9a-z_]*\) .*/\1/p')} + for TEST_function in $SHARE_MON_FUNCTIONS ; do + if ! $TEST_function $dir $id ; then + cat $dir/$id/log + return 1 + fi + done + teardown $dir || return 1 + + FUNCTIONS=${FUNCTIONS:-$(set | sed -n -e 's/^\(TEST_[0-9a-z_]*\) .*/\1/p')} + for TEST_function in $FUNCTIONS ; do + setup $dir || return 1 + $TEST_function $dir || return 1 + teardown $dir || return 1 + done +} + function main() { local dir=$1 -- 2.47.3