| 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 |
| 128 # with other dynamic instrumentation-based tools. |
| 129 # TODO(timurrrr): also check TSan and MSan? |
| 130 # `nm` might not be available, so use try-except. |
| 131 try: |
| 132 nm_output = subprocess.check_output(["nm", exe_path]) |
| 133 if nm_output.find("__asan_init") != -1: |
| 134 raise BadBinary("You're trying to run an executable instrumented " |
| 135 "with AddressSanitizer under %s. Please provide " |
| 136 "an uninstrumented executable." % tool_name) |
| 137 except OSError: |
| 138 pass |
| 139 |
| 140 cmd.append(exe_path) |
| 119 # Valgrind runs tests slowly, so slow tests hurt more; show elapased time | 141 # Valgrind runs tests slowly, so slow tests hurt more; show elapased time |
| 120 # so we can find the slowpokes. | 142 # so we can find the slowpokes. |
| 121 cmd.append("--gtest_print_time") | 143 cmd.append("--gtest_print_time") |
| 122 # Built-in test launcher for gtest-based executables runs tests using | 144 # Built-in test launcher for gtest-based executables runs tests using |
| 123 # multiple process by default. Force the single-process mode back. | 145 # multiple process by default. Force the single-process mode back. |
| 124 cmd.append("--single-process-tests") | 146 cmd.append("--single-process-tests") |
| 125 if self._options.gtest_repeat: | 147 if self._options.gtest_repeat: |
| 126 cmd.append("--gtest_repeat=%s" % self._options.gtest_repeat) | 148 cmd.append("--gtest_repeat=%s" % self._options.gtest_repeat) |
| 127 if self._options.gtest_shuffle: | 149 if self._options.gtest_shuffle: |
| 128 cmd.append("--gtest_shuffle") | 150 cmd.append("--gtest_shuffle") |
| (...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 776 | 798 |
| 777 for t in options.test: | 799 for t in options.test: |
| 778 tests = ChromeTests(options, args, t) | 800 tests = ChromeTests(options, args, t) |
| 779 ret = tests.Run() | 801 ret = tests.Run() |
| 780 if ret: return ret | 802 if ret: return ret |
| 781 return 0 | 803 return 0 |
| 782 | 804 |
| 783 | 805 |
| 784 if __name__ == "__main__": | 806 if __name__ == "__main__": |
| 785 sys.exit(_main()) | 807 sys.exit(_main()) |
| OLD | NEW |