1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00

ctdb:tests: Rework unit test result filtering

Using a variable is too fragile, so use a function instead.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Michael Adam <obnox@samba.org>
This commit is contained in:
Martin Schwenke 2013-11-15 12:22:05 +11:00 committed by Michael Adam
parent 9755485443
commit 8ca117a68e
4 changed files with 18 additions and 19 deletions

View File

@ -1012,11 +1012,7 @@ iterate_test ()
_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

View File

@ -113,17 +113,29 @@ EOF
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

View File

@ -17,9 +17,6 @@ define_test ()
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"

View File

@ -44,12 +44,6 @@ setup_natgw ()
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