lmi-commits
[Top][All Lists]
Advanced

[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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]