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

Side by Side Diff: tools/valgrind/chrome_tests.py

Issue 624533003: Check that the user doesn't try to run ASan-built binaries under Valgrind etc (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address review comments Created 6 years, 2 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 | « tools/valgrind/asan/asan_wrapper.sh ('k') | tools/valgrind/valgrind_test.py » ('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 ''' 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
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
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())
OLDNEW
« no previous file with comments | « tools/valgrind/asan/asan_wrapper.sh ('k') | tools/valgrind/valgrind_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698