scripts/unit-test: Detect problematic sanitizers
Instead of permanently blacklisting sanitizers from running in our unit
test environment for all powerpc platforms, run a problematic test case
to determine if we can use the sanitizers or not.
Tested:
Ran on amd64 and ppc64el to verify that sanitizers are still run on
the currently working amd64 and not on the currently broken ppc64el.
Change-Id: If26e8a3b8d88c579556d30508b69a11d08ed5b5c
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/scripts/unit-test.py b/scripts/unit-test.py
index 094c40c..492f10c 100755
--- a/scripts/unit-test.py
+++ b/scripts/unit-test.py
@@ -584,7 +584,23 @@
"""
Returns whether it is safe to run sanitizers on our platform
"""
- return re.match('ppc64', platform.machine()) is None
+ src = 'unit-test-sanitize.c'
+ exe = './unit-test-sanitize'
+ with open(src, 'w') as h:
+ h.write('int main() { return 0; }\n')
+ try:
+ with open(os.devnull, 'w') as devnull:
+ check_call(['gcc', '-O2', '-fsanitize=address',
+ '-fsanitize=undefined', '-o', exe, src],
+ stdout=devnull, stderr=devnull)
+ check_call([exe], stdout=devnull, stderr=devnull)
+ return True
+ except:
+ sys.stderr.write("###### Platform is not sanitize safe ######\n")
+ return False
+ finally:
+ os.remove(src)
+ os.remove(exe)
def meson_setup_exists(setup):
"""