testbench: add script for improved "failed test" log output

The main intent is to show only failed tests (not SKIPed ones)
to make it easier to interpret test failures.

This also limits the max output size of tests. This is especially
important because of a bug in buildbot that leads to DoS when
very large test logs are sent back to the build master (which
then aborts).

see also https://github.com/buildbot/buildbot/issues/4504
This commit is contained in:
Rainer Gerhards 2020-01-24 10:11:37 +01:00
parent 1a4351718d
commit 5b05b98816
No known key found for this signature in database
GPG Key ID: 0CB6B2A8BE80B499
2 changed files with 49 additions and 9 deletions

46
devtools/gather-check-logs.sh Executable file
View File

@ -0,0 +1,46 @@
#!/bin/bash
# gather logs generated by "make [dist]check"
# this also limits log size so that buildbot does not abort
# Copyright (C) 2020 by Rainer Gerhards, released under ASL 2.0
show_log() {
if grep -q ":test-result: FAIL" "$1"; then
printf "\nFAIL: ${1%%.trs} \
########################################################\
################################\n\n"
logfile="${1%%trs}log"
if [ -f "$logfile" ]; then
lines="$(wc -l < $logfile)"
if (( lines > 4000 )); then
ls -l $logfile
printf 'file is very large (%d lines), showing parts\n' $lines
head -n 2000 < "$logfile"
printf '\n\n... snip ...\n\n'
tail -n 2000 < "$logfile"
else
cat "$logfile"
fi
else
printf 'log FILE MISSING!\n'
fi
fi
}
append_summary() {
echo file: $1 # emit file name just in case we have multiple!
head -n12 "$1"
}
export -f show_log
export -f append_summary
############################## MAIN ENTRY POINT ##############################
printf 'find failing tests\n'
rm -f failed-tests.log
find . -name "*.trs" -exec bash -c 'show_log "$1" >> failed-tests.log' _ {} \;
if [ -f failed-tests.log ]; then
# show summary stats so that we know how many failed
find . -name test-suite.log -exec bash -c 'append_summary "$1" >>failed-tests.log' _ {} \;
fi

View File

@ -33,15 +33,9 @@ echo CI_CHECK_CMD: $CI_CHECK_CMD
make $CI_MAKE_CHECK_OPT ${CI_CHECK_CMD:-check}
rc=$?
# find failing tests
echo find failing tests
head -n12 tests/test-suite.log >> failed.tests.log
find . -name "*.trs" -exec bash -c 'if grep ":test-result: FAIL" "$1"; then printf "\nFAIL: ${1%%.trs} ########################################################################################\n\n" >> failed-tests.log; cat "${1%%trs}log" >> failed-tests.log; fi' _ {} \;
if [ -f failed-tests.log ]; then
# show summary stats so that we know how many failed
echo in failed logs addition
head -n12 tests/test-suite.log >> failed-tests.log
fi
printf 'STEP: find failing tests ====================================================\n'
echo calling gather-check-logs
devtools/gather-check-logs.sh
printf 'STEP: Codecov upload =======================================================\n'
if [ "$CI_CODECOV_TOKEN" != "" ]; then