diff options
| author | Martin Schwenke <martin@meltin.net> | 2012-04-16 14:25:50 +1000 |
|---|---|---|
| committer | Martin Schwenke <martin@meltin.net> | 2012-04-16 15:06:48 +1000 |
| commit | 006b18dec4d9781fc7c64b249e47aa3cf2b99d0c (patch) | |
| tree | b50b9fb94531235f8d69a8b420125ed652fc723f /ctdb/tests/tool/scripts | |
| parent | 612f0d91d265255526ccc5bcbf8bb49285136b11 (diff) | |
| download | samba-006b18dec4d9781fc7c64b249e47aa3cf2b99d0c.tar.gz samba-006b18dec4d9781fc7c64b249e47aa3cf2b99d0c.tar.xz samba-006b18dec4d9781fc7c64b249e47aa3cf2b99d0c.zip | |
tests/tool - Restructure according to new convention
Signed-off-by: Martin Schwenke <martin@meltin.net>
(This used to be ctdb commit 89571585d87b391ff79647cd1f0f6ac193079e72)
Diffstat (limited to 'ctdb/tests/tool/scripts')
| -rw-r--r-- | ctdb/tests/tool/scripts/local.sh | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/ctdb/tests/tool/scripts/local.sh b/ctdb/tests/tool/scripts/local.sh new file mode 100644 index 0000000000..fe8416ee98 --- /dev/null +++ b/ctdb/tests/tool/scripts/local.sh @@ -0,0 +1,70 @@ +# Hey Emacs, this is a -*- shell-script -*- !!! :-) + +# Print a message and exit. +die () { echo "$@" >&2 ; exit 1 ; } + +test_bin="$(dirname ${TEST_SUBDIR})/bin" + +define_test () +{ + _f=$(basename "$0" ".sh") + + case "$_f" in + func.*) + _func="${_f#func.}" + _func="${_func%.*}" # Strip test number + test_prog="${test_bin}/ctdb_tool_libctdb ${_func}" + ;; + stubby.*) + _cmd="${_f#stubby.}" + _cmd="${_cmd%.*}" # Strip test number + test_prog="${test_bin}/ctdb_tool_stubby ${_cmd}" + ;; + *) + die "Unknown pattern for testcase \"$_f\"" + esac + + printf "%-28s - %s\n" "$_f" "$1" +} + +simple_test () +{ + _out=$($test_prog "$@" 2>&1) + _rc=$? + + # Most of the tests when the tool fails will have a date/time/pid + # prefix. Strip that because it isn't possible to match it. + if [ $required_rc -ne 0 ] ; then + OUT_FILTER='s@^[0-9/]+ [0-9:\.]+ \[[ 0-9]+\]:@DATE TIME \[PID\]:@' + fi + + if [ -n "$OUT_FILTER" ] ; then + _fout=$(echo "$_out" | sed -r "$OUT_FILTER") + else + _fout="$_out" + fi + + if [ "$_fout" = "$required_output" -a $_rc = $required_rc ] ; then + if [ "$TEST_VERBOSE" = "yes" ] ; then + cat <<EOF +################################################## +Output (Exit status: ${_rc}): +################################################## +$_fout +EOF + fi + echo "PASSED" + else + cat -A <<EOF +################################################## +Required output (Exit status: ${required_rc}): +################################################## +$required_output +################################################## +Actual output (Exit status: ${_rc}): +################################################## +$_fout +EOF + return 1 + fi +} |
