Chromium Code Reviews| 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 ''' Runs various chrome tests through valgrind_test.py.''' | 6 ''' Runs various chrome tests through valgrind_test.py.''' |
| 7 | 7 |
| 8 import glob | 8 import glob |
| 9 import logging | 9 import logging |
| 10 import multiprocessing | 10 import multiprocessing |
| 11 import optparse | 11 import optparse |
| 12 import os | 12 import os |
| 13 import stat | 13 import stat |
| 14 import subprocess | |
| 14 import sys | 15 import sys |
| 15 | 16 |
| 16 import logging_utils | 17 import logging_utils |
| 17 import path_utils | 18 import path_utils |
| 18 | 19 |
| 19 import common | 20 import common |
| 20 import valgrind_test | 21 import valgrind_test |
| 21 | 22 |
| 22 class TestNotFound(Exception): pass | 23 class TestNotFound(Exception): pass |
| 23 | 24 |
| 24 class MultipleGTestFiltersSpecified(Exception): pass | 25 class MultipleGTestFiltersSpecified(Exception): pass |
| 25 | 26 |
| 26 class BuildDirNotFound(Exception): pass | 27 class BuildDirNotFound(Exception): pass |
| 27 | 28 |
| 28 class BuildDirAmbiguous(Exception): pass | 29 class BuildDirAmbiguous(Exception): pass |
| 29 | 30 |
| 31 class ExecutableNotFound(Exception): pass | |
| 32 | |
| 33 class BadBinary(Exception): pass | |
| 34 | |
| 30 class ChromeTests: | 35 class ChromeTests: |
| 31 SLOW_TOOLS = ["memcheck", "tsan", "tsan_rv", "drmemory"] | 36 SLOW_TOOLS = ["memcheck", "tsan", "tsan_rv", "drmemory"] |
| 32 LAYOUT_TESTS_DEFAULT_CHUNK_SIZE = 300 | 37 LAYOUT_TESTS_DEFAULT_CHUNK_SIZE = 300 |
| 33 | 38 |
| 34 def __init__(self, options, args, test): | 39 def __init__(self, options, args, test): |
| 35 if ':' in test: | 40 if ':' in test: |
| 36 (self._test, self._gtest_filter) = test.split(':', 1) | 41 (self._test, self._gtest_filter) = test.split(':', 1) |
| 37 else: | 42 else: |
| 38 self._test = test | 43 self._test = test |
| 39 self._gtest_filter = options.gtest_filter | 44 self._gtest_filter = options.gtest_filter |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 108 | 113 |
| 109 if self._options.valgrind_tool_flags: | 114 if self._options.valgrind_tool_flags: |
| 110 cmd += self._options.valgrind_tool_flags.split(" ") | 115 cmd += self._options.valgrind_tool_flags.split(" ") |
| 111 if self._options.keep_logs: | 116 if self._options.keep_logs: |
| 112 cmd += ["--keep_logs"] | 117 cmd += ["--keep_logs"] |
| 113 if valgrind_test_args != None: | 118 if valgrind_test_args != None: |
| 114 for arg in valgrind_test_args: | 119 for arg in valgrind_test_args: |
| 115 cmd.append(arg) | 120 cmd.append(arg) |
| 116 if exe: | 121 if exe: |
| 117 self._EnsureBuildDirFound() | 122 self._EnsureBuildDirFound() |
| 118 cmd.append(os.path.join(self._options.build_dir, exe)) | 123 exe_path = os.path.join(self._options.build_dir, exe) |
| 124 if not os.path.exists(exe_path): | |
| 125 raise ExecutableNotFound("Couldn't find '%s'" % exe_path) | |
| 126 | |
| 127 # Make sure we don't try to test ASan-built binaries with other dynamic | |
| 128 # tools if `nm` is available. | |
| 129 if subprocess.call(["which", "nm"]) == 0: | |
|
Alexander Potapenko
2014/10/02 13:19:08
just wrapping subprocess.check_output() into a try
| |
| 130 nm_output = subprocess.check_output(["nm", exe_path]) | |
| 131 if nm_output.find("__asan_init") != -1: | |
| 132 raise BadBinary("You're trying to run an executable instrumented " | |
| 133 "with AddressSanitizer under %s. Please provide " | |
| 134 "an uninstrumented executable." % tool_name) | |
| 135 | |
| 136 cmd.append(exe_path) | |
| 119 # Valgrind runs tests slowly, so slow tests hurt more; show elapased time | 137 # Valgrind runs tests slowly, so slow tests hurt more; show elapased time |
| 120 # so we can find the slowpokes. | 138 # so we can find the slowpokes. |
| 121 cmd.append("--gtest_print_time") | 139 cmd.append("--gtest_print_time") |
| 122 # Built-in test launcher for gtest-based executables runs tests using | 140 # Built-in test launcher for gtest-based executables runs tests using |
| 123 # multiple process by default. Force the single-process mode back. | 141 # multiple process by default. Force the single-process mode back. |
| 124 cmd.append("--single-process-tests") | 142 cmd.append("--single-process-tests") |
| 125 if self._options.gtest_repeat: | 143 if self._options.gtest_repeat: |
| 126 cmd.append("--gtest_repeat=%s" % self._options.gtest_repeat) | 144 cmd.append("--gtest_repeat=%s" % self._options.gtest_repeat) |
| 127 if self._options.gtest_shuffle: | 145 if self._options.gtest_shuffle: |
| 128 cmd.append("--gtest_shuffle") | 146 cmd.append("--gtest_shuffle") |
| (...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 776 | 794 |
| 777 for t in options.test: | 795 for t in options.test: |
| 778 tests = ChromeTests(options, args, t) | 796 tests = ChromeTests(options, args, t) |
| 779 ret = tests.Run() | 797 ret = tests.Run() |
| 780 if ret: return ret | 798 if ret: return ret |
| 781 return 0 | 799 return 0 |
| 782 | 800 |
| 783 | 801 |
| 784 if __name__ == "__main__": | 802 if __name__ == "__main__": |
| 785 sys.exit(_main()) | 803 sys.exit(_main()) |
| OLD | NEW |