diff options
author | Nicolas Boichat <drinkcat@chromium.org> | 2018-06-21 08:39:30 +0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-06-28 07:06:46 -0700 |
commit | 6c6888037c8d82228b480eeba0eaf1b0aa83e9f8 (patch) | |
tree | 5ccd44915959fa98d811bb4e53f71b295ec41317 /util/run_host_test | |
parent | dcfbe0be69d3445edfd45fb036bfae2581b6fdd5 (diff) | |
download | chrome-ec-6c6888037c8d82228b480eeba0eaf1b0aa83e9f8.tar.gz |
ec: Make it possible to run tests with AddressSanitizer enabled
Automatically use CC=clang if TEST_ASAN is specified.
Also, add a __no_sanitize_address attribute macro to prevent ASan
from adding guards around host_command, mkbp_event, and hook
"arrays" that are generated at link-time.
Also, set ASAN_OPTIONS env variable in run_host_test.
BRANCH=none
BUG=chromium:854924
TEST=make TEST_ASAN=y runtests -j
Change-Id: Iaf0ec405022760d757a8a9d62a5022460d1b16e1
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1109661
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'util/run_host_test')
-rwxr-xr-x | util/run_host_test | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/util/run_host_test b/util/run_host_test index c0482a7863..395afd4620 100755 --- a/util/run_host_test +++ b/util/run_host_test @@ -5,6 +5,7 @@ # found in the LICENSE file. from cStringIO import StringIO +import os import pexpect import signal import subprocess @@ -34,9 +35,9 @@ class Tee(object): sys.stdout.flush() self._target.flush() -def RunOnce(test_name, log): +def RunOnce(test_name, log, env): child = pexpect.spawn('build/host/{0}/{0}.exe'.format(test_name), - timeout=TIMEOUT) + timeout=TIMEOUT, env=env) child.logfile = log try: return child.expect(EXPECT_LIST) @@ -49,12 +50,17 @@ def RunOnce(test_name, log): child.kill(signal.SIGTERM) child.read() +# ASAN_OPTIONS environment variable is only required when test is built with +# ASan, but is otherwise harmless. +env = dict(os.environ) +env["ASAN_OPTIONS"] = "log_path=stderr" + log = StringIO() tee_log = Tee(log) test_name = sys.argv[1] start_time = time.time() -result_id = RunOnce(test_name, tee_log) +result_id = RunOnce(test_name, tee_log, env) elapsed_time = time.time() - start_time if result_id == RESULT_ID_TIMEOUT: |