1 # Hey Emacs, this is a -*- shell-script -*- !!! :-)
3 .
"${TEST_SCRIPTS_DIR}/common.sh"
5 # Common variables and functions for CTDB unit tests.
9 # Set the required result for a test.
10 # - Argument 1 is exit code.
11 # - Argument 2, if present is the required test output but "--"
12 # indicates empty output.
13 # If argument 2 is not present or null then read required test output
19 if [ "$2" = "--" ] ; then
26 required_output
=$
(cat)
35 required_result
0 "$@"
50 if "$TEST_VERBOSE" ||
! $_passed ; then
51 if [ -n "$_extra_header" ] ; then
54 ##################################################
60 --------------------------------------------------
61 Output (Exit status: ${_rc}):
62 --------------------------------------------------
64 echo "$_out" |
cat $TEST_CAT_RESULTS_OPTS
69 --------------------------------------------------
70 Required output (Exit status: ${required_rc}):
71 --------------------------------------------------
73 echo "$required_output" |
cat $TEST_CAT_RESULTS_OPTS
75 if $TEST_DIFF_RESULTS ; then
77 echo "$required_output" >"$_outr"
80 echo "$_fout" >"$_outf"
83 --------------------------------------------------
85 --------------------------------------------------
87 diff -u "$_outr" "$_outf" |
cat -A
98 if "$TEST_VERBOSE" ||
! $_passed ; then
99 if [ -n "$_extra_footer" ] ; then
101 --------------------------------------------------
103 --------------------------------------------------
118 # Result filtering is (usually) used to replace the date/time/PID
119 # prefix on some CTDB tool/client log messages with the literal string
120 # "DATE TIME [PID]". This allows tests to loosely match this output,
121 # since it can't otherwise be matched.
122 result_filter_default
()
124 _date_time_pid
='[0-9/][0-9/]*\ [0-9:\.][0-9:\.]*\ \[[\ 0-9][\ 0-9]*\]'
125 sed -e "s@^${_date_time_pid}:@DATE\ TIME\ \[PID\]:@"
128 # Override this function to customise output filtering.
131 result_filter_default
140 _fout
=$
(echo "$_out" | result_filter
)
142 if [ "$_fout" = "$required_output" -a $_rc = $required_rc ] ; then
148 result_print
"$_passed" "$_out" "$_rc" "$_extra_header"
149 result_footer
"$_passed"
152 local="${TEST_SUBDIR}/scripts/local.sh"
153 if [ -r "$local" ] ; then