Skip to content

Commit

Permalink
scripts/unit-test: Detect problematic sanitizers
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
wak-google authored and geissonator committed Feb 12, 2019
1 parent 0326ded commit 0b7fb2b
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion scripts/unit-test.py
Expand Up @@ -584,7 +584,23 @@ def is_sanitize_safe():
"""
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):
"""
Expand Down

0 comments on commit 0b7fb2b

Please sign in to comment.