diff options
author | Martin Schwenke <martin@meltin.net> | 2013-11-15 12:22:05 +1100 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2013-11-27 18:46:17 +0100 |
commit | 8ca117a68e525db57623ce529690b24c45afa1e3 (patch) | |
tree | 22eefc08a9e6a6c5c62ec9dd52aedc2dfa66bc8a /ctdb | |
parent | 97554854439e83ebb9e99ce4ebb6e49de8e7a5a9 (diff) | |
download | samba-8ca117a68e525db57623ce529690b24c45afa1e3.tar.gz samba-8ca117a68e525db57623ce529690b24c45afa1e3.tar.xz samba-8ca117a68e525db57623ce529690b24c45afa1e3.zip |
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>
Diffstat (limited to 'ctdb')
-rw-r--r-- | ctdb/tests/eventscripts/scripts/local.sh | 6 | ||||
-rw-r--r-- | ctdb/tests/scripts/unit.sh | 22 | ||||
-rw-r--r-- | ctdb/tests/takeover/scripts/local.sh | 3 | ||||
-rw-r--r-- | ctdb/tests/tool/scripts/local.sh | 6 |
4 files changed, 18 insertions, 19 deletions
diff --git a/ctdb/tests/eventscripts/scripts/local.sh b/ctdb/tests/eventscripts/scripts/local.sh index 4c3f0b1394f..2b4bc920462 100644 --- a/ctdb/tests/eventscripts/scripts/local.sh +++ b/ctdb/tests/eventscripts/scripts/local.sh @@ -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 diff --git a/ctdb/tests/scripts/unit.sh b/ctdb/tests/scripts/unit.sh index c7c2b7a2736..f423db19a2e 100644 --- a/ctdb/tests/scripts/unit.sh +++ b/ctdb/tests/scripts/unit.sh @@ -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 diff --git a/ctdb/tests/takeover/scripts/local.sh b/ctdb/tests/takeover/scripts/local.sh index 3b69d14fc92..b10d7461ee4 100644 --- a/ctdb/tests/takeover/scripts/local.sh +++ b/ctdb/tests/takeover/scripts/local.sh @@ -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" diff --git a/ctdb/tests/tool/scripts/local.sh b/ctdb/tests/tool/scripts/local.sh index 385e2ad64b4..6cad929e85e 100644 --- a/ctdb/tests/tool/scripts/local.sh +++ b/ctdb/tests/tool/scripts/local.sh @@ -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 |