OLD | NEW |
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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 extra_env = {} | 58 extra_env = {} |
59 | 59 |
60 # Instruct GTK to use malloc while running sanitizer-instrumented tests. | 60 # Instruct GTK to use malloc while running sanitizer-instrumented tests. |
61 extra_env['G_SLICE'] = 'always-malloc' | 61 extra_env['G_SLICE'] = 'always-malloc' |
62 | 62 |
63 extra_env['NSS_DISABLE_ARENA_FREE_LIST'] = '1' | 63 extra_env['NSS_DISABLE_ARENA_FREE_LIST'] = '1' |
64 extra_env['NSS_DISABLE_UNLOAD'] = '1' | 64 extra_env['NSS_DISABLE_UNLOAD'] = '1' |
65 | 65 |
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.join(ROOT_DIR, |
69 'llvm-build', 'Release+Asserts', 'bin', 'llvm-symbolizer')) | 69 'third_party', '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) and sys.platform not in ['win32', 'cygwin']: | 76 elif (asan or msan) and sys.platform not in ['win32', 'cygwin']: |
77 # ASan uses a script for offline symbolization, except on Windows. | 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. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 | 118 |
119 if tsan: | 119 if tsan: |
120 tsan_options = symbolization_options[:] | 120 tsan_options = symbolization_options[:] |
121 extra_env['TSAN_OPTIONS'] = ' '.join(tsan_options) | 121 extra_env['TSAN_OPTIONS'] = ' '.join(tsan_options) |
122 | 122 |
123 return extra_env | 123 return extra_env |
124 | 124 |
125 | 125 |
126 def get_sanitizer_symbolize_command(json_path=None, executable_path=None): | 126 def get_sanitizer_symbolize_command(json_path=None, executable_path=None): |
127 """Construct the command to invoke offline symbolization script.""" | 127 """Construct the command to invoke offline symbolization script.""" |
128 script_path = '../tools/valgrind/asan/asan_symbolize.py' | 128 script_path = os.path.join( |
| 129 ROOT_DIR, 'tools', 'valgrind', 'asan', 'asan_symbolize.py') |
129 cmd = [sys.executable, script_path] | 130 cmd = [sys.executable, script_path] |
130 if json_path is not None: | 131 if json_path is not None: |
131 cmd.append('--test-summary-json-file=%s' % json_path) | 132 cmd.append('--test-summary-json-file=%s' % json_path) |
132 if executable_path is not None: | 133 if executable_path is not None: |
133 cmd.append('--executable-path=%s' % executable_path) | 134 cmd.append('--executable-path=%s' % executable_path) |
134 return cmd | 135 return cmd |
135 | 136 |
136 | 137 |
137 def get_json_path(cmd): | 138 def get_json_path(cmd): |
138 """Extract the JSON test summary path from a command line.""" | 139 """Extract the JSON test summary path from a command line.""" |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 print >> sys.stderr, 'Failed to start %s' % cmd | 231 print >> sys.stderr, 'Failed to start %s' % cmd |
231 raise | 232 raise |
232 | 233 |
233 | 234 |
234 def main(): | 235 def main(): |
235 return run_executable(sys.argv[1:], os.environ.copy()) | 236 return run_executable(sys.argv[1:], os.environ.copy()) |
236 | 237 |
237 | 238 |
238 if __name__ == '__main__': | 239 if __name__ == '__main__': |
239 sys.exit(main()) | 240 sys.exit(main()) |
OLD | NEW |