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 <armbru@pond.sub.org>
This commit is contained in:
parent
cc692142d9
commit
4c92dc36ba
1 changed files with 5 additions and 4 deletions
|
@ -8,6 +8,9 @@ fi
|
||||||
test=${0##*/}
|
test=${0##*/}
|
||||||
test=${test%-test}
|
test=${test%-test}
|
||||||
|
|
||||||
|
failed=
|
||||||
|
trap 'if [ "$pid" ]; then kill -9 "$pid" 2>/dev/null || true; fi; [ "$failed" ] && exit 1' EXIT
|
||||||
|
|
||||||
# Abbreviations
|
# Abbreviations
|
||||||
testdir="$srcdir/tests/$test"
|
testdir="$srcdir/tests/$test"
|
||||||
econfig=sandbox/etc/empire/econfig
|
econfig=sandbox/etc/empire/econfig
|
||||||
|
@ -72,7 +75,6 @@ start_server()
|
||||||
check_empthread
|
check_empthread
|
||||||
|
|
||||||
pid=
|
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
|
src/server/emp_server -e $econfig -R 1 -s -E crash-dump
|
||||||
timeout=$((`now`+5))
|
timeout=$((`now`+5))
|
||||||
until pid=`cat $pidfile 2>/dev/null` && [ -n "$pid" ]
|
until pid=`cat $pidfile 2>/dev/null` && [ -n "$pid" ]
|
||||||
|
@ -177,7 +179,7 @@ cmp_logs_xdump()
|
||||||
|
|
||||||
cmp_out()
|
cmp_out()
|
||||||
{
|
{
|
||||||
local exp act nrm ret=0
|
local exp act nrm
|
||||||
for i
|
for i
|
||||||
do
|
do
|
||||||
exp="$testdir/${i##*/}"
|
exp="$testdir/${i##*/}"
|
||||||
|
@ -201,9 +203,8 @@ cmp_out()
|
||||||
echo "$i CHANGED"
|
echo "$i CHANGED"
|
||||||
cp "$nrm" "$exp"
|
cp "$nrm" "$exp"
|
||||||
else
|
else
|
||||||
ret=$?
|
failed=y
|
||||||
echo "$i FAIL"
|
echo "$i FAIL"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
return $ret
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue