scripts/unit-test: Run ub+asan for meson
Meson supports trivially enabling undefined behavior sanitizer and
address sanitizer support. All tests should be run through these
analyzers.
This also adds a TODO for memory sanitizer support which is not in gcc7
so we can't trivially support that yet.
Change-Id: Ib9e8c4a668f07bcc44733b691c17345e3ed276c4
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/scripts/unit-test.py b/scripts/unit-test.py
index ba95405..50afb06 100755
--- a/scripts/unit-test.py
+++ b/scripts/unit-test.py
@@ -720,6 +720,22 @@
check_call_cmd(top_dir, 'meson', 'test', '-C', 'build',
'--wrap', 'valgrind')
+ # Run tests through sanitizers
+ # b_lundef is needed if clang++ is CXX since it resolves the asan
+ # symbols at runtime only. We don't want to set it earlier in the
+ # build process to ensure we don't have undefined runtime code.
+ check_call_cmd(top_dir, 'meson', 'configure', 'build',
+ '-Db_sanitize=address,undefined', '-Db_lundef=false')
+ check_call_cmd(top_dir, 'meson', 'test', '-C', 'build',
+ '--logbase', 'testlog-ubasan')
+ # TODO: Fix memory sanitizer
+ #check_call_cmd(top_dir, 'meson', 'configure', 'build',
+ # '-Db_sanitize=memory')
+ #check_call_cmd(top_dir, 'meson', 'test', '-C', 'build'
+ # '--logbase', 'testlog-msan')
+ check_call_cmd(top_dir, 'meson', 'configure', 'build',
+ '-Db_sanitize=none', '-Db_lundef=true')
+
# Run coverage checks
check_call_cmd(top_dir, 'meson', 'configure', 'build',
'-Db_coverage=true')