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

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

Issue 9965045: Add Web Page Replay support. (Closed) Base URL: http://src.chromium.org/svn/trunk/tools/build/
Patch Set: Created 8 years, 7 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 | 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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 document_root) 164 document_root)
165 stop_cmd = platform_util.GetStopHttpdCommand() 165 stop_cmd = platform_util.GetStopHttpdCommand()
166 http_server = google.httpd_utils.ApacheHttpd(start_cmd, stop_cmd, [8000]) 166 http_server = google.httpd_utils.ApacheHttpd(start_cmd, stop_cmd, [8000])
167 try: 167 try:
168 http_server.StartServer() 168 http_server.StartServer()
169 except google.httpd_utils.HttpdNotStarted, e: 169 except google.httpd_utils.HttpdNotStarted, e:
170 raise google.httpd_utils.HttpdNotStarted('%s. See log file in %s' % 170 raise google.httpd_utils.HttpdNotStarted('%s. See log file in %s' %
171 (e, output_dir)) 171 (e, output_dir))
172 return http_server 172 return http_server
173 173
174 def start_wpr_server(test_exe_path):
175 """Start Web Page Replay server.
176
177 WPR makes it easy to record all the resources for a web page and serve
178 that page with a simulated network.
179 """
180 # pylint: disable=F0401
181 import google.webpagereplay_utils
182 test_exe_name = os.path.splitext(os.path.basename(test_exe_path))[0]
183 paths = google.webpagereplay_utils.ChromiumPaths(
184 TEST_EXE_NAME=test_exe_name, TEST_NAME='2012Q2')
185 wpr_server = google.webpagereplay_utils.ReplayLauncher(
186 paths['replay'], paths['.wpr'], paths['logs'], ['--no-dns_forwarding'])
187 wpr_server.StartServer()
188 return wpr_server
189
174 def main_mac(options, args): 190 def main_mac(options, args):
175 if len(args) < 1: 191 if len(args) < 1:
176 raise chromium_utils.MissingArgument('Usage: %s' % USAGE) 192 raise chromium_utils.MissingArgument('Usage: %s' % USAGE)
177 193
178 test_exe = args[0] 194 test_exe = args[0]
179 build_dir = os.path.normpath(os.path.abspath(options.build_dir)) 195 build_dir = os.path.normpath(os.path.abspath(options.build_dir))
180 test_exe_path = os.path.join(build_dir, options.target, test_exe) 196 test_exe_path = os.path.join(build_dir, options.target, test_exe)
181 if not os.path.exists(test_exe_path): 197 if not os.path.exists(test_exe_path):
182 pre = 'Unable to find %s\n' % test_exe_path 198 pre = 'Unable to find %s\n' % test_exe_path
183 199
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 results_tracker = None 242 results_tracker = None
227 if options.generate_json_file: 243 if options.generate_json_file:
228 results_tracker = gtest_slave_utils.GTestUnexpectedDeathTracker() 244 results_tracker = gtest_slave_utils.GTestUnexpectedDeathTracker()
229 245
230 if os.path.exists(options.test_output_xml): 246 if os.path.exists(options.test_output_xml):
231 # remove the old XML output file. 247 # remove the old XML output file.
232 os.remove(options.test_output_xml) 248 os.remove(options.test_output_xml)
233 249
234 try: 250 try:
235 http_server = None 251 http_server = None
252 webpagereplay_server = None
236 if options.document_root: 253 if options.document_root:
237 http_server = start_http_server('mac', build_dir=build_dir, 254 http_server = start_http_server('mac', build_dir=build_dir,
238 test_exe_path=test_exe_path, 255 test_exe_path=test_exe_path,
239 document_root=options.document_root) 256 document_root=options.document_root)
257 if options.enable_wpr:
258 webpagereplay_server = start_wpr_server(test_exe_path)
240 if options.factory_properties.get('asan', False): 259 if options.factory_properties.get('asan', False):
241 symbolize = os.path.abspath(os.path.join('src', 'third_party', 'asan', 260 symbolize = os.path.abspath(os.path.join('src', 'third_party', 'asan',
242 'scripts', 'asan_symbolize.py')) 261 'scripts', 'asan_symbolize.py'))
243 pipes = [[sys.executable, symbolize], ['c++filt']] 262 pipes = [[sys.executable, symbolize], ['c++filt']]
244 result = _RunGTestCommand(command, pipes=pipes) 263 result = _RunGTestCommand(command, pipes=pipes)
245 else: 264 else:
246 result = _RunGTestCommand(command, results_tracker) 265 result = _RunGTestCommand(command, results_tracker)
247 finally: 266 finally:
248 if http_server: 267 if http_server:
249 http_server.StopServer() 268 http_server.StopServer()
269 if webpagereplay_server:
270 webpagereplay_server.StopServer()
250 271
251 if options.generate_json_file: 272 if options.generate_json_file:
252 _GenerateJSONForTestResults(options, results_tracker) 273 _GenerateJSONForTestResults(options, results_tracker)
253 274
254 return result 275 return result
255 276
256 def main_linux(options, args): 277 def main_linux(options, args):
257 if len(args) < 1: 278 if len(args) < 1:
258 raise chromium_utils.MissingArgument('Usage: %s' % USAGE) 279 raise chromium_utils.MissingArgument('Usage: %s' % USAGE)
259 280
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 results_tracker = None 367 results_tracker = None
347 if options.generate_json_file: 368 if options.generate_json_file:
348 results_tracker = gtest_slave_utils.GTestUnexpectedDeathTracker() 369 results_tracker = gtest_slave_utils.GTestUnexpectedDeathTracker()
349 370
350 if os.path.exists(options.test_output_xml): 371 if os.path.exists(options.test_output_xml):
351 # remove the old XML output file. 372 # remove the old XML output file.
352 os.remove(options.test_output_xml) 373 os.remove(options.test_output_xml)
353 374
354 try: 375 try:
355 http_server = None 376 http_server = None
377 webpagereplay_server = None
356 if options.document_root: 378 if options.document_root:
357 http_server = start_http_server('linux', build_dir=build_dir, 379 http_server = start_http_server('linux', build_dir=build_dir,
358 test_exe_path=test_exe_path, 380 test_exe_path=test_exe_path,
359 document_root=options.document_root) 381 document_root=options.document_root)
382 if options.enable_wpr:
383 webpagereplay_server = start_wpr_server(test_exe_path)
360 if options.xvfb: 384 if options.xvfb:
361 xvfb.StartVirtualX( 385 xvfb.StartVirtualX(
362 slave_name, bin_dir, 386 slave_name, bin_dir,
363 with_wm=options.factory_properties.get('window_manager', True), 387 with_wm=options.factory_properties.get('window_manager', True),
364 server_dir=special_xvfb_dir) 388 server_dir=special_xvfb_dir)
365 if options.factory_properties.get('asan', False): 389 if options.factory_properties.get('asan', False):
366 symbolize = os.path.abspath(os.path.join('src', 'third_party', 'asan', 390 symbolize = os.path.abspath(os.path.join('src', 'third_party', 'asan',
367 'scripts', 'asan_symbolize.py')) 391 'scripts', 'asan_symbolize.py'))
368 pipes = [[sys.executable, symbolize], ['c++filt']] 392 pipes = [[sys.executable, symbolize], ['c++filt']]
369 result = _RunGTestCommand(command, pipes=pipes) 393 result = _RunGTestCommand(command, pipes=pipes)
370 else: 394 else:
371 result = _RunGTestCommand(command, results_tracker) 395 result = _RunGTestCommand(command, results_tracker)
372 finally: 396 finally:
373 if http_server: 397 if http_server:
374 http_server.StopServer() 398 http_server.StopServer()
399 if webpagereplay_server:
400 webpagereplay_server.StopServer()
375 if options.xvfb: 401 if options.xvfb:
376 xvfb.StopVirtualX(slave_name) 402 xvfb.StopVirtualX(slave_name)
377 403
378 if options.generate_json_file: 404 if options.generate_json_file:
379 _GenerateJSONForTestResults(options, results_tracker) 405 _GenerateJSONForTestResults(options, results_tracker)
380 406
381 return result 407 return result
382 408
383 def main_win(options, args): 409 def main_win(options, args):
384 """Using the target build configuration, run the executable given in the 410 """Using the target build configuration, run the executable given in the
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 help='path to main build directory (the parent of ' 503 help='path to main build directory (the parent of '
478 'the Release or Debug directory)') 504 'the Release or Debug directory)')
479 option_parser.add_option('', '--enable-pageheap', action='store_true', 505 option_parser.add_option('', '--enable-pageheap', action='store_true',
480 default=False, 506 default=False,
481 help='enable pageheap checking for chrome.exe') 507 help='enable pageheap checking for chrome.exe')
482 # --with-httpd assumes a chromium checkout with src/tools/python. 508 # --with-httpd assumes a chromium checkout with src/tools/python.
483 option_parser.add_option('', '--with-httpd', dest='document_root', 509 option_parser.add_option('', '--with-httpd', dest='document_root',
484 default=None, metavar='DOC_ROOT', 510 default=None, metavar='DOC_ROOT',
485 help='Start a local httpd server using the given ' 511 help='Start a local httpd server using the given '
486 'document root, relative to the current dir') 512 'document root, relative to the current dir')
513 option_parser.add_option('', '--enable-wpr', action='store_true',
514 default=False,
515 help='Start the given Web Page Replay server using '
516 'the httpd document root as the archive root.')
487 option_parser.add_option('', '--total-shards', dest='total_shards', 517 option_parser.add_option('', '--total-shards', dest='total_shards',
488 default=None, type="int", 518 default=None, type="int",
489 help='Number of shards to split this test into.') 519 help='Number of shards to split this test into.')
490 option_parser.add_option('', '--shard-index', dest='shard_index', 520 option_parser.add_option('', '--shard-index', dest='shard_index',
491 default=None, type="int", 521 default=None, type="int",
492 help='Shard to run. Must be between 1 and ' 522 help='Shard to run. Must be between 1 and '
493 'total-shards.') 523 'total-shards.')
494 option_parser.add_option('', '--run-shell-script', action='store_true', 524 option_parser.add_option('', '--run-shell-script', action='store_true',
495 default=False, 525 default=False,
496 help='treat first argument as the shell script' 526 help='treat first argument as the shell script'
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 '%d new files were left in %s: Fix the tests to clean up themselves.' 630 '%d new files were left in %s: Fix the tests to clean up themselves.'
601 ) % ((new_temp_files - temp_files), tempfile.gettempdir()) 631 ) % ((new_temp_files - temp_files), tempfile.gettempdir())
602 # TODO(maruel): Make it an error soon. Not yet since I want to iron out all 632 # TODO(maruel): Make it an error soon. Not yet since I want to iron out all
603 # the remaining cases before. 633 # the remaining cases before.
604 #result = 1 634 #result = 1
605 return result 635 return result
606 636
607 637
608 if '__main__' == __name__: 638 if '__main__' == __name__:
609 sys.exit(main()) 639 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
This is Rietveld 408576698