mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-01-12 18:15:27 +00:00
More robust failure detection for the coverage report generation
The previous implementation was hard to understand and could in principle fail to notice if there was a test case failure and the writing of the line "Note: $TOTAL_FAIL failures." failed. KISS. Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
parent
a2df615e21
commit
5cf753ae02
|
@ -160,6 +160,11 @@ echo "========================================================================="
|
||||||
echo "Test Report Summary"
|
echo "Test Report Summary"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
|
# A failure of the left-hand side of a pipe is ignored (this is a limitation
|
||||||
|
# of sh). We'll use the presence of this file as a marker that the generation
|
||||||
|
# of the report succeeded.
|
||||||
|
rm -f "basic-build-test-$$.ok"
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
cd tests
|
cd tests
|
||||||
|
@ -271,13 +276,7 @@ echo
|
||||||
echo "Branches Tested : $BRANCHES_TESTED of $BRANCHES_TOTAL $BRANCHES_PERCENT%"
|
echo "Branches Tested : $BRANCHES_TESTED of $BRANCHES_TOTAL $BRANCHES_PERCENT%"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
# If there was a failure, remind the reader here. This also ensures that
|
touch "basic-build-test-$$.ok"
|
||||||
# the coverage summary ends with a distinctive mark so that this script
|
|
||||||
# knows to exit with a failure status.
|
|
||||||
if [ $TOTAL_FAIL -ne 0 ]; then
|
|
||||||
echo "Note: $TOTAL_FAIL failures."
|
|
||||||
fi
|
|
||||||
|
|
||||||
} | tee coverage-summary.txt
|
} | tee coverage-summary.txt
|
||||||
|
|
||||||
make clean
|
make clean
|
||||||
|
@ -286,18 +285,7 @@ if [ -f "$CONFIG_BAK" ]; then
|
||||||
mv "$CONFIG_BAK" "$CONFIG_H"
|
mv "$CONFIG_BAK" "$CONFIG_H"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If the coverage summary doesn't end with the expected last two lines
|
# The file must exist, otherwise it means something went wrong while generating
|
||||||
# ("Branches Tested" and a blank line), either there was an error while
|
# the coverage report. If something did go wrong, rm will complain so this
|
||||||
# creating the coverage summary or the coverage summary reported failures.
|
# script will exit with a failure status.
|
||||||
# The script runs under `set -e`, so most failures cause it to abort,
|
rm "basic-build-test-$$.ok"
|
||||||
# but failures on the left-hand side of a pipe are not detected (this is
|
|
||||||
# a limitation of sh), so we check that the left-hand side of the pipe
|
|
||||||
# succeeded by checking that it took the last action that it was expected
|
|
||||||
# to take.
|
|
||||||
newline='
|
|
||||||
'
|
|
||||||
case "$(tail -n2 coverage-summary.txt)" in
|
|
||||||
*"$newline"*) exit 1;; # last line was not blank
|
|
||||||
"Branches Tested"*) :;; # looks good
|
|
||||||
*) exit 1;; # next-to-last line had unexpected content
|
|
||||||
esac
|
|
||||||
|
|
Loading…
Reference in a new issue