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 <loic@dachary.org>
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