Diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Fail a test script that leaves a sanitizer report
Without -v a report went to /dev/null with the rest of stderr, and one
from a process whose status a pipeline or a background job loses
failed nothing at all.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/aggregate-results.sh | 11 | |
| -rw-r--r-- | tests/setup.sh | 31 |
2 files changed, 42 insertions, 0 deletions
diff --git a/tests/aggregate-results.sh b/tests/aggregate-results.sh index 27ac1df..2cb9e18 100644 --- a/tests/aggregate-results.sh +++ b/tests/aggregate-results.sh @@ -22,6 +22,17 @@ do then failed_scripts="$failed_scripts $name" fi + # setup.sh fails a script that leaves a sanitizer report, and this + # makes sure of it. + for report in "test-results/$name.sanitizer".* + do + test -f "$report" || continue + echo "sanitizer report: $report" + case " $failed_scripts " in + *" $name "*) ;; + *) failed_scripts="$failed_scripts $name" ;; + esac + done test -f "test-results/$name.counts" || continue total=0 success=0 fixed=0 broken=0 failure=0 prereqs= diff --git a/tests/setup.sh b/tests/setup.sh index bd8b4c4..68b7a5b 100644 --- a/tests/setup.sh +++ b/tests/setup.sh @@ -69,6 +69,37 @@ done unset cgit_variable umask 022 +# A sanitizer report goes to stderr, which the library throws away without -v, +# and a process whose exit status is lost, one in a pipeline say, fails no test +# at all. So each report is written to a file beside the script's counts, and +# any found there when the script ends are shown and fail a test of their own. +# The summary looks for them again. +cgit_sanitizer_log="$TEST_RESULTS_BASE.sanitizer" +mkdir -p "$TEST_RESULTS_DIR" && +rm -f "$cgit_sanitizer_log".* || + BAIL_OUT "cannot prepare $TEST_RESULTS_DIR for sanitizer reports" +ASAN_OPTIONS="$ASAN_OPTIONS:log_path='$cgit_sanitizer_log'" +UBSAN_OPTIONS="$UBSAN_OPTIONS:log_path='$cgit_sanitizer_log'" +export ASAN_OPTIONS UBSAN_OPTIONS + +# This runs when the script ends, where the library has pointed stdout and +# stderr at its verbose output, so they are pointed back for the test. It can +# run twice when -i stops the script, which the flag guards against. +cgit_check_sanitizer_logs() { + test -z "$cgit_sanitizer_checked" || return 0 + cgit_sanitizer_checked=t + set -- "$cgit_sanitizer_log".* + test -f "$1" || return 0 + cat "$@" >&7 + test_expect_success 'no sanitizer reported an error' ' + for cgit_sanitizer_report in "$cgit_sanitizer_log".* + do + test_path_is_missing "$cgit_sanitizer_report" || return 1 + done + ' >&5 2>&7 +} +test_atexit cgit_check_sanitizer_logs + # The library has moved into the trash directory by now, so paths outside it # are anchored to TEST_OUTPUT_DIRECTORY. The tests run cgit by name, so the # binary just built has to come ahead of any copy already installed. Under |
