_out=$($_shell "${CTDB_BASE}/events.d/$script" "$event" $args 2>&1)
_rc=$?
- if [ -n "$OUT_FILTER" ] ; then
- _fout=$(echo "$_out" | eval sed -r $OUT_FILTER)
- else
- _fout="$_out"
- fi
+ _fout=$(echo "$_out" | result_filter)
if [ "$_fout" = "$required_output" -a $_rc = $required_rc ] ; then
_passed=true
fi
}
+# Result filtering is (usually) used to replace the date/time/PID
+# prefix on some CTDB tool/client log messages with the literal string
+# "DATE TIME [PID]". This allows tests to loosely match this output,
+# since it can't otherwise be matched.
+result_filter_default ()
+{
+ _date_time_pid='[0-9/][0-9/]*\ [0-9:\.][0-9:\.]*\ \[[\ 0-9][\ 0-9]*\]'
+ sed -e "s@^${_date_time_pid}:@DATE\ TIME\ \[PID\]:@"
+}
+
+# Override this function to customise output filtering.
+result_filter ()
+{
+ result_filter_default
+}
+
result_check ()
{
_rc=$?
_extra_header="$1"
- if [ -n "$OUT_FILTER" ] ; then
- _fout=$(echo "$_out" | eval sed -r $OUT_FILTER)
- else
- _fout="$_out"
- fi
+ _fout=$(echo "$_out" | result_filter)
if [ "$_fout" = "$required_output" -a $_rc = $required_rc ] ; then
_passed=true
simple_test ()
{
- # Do some filtering of the output to replace date/time.
- OUT_FILTER='s@^[^\]]*\]:@DATE\ TIME\ \[PID\]:@'
-
_out=$($VALGRIND $test_prog "$@" 2>&1)
result_check "Algorithm: $CTDB_IP_ALGORITHM"
simple_test ()
{
- # 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
-
_out=$($VALGRIND $test_prog "$@" 2>&1)
result_check