From 4c92dc36babbb4d1fcddce38b08ccf7a023d91e3 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Wed, 29 Jan 2014 19:56:38 +0100 Subject: [PATCH] tests: Simplify running cmp_out more than once When cmp_out detects a test failure, it returns non-zero status, which terminates the test script unless caught. Accumulate failures in a global variable checked at exit instead, so running it multiple times in a test script just works. Signed-off-by: Markus Armbruster --- tests/test-common.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/test-common.sh b/tests/test-common.sh index 5fc117c1..bb37b773 100644 --- a/tests/test-common.sh +++ b/tests/test-common.sh @@ -8,6 +8,9 @@ fi test=${0##*/} test=${test%-test} +failed= +trap 'if [ "$pid" ]; then kill -9 "$pid" 2>/dev/null || true; fi; [ "$failed" ] && exit 1' EXIT + # Abbreviations testdir="$srcdir/tests/$test" econfig=sandbox/etc/empire/econfig @@ -72,7 +75,6 @@ start_server() check_empthread pid= - trap 'if [ "$pid" ]; then kill -9 "$pid" 2>/dev/null || true; fi' EXIT src/server/emp_server -e $econfig -R 1 -s -E crash-dump timeout=$((`now`+5)) until pid=`cat $pidfile 2>/dev/null` && [ -n "$pid" ] @@ -177,7 +179,7 @@ cmp_logs_xdump() cmp_out() { - local exp act nrm ret=0 + local exp act nrm for i do exp="$testdir/${i##*/}" @@ -201,9 +203,8 @@ cmp_out() echo "$i CHANGED" cp "$nrm" "$exp" else - ret=$? + failed=y echo "$i FAIL" fi done - return $ret }