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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 (k, v) for k, v in sorted(extra_env.iteritems())), | 167 (k, v) for k, v in sorted(extra_env.iteritems())), |
168 ' '.join(cmd))) | 168 ' '.join(cmd))) |
169 env.update(extra_env or {}) | 169 env.update(extra_env or {}) |
170 try: | 170 try: |
171 # See above comment regarding offline symbolization. | 171 # See above comment regarding offline symbolization. |
172 if asan and not lsan: | 172 if asan and not lsan: |
173 # Need to pipe to the symbolizer script. | 173 # Need to pipe to the symbolizer script. |
174 p1 = subprocess.Popen(cmd, env=env, stdout=subprocess.PIPE, | 174 p1 = subprocess.Popen(cmd, env=env, stdout=subprocess.PIPE, |
175 stderr=sys.stdout) | 175 stderr=sys.stdout) |
176 p2 = subprocess.Popen(["../tools/valgrind/asan/asan_symbolize.py"], | 176 p2 = subprocess.Popen(["../tools/valgrind/asan/asan_symbolize.py"], |
177 stdin=p1.stdout) | 177 env=env, stdin=p1.stdout) |
178 p1.stdout.close() # Allow p1 to receive a SIGPIPE if p2 exits. | 178 p1.stdout.close() # Allow p1 to receive a SIGPIPE if p2 exits. |
| 179 p1.wait() |
179 p2.wait() | 180 p2.wait() |
180 return p2.returncode | 181 return p1.returncode |
181 else: | 182 else: |
182 return subprocess.call(cmd, env=env) | 183 return subprocess.call(cmd, env=env) |
183 except OSError: | 184 except OSError: |
184 print >> sys.stderr, 'Failed to start %s' % cmd | 185 print >> sys.stderr, 'Failed to start %s' % cmd |
185 raise | 186 raise |
186 | 187 |
187 | 188 |
188 def main(): | 189 def main(): |
189 return run_executable(sys.argv[1:], os.environ.copy()) | 190 return run_executable(sys.argv[1:], os.environ.copy()) |
190 | 191 |
191 | 192 |
192 if __name__ == '__main__': | 193 if __name__ == '__main__': |
193 sys.exit(main()) | 194 sys.exit(main()) |
OLD | NEW |