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