diff options
author | earthdok <earthdok@chromium.org> | 2015-01-29 13:19:36 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-01-29 21:20:32 +0000 |
commit | 9bd5d58a7f62385ed985abf3740daa17d53c2266 (patch) | |
tree | bb7085eb3ceb09d9db56d2d3924fe61b7a25e49b /testing/test_env.py | |
parent | 6b6714d20c8311b0b0badff0cd783eb6a4bff4bc (diff) | |
download | chromium_src-9bd5d58a7f62385ed985abf3740daa17d53c2266.zip chromium_src-9bd5d58a7f62385ed985abf3740daa17d53c2266.tar.gz chromium_src-9bd5d58a7f62385ed985abf3740daa17d53c2266.tar.bz2 |
Symbolize JSON output snippets in swarming ASan runs.
This mirrors an earlier change to non-swarming runs:
https://codereview.chromium.org/810643006/
BUG=372458
R=vadimsh@chromium.org
Review URL: https://codereview.chromium.org/865853009
Cr-Commit-Position: refs/heads/master@{#313793}
Diffstat (limited to 'testing/test_env.py')
-rwxr-xr-x | testing/test_env.py | 44 |
1 files changed, 41 insertions, 3 deletions
diff --git a/testing/test_env.py b/testing/test_env.py index 5f94326..0743f34 100755 --- a/testing/test_env.py +++ b/testing/test_env.py @@ -105,6 +105,42 @@ def get_asan_env(cmd, lsan): return extra_env +def get_sanitizer_symbolize_command(json_path=None): + """Construct the command to invoke offline symbolization script.""" + script_path = '../tools/valgrind/asan/asan_symbolize.py' + cmd = [sys.executable, script_path] + if json_path is not None: + cmd.append('--test-summary-json-file=%s' % json_path) + return cmd + + +def get_json_path(cmd): + """Extract the JSON test summary path from a command line.""" + json_path_flag = '--test-launcher-summary-output=' + for arg in cmd: + if arg.startswith(json_path_flag): + return arg.split(json_path_flag).pop() + return None + + +def symbolize_snippets_in_json(cmd, env): + """Symbolize output snippets inside the JSON test summary.""" + json_path = get_json_path(cmd) + if json_path is None: + return + + try: + symbolize_command = get_sanitizer_symbolize_command(json_path=json_path) + p = subprocess.Popen(symbolize_command, stderr=subprocess.PIPE, env=env) + (_, stderr) = p.communicate() + except OSError as e: + print 'Exception while symbolizing snippets: %s' % e + + if p.returncode != 0: + print "Error: failed to symbolize snippets in JSON:\n" + print stderr + + def run_executable(cmd, env): """Runs an executable with: - environment variable CR_SOURCE_ROOT set to the root directory. @@ -123,6 +159,7 @@ def run_executable(cmd, env): # Copy logic from tools/build/scripts/slave/runtest.py. asan = '--asan=1' in cmd lsan = '--lsan=1' in cmd + use_symbolization_script = asan and not lsan if asan: extra_env.update(get_asan_env(cmd, lsan)) @@ -146,16 +183,17 @@ def run_executable(cmd, env): env.update(extra_env or {}) try: # See above comment regarding offline symbolization. - if asan and not lsan: + if use_symbolization_script: # Need to pipe to the symbolizer script. p1 = subprocess.Popen(cmd, env=env, stdout=subprocess.PIPE, stderr=sys.stdout) - p2 = subprocess.Popen([sys.executable, - "../tools/valgrind/asan/asan_symbolize.py"], + p2 = subprocess.Popen(get_sanitizer_symbolize_command(), env=env, stdin=p1.stdout) p1.stdout.close() # Allow p1 to receive a SIGPIPE if p2 exits. p1.wait() p2.wait() + # Also feed the out-of-band JSON output to the symbolizer script. + symbolize_snippets_in_json(cmd, env) return p1.returncode else: return subprocess.call(cmd, env=env) |