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
b969570650
commit
6ee3b7ed1f
1 changed files with 10 additions and 22 deletions
|
@ -156,6 +156,11 @@ echo "========================================================================="
|
|||
echo "Test Report Summary"
|
||||
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
|
||||
|
@ -267,13 +272,7 @@ echo
|
|||
echo "Branches Tested : $BRANCHES_TESTED of $BRANCHES_TOTAL $BRANCHES_PERCENT%"
|
||||
echo
|
||||
|
||||
# If there was a failure, remind the reader here. This also ensures that
|
||||
# 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
|
||||
|
||||
touch "basic-build-test-$$.ok"
|
||||
} | tee coverage-summary.txt
|
||||
|
||||
make clean
|
||||
|
@ -282,18 +281,7 @@ if [ -f "$CONFIG_BAK" ]; then
|
|||
mv "$CONFIG_BAK" "$CONFIG_H"
|
||||
fi
|
||||
|
||||
# If the coverage summary doesn't end with the expected last two lines
|
||||
# ("Branches Tested" and a blank line), either there was an error while
|
||||
# creating the coverage summary or the coverage summary reported failures.
|
||||
# The script runs under `set -e`, so most failures cause it to abort,
|
||||
# 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
|
||||
# The file must exist, otherwise it means something went wrong while generating
|
||||
# the coverage report. If something did go wrong, rm will complain so this
|
||||
# script will exit with a failure status.
|
||||
rm "basic-build-test-$$.ok"
|
||||
|
|
Loading…
Reference in a new issue