mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-01-24 08:11:01 +00:00
Move is-it-resend logic into a function
Improve the code structure in case we want to add other similar conditions later. Document better what we're doing, and document why we're doing it. Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
parent
2d3c9f898b
commit
aa1d6ad9d2
|
@ -485,6 +485,32 @@ record_outcome() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# True if the presence of the given pattern in a log definitely indicates
|
||||||
|
# that the test has failed. False if the presence is inconclusive.
|
||||||
|
#
|
||||||
|
# Inputs:
|
||||||
|
# * $1: pattern found in the logs
|
||||||
|
# * $TIMES_LEFT: >0 if retrying is an option
|
||||||
|
#
|
||||||
|
# Outputs:
|
||||||
|
# * $outcome: set to a retry reason if the pattern is inconclusive,
|
||||||
|
# unchanged otherwise.
|
||||||
|
# * Return value: 1 if the pattern is inconclusive,
|
||||||
|
# 0 if the failure is definitive.
|
||||||
|
log_pattern_presence_is_conclusive() {
|
||||||
|
# If we've run out of attempts, then don't retry no matter what.
|
||||||
|
if [ $TIMES_LEFT -eq 0 ]; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
case $1 in
|
||||||
|
"resend")
|
||||||
|
# An undesired resend may have been caused by the OS dropping or
|
||||||
|
# delaying a packet at an inopportune time.
|
||||||
|
outcome="RETRY(resend)"
|
||||||
|
return 1;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
# fail <message>
|
# fail <message>
|
||||||
fail() {
|
fail() {
|
||||||
record_outcome "FAIL" "$1"
|
record_outcome "FAIL" "$1"
|
||||||
|
@ -863,9 +889,7 @@ check_test_failure() {
|
||||||
|
|
||||||
"-S")
|
"-S")
|
||||||
if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
|
if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
|
||||||
if [ "$2" = "resend" ] && [ $TIMES_LEFT -gt 0 ]; then
|
if log_pattern_presence_is_conclusive "$2"; then
|
||||||
outcome="RETRY(resend)"
|
|
||||||
else
|
|
||||||
fail "pattern '$2' MUST NOT be present in the Server output"
|
fail "pattern '$2' MUST NOT be present in the Server output"
|
||||||
fi
|
fi
|
||||||
return
|
return
|
||||||
|
@ -874,9 +898,7 @@ check_test_failure() {
|
||||||
|
|
||||||
"-C")
|
"-C")
|
||||||
if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
|
if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
|
||||||
if [ "$2" = "resend" ] && [ $TIMES_LEFT -gt 0 ]; then
|
if log_pattern_presence_is_conclusive "$2"; then
|
||||||
outcome="RETRY(resend)"
|
|
||||||
else
|
|
||||||
fail "pattern '$2' MUST NOT be present in the Client output"
|
fail "pattern '$2' MUST NOT be present in the Client output"
|
||||||
fi
|
fi
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in a new issue