Move retry logic into check_test_failure

This will allow having other retry conditions, in particular based on
run_test options.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
Gilles Peskine 2021-10-19 17:23:25 +02:00
parent 196d73bc1b
commit 0e3534c67b

View file

@ -864,11 +864,19 @@ analyze_test_commands() {
# * $CLI_EXPECT: expected client return code
# * $SRV_RET: server return code
# * $CLI_OUT, $SRV_OUT, $PXY_OUT: files containing client/server/proxy logs
# * $TIMES_LEFT: if nonzero, a RETRY outcome is allowed
#
# Outputs:
# * $pass: set to 1 if no failures are detected, 0 otherwise
# * $outcome: one of PASS/RETRY/FAIL
check_test_failure() {
pass=0
outcome=FAIL
if [ $TIMES_LEFT -gt 0 ] &&
grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null
then
outcome=RETRY
return
fi
# check if the client and server went at least to the handshake stage
# (useful to avoid tests with only negative assertions and non-zero
@ -1002,7 +1010,7 @@ check_test_failure() {
fi
# if we're here, everything is ok
pass=1
outcome=PASS
}
# Run the current test case: start the server and if applicable the proxy, run
@ -1118,19 +1126,15 @@ run_test() {
do_run_test_once
# retry only on timeouts
if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
printf "RETRY "
else
TIMES_LEFT=0
fi
check_test_failure "$@"
case $outcome in
PASS) break;;
RETRY) printf "RETRY ";;
FAIL) return;;
esac
done
check_test_failure "$@"
if [ "$pass" -eq 0 ]; then
return
fi
# If we get this far, the test case passed.
record_outcome "PASS"
if [ "$PRESERVE_LOGS" -gt 0 ]; then
mv $SRV_OUT o-srv-${TESTS}.log