[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 5675763a 04/10: Automate UBSan unit tests
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 5675763a 04/10: Automate UBSan unit tests |
Date: |
Wed, 8 Jun 2022 19:41:00 -0400 (EDT) |
branch: master
commit 5675763ae6acecb70325489e3b42262639251748
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
Automate UBSan unit tests
Adding UBSan support more than doubles the size of this script;
arguably, once it's copied to 'nychthemeral_test.sh', it should be
removed here. However, at least for the moment, this commit serves
to highlight the somewhat recherché technique, for which see:
http://www.softpanorama.org/Tools/tee.shtml
It just so happens that UBSan writes its diagnostics to stderr,
which lmi's unit tests almost never use.
---
gwc/unit_test.sh | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/gwc/unit_test.sh b/gwc/unit_test.sh
index 17095564..93680c1f 100755
--- a/gwc/unit_test.sh
+++ b/gwc/unit_test.sh
@@ -1,5 +1,14 @@
#!/bin/zsh
+unit_test_stderr_clutter='
+/.*\/test_coding_rules_test\.sh$/d
+/^Testing .test_coding_rules.\.$/d
+/^ This message should appear on stderr\.$/d
+/^Integrity check failed for .coleridge.$/d
+/^Please report this: culminate() not called\.$/d
+/^sh: 1: xyzzy: not found$/d
+'
+
# 'triplets' really is used, but in a zsh-specific way
# shellcheck disable=SC2034
triplets="x86_64-pc-linux-gnu x86_64-w64-mingw32"
@@ -20,6 +29,27 @@ printf 'LMI_TRIPLET = "%s"\n' "$LMI_TRIPLET" > /dev/tty
>(grep \?\?\?\?) \
>(grep '!!!!' --count | xargs printf '%d tests succeeded\n') \
>"$log_dir"/unit_tests
+ if [ "x86_64-pc-linux-gnu" = "$LMI_TRIPLET" ]
+ then
+ printf '\n unit tests with UBSan\n\n'
+ # shellcheck disable=SC3001
+ (setopt nomultios; \
+ ( \
+ (make "$coefficiency" --output-sync=recurse unit_tests \
+ build_type=ubsan UBSAN_OPTIONS=print_stacktrace=1 \
+ | tee \
+ >(grep '\*\*\*') \
+ >(grep \?\?\?\?) \
+ >(grep '!!!!' --count | xargs printf '%d tests succeeded\n') \
+ >"$log_dir"/unit_tests_ubsan_stdout \
+ ) \
+ 3>&1 1>&2 2>&3 \
+ | tee "$log_dir"/unit_tests_ubsan_stderr \
+ | sed -e "$unit_test_stderr_clutter" \
+ | sed -e's/^/UBSan: /' \
+ ) 3>&1 1>&2 2>&3 \
+ );
+ fi
}
printf "\n Done.\n"
done
- [lmi-commits] [lmi] master updated (56930208 -> 60df9bef), Greg Chicares, 2022/06/08
- [lmi-commits] [lmi] master 56ba3303 01/10: For the nonce, exclude 'actuarial_table_test' ∩ UBSan, Greg Chicares, 2022/06/08
- [lmi-commits] [lmi] master 6e83ab22 08/10: Make system_test for every architecture, Greg Chicares, 2022/06/08
- [lmi-commits] [lmi] master 5675763a 04/10: Automate UBSan unit tests,
Greg Chicares <=
- [lmi-commits] [lmi] master 60df9bef 10/10: Filter out a few routine messages, Greg Chicares, 2022/06/08
- [lmi-commits] [lmi] master cc2078b2 09/10: Build default targets for each important build_type, Greg Chicares, 2022/06/08
- [lmi-commits] [lmi] master 7aa985c5 07/10: Preserve discrepancies found in various CLI outputs, Greg Chicares, 2022/06/08
- [lmi-commits] [lmi] master b4b0e2c9 06/10: Adjust whitespace, Greg Chicares, 2022/06/08
- [lmi-commits] [lmi] master 83e53663 02/10: For the nonce, exclude 'math_functions_test' ∩ UBSan, Greg Chicares, 2022/06/08
- [lmi-commits] [lmi] master a4cae8ed 05/10: Transplant the last revision, Greg Chicares, 2022/06/08
- [lmi-commits] [lmi] master 12537383 03/10: Remove an unuseful option, Greg Chicares, 2022/06/08