1105628a4b041c441ebc2c1993e0e02b0ca5b1cc
[ctdb.git] / tests / tool / scripts / local.sh
1 # Hey Emacs, this is a -*- shell-script -*- !!!  :-)
2
3 test_bin="$(dirname ${TEST_SUBDIR})/bin"
4
5 define_test ()
6 {
7     _f=$(basename "$0" ".sh")
8
9     case "$_f" in
10         func.*)
11             _func="${_f#func.}"
12             _func="${_func%.*}" # Strip test number
13             test_prog="${test_bin}/ctdb_tool_libctdb ${_func}"
14             ;;
15         stubby.*)
16             _cmd="${_f#stubby.}"
17             _cmd="${_cmd%.*}" # Strip test number
18             test_prog="${test_bin}/ctdb_tool_stubby ${_cmd}"
19             ;;
20         *)
21             die "Unknown pattern for testcase \"$_f\""
22     esac
23
24     printf "%-28s - %s\n" "$_f" "$1"
25 }
26
27 simple_test ()
28 {
29     # Most of the tests when the tool fails will have a date/time/pid
30     # prefix.  Strip that because it isn't possible to match it.
31     if [ $required_rc -ne 0 ]  ; then
32         OUT_FILTER='s@^[0-9/]+\ [0-9:\.]+\ \[[\ 0-9]+\]:@DATE\ TIME\ \[PID\]:@'
33     fi
34
35     _out=$($test_prog "$@" 2>&1)
36
37     result_check
38 }