Chromium Code Reviews
Help | Chromium Project | Sign in
(649)

Side by Side Diff: scripts/slave/runtest.py

Issue 9949032: Read in gtest_exclude files before running ASAN. (Closed) Base URL: svn://chrome-svn/chrome/trunk/tools/build/
Patch Set: Created 2 years ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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 """A tool to run a chrome test executable, used by the buildbot slaves. 6 """A tool to run a chrome test executable, used by the buildbot slaves.
7 7
8 When this is run, the current directory (cwd) should be the outer build 8 When this is run, the current directory (cwd) should be the outer build
9 directory (e.g., chrome-release/build/). 9 directory (e.g., chrome-release/build/).
10 10
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 122
123 # Generate results JSON file and upload it to the appspot server. 123 # Generate results JSON file and upload it to the appspot server.
124 gtest_slave_utils.GenerateAndUploadJSONResults( 124 gtest_slave_utils.GenerateAndUploadJSONResults(
125 results_map, generate_json_options) 125 results_map, generate_json_options)
126 126
127 # The code can throw all sorts of exceptions, including 127 # The code can throw all sorts of exceptions, including
128 # slave.gtest.networktransaction.NetworkTimeout so just trap everything. 128 # slave.gtest.networktransaction.NetworkTimeout so just trap everything.
129 except: # pylint: disable=W0702 129 except: # pylint: disable=W0702
130 print 'Unexpected error while generating JSON' 130 print 'Unexpected error while generating JSON'
131 131
132 def _GetGtestFilterForAsan(build_dir, test_name):
133 """Returns an appropriate --gtest_filter flag for googletest binary
134 invocation. A cheap knock off of _AppendGtestFilter() from
135 src/tools/valgrind/chrome_test.py just for ASAN.
136
137 Args:
138 build_dir: the path to the src/build directory.
139 test_name: the name of the test, e.g. browser_tests.
140 """
141 print 'Reading gtest exclude filter files for ASAN:'
142 test_files = [
143 '%s.gtest-asan.txt' % test_name,
144 '%s.gtest-asan_%s.txt' % (test_name, chromium_utils.PlatformName())]
145 gtest_dir = os.path.join(
146 build_dir, '..', 'tools', 'valgrind', 'gtest_exclude')
147 filters = []
148 for test_file in test_files:
149 test_path = os.path.join(gtest_dir, test_file)
150 if not os.path.exists(test_path):
151 print ' "%s" - not found' % test_file
152 continue
153 print ' "%s" - OK' % test_file
154 f = open(test_path, 'r')
155 for line in f.readlines():
156 if line.startswith('#') or line.startswith('//') or line.isspace():
Alexander Potapenko 2012/04/06 07:32:53 I don't mind treating '//' as a comment line, but
157 continue
158 line = line.rstrip()
159 test_prefixes = ['FLAKY', 'FAILS']
160 for p in test_prefixes:
161 # Strip prefixes from the test names.
162 line = line.replace('.%s_' % p, '.')
163 # Exclude the original test name.
164 filters.append(line)
165 if line[-2:] != '.*':
166 # List all possible prefixes if line doesn't end with '.*'.
167 for p in test_prefixes:
168 filters.append(line.replace('.', '.%s_' % p))
169 # Get rid of duplicates.
170 filters = set(filters)
171 if not filters:
172 return None
173 gtest_filter = '-'
Alexander Potapenko 2012/04/06 07:32:53 How about joining lines 173 and 174? (and maybe 17
174 gtest_filter += ':'.join(filters)
175 return gtest_filter
176
132 def start_http_server(platform, build_dir, test_exe_path, document_root): 177 def start_http_server(platform, build_dir, test_exe_path, document_root):
133 # pylint: disable=F0401 178 # pylint: disable=F0401
134 import google.httpd_utils 179 import google.httpd_utils
135 import google.platform_utils 180 import google.platform_utils
136 platform_util = google.platform_utils.PlatformUtility(build_dir) 181 platform_util = google.platform_utils.PlatformUtility(build_dir)
137 182
138 # Name the output directory for the exe, without its path or suffix. 183 # Name the output directory for the exe, without its path or suffix.
139 # e.g., chrome-release/httpd_logs/unit_tests/ 184 # e.g., chrome-release/httpd_logs/unit_tests/
140 test_exe_name = os.path.splitext(os.path.basename(test_exe_path))[0] 185 test_exe_name = os.path.splitext(os.path.basename(test_exe_path))[0]
141 output_dir = os.path.join(slave_utils.SlaveBaseDir(build_dir), 186 output_dir = os.path.join(slave_utils.SlaveBaseDir(build_dir),
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 # remove the old XML output file. 273 # remove the old XML output file.
229 os.remove(options.test_output_xml) 274 os.remove(options.test_output_xml)
230 275
231 try: 276 try:
232 http_server = None 277 http_server = None
233 if options.document_root: 278 if options.document_root:
234 http_server = start_http_server('mac', build_dir=build_dir, 279 http_server = start_http_server('mac', build_dir=build_dir,
235 test_exe_path=test_exe_path, 280 test_exe_path=test_exe_path,
236 document_root=options.document_root) 281 document_root=options.document_root)
237 if options.factory_properties.get('asan', False): 282 if options.factory_properties.get('asan', False):
283 gtest_filter = _GetGtestFilterForAsan(build_dir, args[0])
284 if gtest_filter:
285 command.append('--gtest_filter=%s' % gtest_filter)
238 symbolize = os.path.abspath(os.path.join('src', 'third_party', 'asan', 286 symbolize = os.path.abspath(os.path.join('src', 'third_party', 'asan',
239 'scripts', 'asan_symbolize.py')) 287 'scripts', 'asan_symbolize.py'))
240 pipes = [[sys.executable, symbolize], ['c++filt']] 288 pipes = [[sys.executable, symbolize], ['c++filt']]
241 result = _RunGTestCommand(command, pipes=pipes) 289 result = _RunGTestCommand(command, pipes=pipes)
242 else: 290 else:
243 result = _RunGTestCommand(command, results_tracker) 291 result = _RunGTestCommand(command, results_tracker)
244 finally: 292 finally:
245 if http_server: 293 if http_server:
246 http_server.StopServer() 294 http_server.StopServer()
247 295
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 if options.document_root: 398 if options.document_root:
351 http_server = start_http_server('linux', build_dir=build_dir, 399 http_server = start_http_server('linux', build_dir=build_dir,
352 test_exe_path=test_exe_path, 400 test_exe_path=test_exe_path,
353 document_root=options.document_root) 401 document_root=options.document_root)
354 if options.xvfb: 402 if options.xvfb:
355 xvfb.StartVirtualX( 403 xvfb.StartVirtualX(
356 slave_name, bin_dir, 404 slave_name, bin_dir,
357 with_wm=options.factory_properties.get('window_manager', True), 405 with_wm=options.factory_properties.get('window_manager', True),
358 server_dir=special_xvfb_dir) 406 server_dir=special_xvfb_dir)
359 if options.factory_properties.get('asan', False): 407 if options.factory_properties.get('asan', False):
408 gtest_filter = _GetGtestFilterForAsan(build_dir, args[0])
409 if gtest_filter:
410 command.append('--gtest_filter=%s' % gtest_filter)
360 symbolize = os.path.abspath(os.path.join('src', 'third_party', 'asan', 411 symbolize = os.path.abspath(os.path.join('src', 'third_party', 'asan',
361 'scripts', 'asan_symbolize.py')) 412 'scripts', 'asan_symbolize.py'))
362 pipes = [[sys.executable, symbolize], ['c++filt']] 413 pipes = [[sys.executable, symbolize], ['c++filt']]
363 result = _RunGTestCommand(command, pipes=pipes) 414 result = _RunGTestCommand(command, pipes=pipes)
364 else: 415 else:
365 result = _RunGTestCommand(command, results_tracker) 416 result = _RunGTestCommand(command, results_tracker)
366 finally: 417 finally:
367 if http_server: 418 if http_server:
368 http_server.StopServer() 419 http_server.StopServer()
369 if options.xvfb: 420 if options.xvfb:
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 '%d new files were left in %s: Fix the tests to clean up themselves.' 642 '%d new files were left in %s: Fix the tests to clean up themselves.'
592 ) % ((new_temp_files - temp_files), tempfile.gettempdir()) 643 ) % ((new_temp_files - temp_files), tempfile.gettempdir())
593 # TODO(maruel): Make it an error soon. Not yet since I want to iron out all 644 # TODO(maruel): Make it an error soon. Not yet since I want to iron out all
594 # the remaining cases before. 645 # the remaining cases before.
595 #result = 1 646 #result = 1
596 return result 647 return result
597 648
598 649
599 if '__main__' == __name__: 650 if '__main__' == __name__:
600 sys.exit(main()) 651 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld 1280:2d3e6564b7b6