diff options
author | Martin Schwenke <martin@meltin.net> | 2012-03-20 17:19:01 +1100 |
---|---|---|
committer | Martin Schwenke <martin@meltin.net> | 2012-03-22 15:30:27 +1100 |
commit | c0931a0cde5d73045a666c35929553fda93a15c4 (patch) | |
tree | b5ddaa8606dee9db217d3fef41490bf3d8c44b0f | |
parent | 2f312355c7ea5921972166ae992f3905e60af16e (diff) | |
download | samba-c0931a0cde5d73045a666c35929553fda93a15c4.tar.gz samba-c0931a0cde5d73045a666c35929553fda93a15c4.tar.xz samba-c0931a0cde5d73045a666c35929553fda93a15c4.zip |
Tests - eventscripts - new function simple_test_command()
Allows running arbitrary command and comparing output against
expected.
Signed-off-by: Martin Schwenke <martin@meltin.net>
(This used to be ctdb commit da2e9650a97f99e7d694659926d9958927edd8ad)
-rw-r--r-- | ctdb/tests/eventscripts/common.sh | 49 |
1 files changed, 34 insertions, 15 deletions
diff --git a/ctdb/tests/eventscripts/common.sh b/ctdb/tests/eventscripts/common.sh index aa129c6ac7..44c975e034 100644 --- a/ctdb/tests/eventscripts/common.sh +++ b/ctdb/tests/eventscripts/common.sh @@ -800,22 +800,8 @@ EOF fi } -# Run an eventscript once. The test passes if the return code and -# output match those required. - -# Any args are passed to the eventscript. - -# Eventscript tracing can be done by setting: -# EVENTSCRIPTS_TESTS_TRACE="sh -x" - -# or similar. This will almost certainly make a test fail but is -# useful for debugging. -simple_test () +result_check () { - [ -n "$event" ] || die 'simple_test: $event not set' - - echo "Running \"$script $event${1:+ }$*\"" - _out=$($EVENTSCRIPTS_TESTS_TRACE "${CTDB_BASE}/events.d/$script" "$event" "$@" 2>&1) _rc=$? if [ -n "$OUT_FILTER" ] ; then @@ -834,6 +820,26 @@ simple_test () result_footer "$_passed" } +# Run an eventscript once. The test passes if the return code and +# output match those required. + +# Any args are passed to the eventscript. + +# Eventscript tracing can be done by setting: +# EVENTSCRIPTS_TESTS_TRACE="sh -x" + +# or similar. This will almost certainly make a test fail but is +# useful for debugging. +simple_test () +{ + [ -n "$event" ] || die 'simple_test: $event not set' + + echo "Running eventscript \"$script $event${1:+ }$*\"" + _out=$($EVENTSCRIPTS_TESTS_TRACE "${CTDB_BASE}/events.d/$script" "$event" "$@" 2>&1) + + result_check +} + simple_test_event () { # If something has previously failed then don't continue. @@ -845,6 +851,19 @@ simple_test_event () simple_test "$@" } +simple_test_command () +{ + # If something has previously failed then don't continue. + : ${_passed:=true} + $_passed || return 1 + + echo "##################################################" + echo "Running command \"$*\"" + _out=$("$@" 2>&1) + + result_check +} + # Run an eventscript iteratively. # - 1st argument is the number of iterations. # - 2nd argument is something to eval to do setup for every iteration. |