Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(659)

Side by Side Diff: testing/test_env.py

Issue 935333002: Update from https://crrev.com/316786 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « testing/scripts/webview_licenses.py ('k') | third_party/boringssl/boringssl.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Sets environment variables needed to run a chromium unit test.""" 6 """Sets environment variables needed to run a chromium unit test."""
7 7
8 import os 8 import os
9 import stat 9 import stat
10 import subprocess 10 import subprocess
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 # TODO(glider): remove the symbolizer path once 66 # TODO(glider): remove the symbolizer path once
67 # https://code.google.com/p/address-sanitizer/issues/detail?id=134 is fixed. 67 # https://code.google.com/p/address-sanitizer/issues/detail?id=134 is fixed.
68 symbolizer_path = os.path.abspath(os.path.join(ROOT_DIR, 'third_party', 68 symbolizer_path = os.path.abspath(os.path.join(ROOT_DIR, 'third_party',
69 'llvm-build', 'Release+Asserts', 'bin', 'llvm-symbolizer')) 69 'llvm-build', 'Release+Asserts', 'bin', 'llvm-symbolizer'))
70 70
71 if lsan or tsan: 71 if lsan or tsan:
72 # LSan is not sandbox-compatible, so we can use online symbolization. In 72 # LSan is not sandbox-compatible, so we can use online symbolization. In
73 # fact, it needs symbolization to be able to apply suppressions. 73 # fact, it needs symbolization to be able to apply suppressions.
74 symbolization_options = ['symbolize=1', 74 symbolization_options = ['symbolize=1',
75 'external_symbolizer_path=%s' % symbolizer_path] 75 'external_symbolizer_path=%s' % symbolizer_path]
76 elif asan or msan: 76 elif (asan or msan) and sys.platform not in ['win32', 'cygwin']:
77 # ASan uses a script for offline symbolization. 77 # ASan uses a script for offline symbolization, except on Windows.
78 # Important note: when running ASan with leak detection enabled, we must use 78 # Important note: when running ASan with leak detection enabled, we must use
79 # the LSan symbolization options above. 79 # the LSan symbolization options above.
80 symbolization_options = ['symbolize=0'] 80 symbolization_options = ['symbolize=0']
81 # Set the path to llvm-symbolizer to be used by asan_symbolize.py 81 # Set the path to llvm-symbolizer to be used by asan_symbolize.py
82 extra_env['LLVM_SYMBOLIZER_PATH'] = symbolizer_path 82 extra_env['LLVM_SYMBOLIZER_PATH'] = symbolizer_path
83 else:
84 symbolization_options = []
83 85
84 if asan: 86 if asan:
85 asan_options = symbolization_options[:] 87 asan_options = symbolization_options[:]
86 if lsan: 88 if lsan:
87 asan_options.append('detect_leaks=1') 89 asan_options.append('detect_leaks=1')
88 90
89 extra_env['ASAN_OPTIONS'] = ' '.join(asan_options) 91 if asan_options:
92 extra_env['ASAN_OPTIONS'] = ' '.join(asan_options)
90 93
91 if sys.platform == 'darwin': 94 if sys.platform == 'darwin':
92 isolate_output_dir = os.path.abspath(os.path.dirname(cmd[0])) 95 isolate_output_dir = os.path.abspath(os.path.dirname(cmd[0]))
93 # This is needed because the test binary has @executable_path embedded in 96 # This is needed because the test binary has @executable_path embedded in
94 # it that the OS tries to resolve to the cache directory and not the 97 # it that the OS tries to resolve to the cache directory and not the
95 # mapped directory. 98 # mapped directory.
96 extra_env['DYLD_LIBRARY_PATH'] = str(isolate_output_dir) 99 extra_env['DYLD_LIBRARY_PATH'] = str(isolate_output_dir)
97 100
98 if lsan: 101 if lsan:
99 if asan or msan: 102 if asan or msan:
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 # Used by base/base_paths_linux.cc as an override. Just make sure the default 179 # Used by base/base_paths_linux.cc as an override. Just make sure the default
177 # logic is used. 180 # logic is used.
178 env.pop('CR_SOURCE_ROOT', None) 181 env.pop('CR_SOURCE_ROOT', None)
179 extra_env.update(get_sandbox_env(env)) 182 extra_env.update(get_sandbox_env(env))
180 183
181 # Copy logic from tools/build/scripts/slave/runtest.py. 184 # Copy logic from tools/build/scripts/slave/runtest.py.
182 asan = '--asan=1' in cmd 185 asan = '--asan=1' in cmd
183 lsan = '--lsan=1' in cmd 186 lsan = '--lsan=1' in cmd
184 msan = '--msan=1' in cmd 187 msan = '--msan=1' in cmd
185 tsan = '--tsan=1' in cmd 188 tsan = '--tsan=1' in cmd
186 use_symbolization_script = (asan or msan) and not lsan 189 if sys.platform in ['win32', 'cygwin']:
190 # Symbolization works in-process on Windows even when sandboxed.
191 use_symbolization_script = False
192 else:
193 # LSan doesn't support sandboxing yet, so we use the in-process symbolizer.
194 # Note that ASan and MSan can work together with LSan.
195 use_symbolization_script = (asan or msan) and not lsan
187 196
188 if asan or lsan or msan or tsan: 197 if asan or lsan or msan or tsan:
189 extra_env.update(get_sanitizer_env(cmd, asan, lsan, msan, tsan)) 198 extra_env.update(get_sanitizer_env(cmd, asan, lsan, msan, tsan))
190 199
191 if lsan or tsan: 200 if lsan or tsan:
192 # LSan and TSan are not sandbox-friendly. 201 # LSan and TSan are not sandbox-friendly.
193 cmd.append('--no-sandbox') 202 cmd.append('--no-sandbox')
194 203
195 cmd = trim_cmd(cmd) 204 cmd = trim_cmd(cmd)
196 205
(...skipping 28 matching lines...) Expand all
225 print >> sys.stderr, 'Failed to start %s' % cmd 234 print >> sys.stderr, 'Failed to start %s' % cmd
226 raise 235 raise
227 236
228 237
229 def main(): 238 def main():
230 return run_executable(sys.argv[1:], os.environ.copy()) 239 return run_executable(sys.argv[1:], os.environ.copy())
231 240
232 241
233 if __name__ == '__main__': 242 if __name__ == '__main__':
234 sys.exit(main()) 243 sys.exit(main())
OLDNEW
« no previous file with comments | « testing/scripts/webview_licenses.py ('k') | third_party/boringssl/boringssl.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698