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

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, 8 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 | « DEPS ('k') | scripts/slave/webpagereplay.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 """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 19 matching lines...) Expand all
30 # which I really don't understand). 30 # which I really don't understand).
31 sys.path.insert(0, os.path.abspath('src/tools/python')) 31 sys.path.insert(0, os.path.abspath('src/tools/python'))
32 32
33 # Because of this dependency on a chromium checkout, we need to disable some 33 # Because of this dependency on a chromium checkout, we need to disable some
34 # pylint checks. 34 # pylint checks.
35 # pylint: disable=E0611 35 # pylint: disable=E0611
36 # pylint: disable=E1101 36 # pylint: disable=E1101
37 from common import chromium_utils 37 from common import chromium_utils
38 from slave import gtest_slave_utils 38 from slave import gtest_slave_utils
39 from slave import slave_utils 39 from slave import slave_utils
40 from slave import webpagereplay
40 from slave import xvfb 41 from slave import xvfb
41 import config 42 import config
42 43
43 USAGE = '%s [options] test.exe [test args]' % os.path.basename(sys.argv[0]) 44 USAGE = '%s [options] test.exe [test args]' % os.path.basename(sys.argv[0])
44 45
45 DEST_DIR = 'gtest_results' 46 DEST_DIR = 'gtest_results'
46 47
47 HTTPD_CONF = { 48 HTTPD_CONF = {
48 'linux': 'httpd2_linux.conf', 49 'linux': 'httpd2_linux.conf',
49 'mac': 'httpd2_mac.conf', 50 'mac': 'httpd2_mac.conf',
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 document_root) 165 document_root)
165 stop_cmd = platform_util.GetStopHttpdCommand() 166 stop_cmd = platform_util.GetStopHttpdCommand()
166 http_server = google.httpd_utils.ApacheHttpd(start_cmd, stop_cmd, [8000]) 167 http_server = google.httpd_utils.ApacheHttpd(start_cmd, stop_cmd, [8000])
167 try: 168 try:
168 http_server.StartServer() 169 http_server.StartServer()
169 except google.httpd_utils.HttpdNotStarted, e: 170 except google.httpd_utils.HttpdNotStarted, e:
170 raise google.httpd_utils.HttpdNotStarted('%s. See log file in %s' % 171 raise google.httpd_utils.HttpdNotStarted('%s. See log file in %s' %
171 (e, output_dir)) 172 (e, output_dir))
172 return http_server 173 return http_server
173 174
175 def start_wpr_server(platform, build_dir, test_exe_path, data_dir,
James Simonsen 2012/04/05 00:34:03 platform is unused.
176 wpr_dir=None):
177 """Start Web Page Replay server.
178
179 WPR makes it easy to record all the resources for a web page and serve
180 that page with a simulated network.
181 """
182 # Name the output directory for the exe, without its path or suffix.
183 # e.g., chrome-release/httpd_logs/unit_tests/
184 test_exe_name = os.path.splitext(os.path.basename(test_exe_path))[0]
185 output_dir = os.path.join(slave_utils.SlaveBaseDir(build_dir),
186 'webpagereplay_logs',
187 test_exe_name)
188 if wpr_dir is None:
189 wpr_dir = os.path.abspath(os.path.join(
190 __file__, '..', '..', '..', 'third_party', 'webpagereplay'))
191 data_dir = os.path.abspath(data_dir)
192 wpr_server = webpagereplay.ReplayLauncher(wpr_dir, data_dir, output_dir)
193 wpr_server.StartServer()
194 return wpr_server
195
174 def main_mac(options, args): 196 def main_mac(options, args):
175 if len(args) < 1: 197 if len(args) < 1:
176 raise chromium_utils.MissingArgument('Usage: %s' % USAGE) 198 raise chromium_utils.MissingArgument('Usage: %s' % USAGE)
177 199
178 test_exe = args[0] 200 test_exe = args[0]
179 build_dir = os.path.normpath(os.path.abspath(options.build_dir)) 201 build_dir = os.path.normpath(os.path.abspath(options.build_dir))
180 test_exe_path = os.path.join(build_dir, options.target, test_exe) 202 test_exe_path = os.path.join(build_dir, options.target, test_exe)
181 if not os.path.exists(test_exe_path): 203 if not os.path.exists(test_exe_path):
182 pre = 'Unable to find %s\n' % test_exe_path 204 pre = 'Unable to find %s\n' % test_exe_path
183 205
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 results_tracker = None 245 results_tracker = None
224 if options.generate_json_file: 246 if options.generate_json_file:
225 results_tracker = gtest_slave_utils.GTestUnexpectedDeathTracker() 247 results_tracker = gtest_slave_utils.GTestUnexpectedDeathTracker()
226 248
227 if os.path.exists(options.test_output_xml): 249 if os.path.exists(options.test_output_xml):
228 # remove the old XML output file. 250 # remove the old XML output file.
229 os.remove(options.test_output_xml) 251 os.remove(options.test_output_xml)
230 252
231 try: 253 try:
232 http_server = None 254 http_server = None
255 webpagereplay_server = None
233 if options.document_root: 256 if options.document_root:
234 http_server = start_http_server('mac', build_dir=build_dir, 257 http_server = start_http_server('mac', build_dir=build_dir,
235 test_exe_path=test_exe_path, 258 test_exe_path=test_exe_path,
236 document_root=options.document_root) 259 document_root=options.document_root)
260 if options.enable_wpr:
261 webpagereplay_server = start_wpr_server(
262 'mac', build_dir=build_dir, test_exe_path=test_exe_path,
263 data_dir=os.path.join(options.document_root, 'webpagereplay'))
237 result = _RunGTestCommand(command, results_tracker) 264 result = _RunGTestCommand(command, results_tracker)
238 finally: 265 finally:
239 if http_server: 266 if http_server:
240 http_server.StopServer() 267 http_server.StopServer()
268 if webpagereplay_server:
269 webpagereplay_server.StopServer()
241 270
242 if options.generate_json_file: 271 if options.generate_json_file:
243 _GenerateJSONForTestResults(options, results_tracker) 272 _GenerateJSONForTestResults(options, results_tracker)
244 273
245 return result 274 return result
246 275
247 def main_linux(options, args): 276 def main_linux(options, args):
248 if len(args) < 1: 277 if len(args) < 1:
249 raise chromium_utils.MissingArgument('Usage: %s' % USAGE) 278 raise chromium_utils.MissingArgument('Usage: %s' % USAGE)
250 279
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 results_tracker = None 358 results_tracker = None
330 if options.generate_json_file: 359 if options.generate_json_file:
331 results_tracker = gtest_slave_utils.GTestUnexpectedDeathTracker() 360 results_tracker = gtest_slave_utils.GTestUnexpectedDeathTracker()
332 361
333 if os.path.exists(options.test_output_xml): 362 if os.path.exists(options.test_output_xml):
334 # remove the old XML output file. 363 # remove the old XML output file.
335 os.remove(options.test_output_xml) 364 os.remove(options.test_output_xml)
336 365
337 try: 366 try:
338 http_server = None 367 http_server = None
368 webpagereplay_server = None
339 if options.document_root: 369 if options.document_root:
340 http_server = start_http_server('linux', build_dir=build_dir, 370 http_server = start_http_server('linux', build_dir=build_dir,
341 test_exe_path=test_exe_path, 371 test_exe_path=test_exe_path,
342 document_root=options.document_root) 372 document_root=options.document_root)
373 if options.enable_wpr:
374 webpagereplay_server = start_wpr_server(
375 'linux', build_dir=build_dir, test_exe_path=test_exe_path,
376 data_dir=os.path.join(options.document_root, 'webpagereplay'))
343 if options.xvfb: 377 if options.xvfb:
344 xvfb.StartVirtualX( 378 xvfb.StartVirtualX(
345 slave_name, bin_dir, 379 slave_name, bin_dir,
346 with_wm=options.factory_properties.get('window_manager', True), 380 with_wm=options.factory_properties.get('window_manager', True),
347 server_dir=special_xvfb_dir) 381 server_dir=special_xvfb_dir)
348 if options.factory_properties.get('asan', False): 382 if options.factory_properties.get('asan', False):
349 symbolize = os.path.abspath(os.path.join('src', 'third_party', 'asan', 383 symbolize = os.path.abspath(os.path.join('src', 'third_party', 'asan',
350 'scripts', 'asan_symbolize.py')) 384 'scripts', 'asan_symbolize.py'))
351 pipes = [[sys.executable, symbolize], ['c++filt']] 385 pipes = [[sys.executable, symbolize], ['c++filt']]
352 result = _RunGTestCommand(command, pipes=pipes) 386 result = _RunGTestCommand(command, pipes=pipes)
353 else: 387 else:
354 result = _RunGTestCommand(command, results_tracker) 388 result = _RunGTestCommand(command, results_tracker)
355 finally: 389 finally:
356 if http_server: 390 if http_server:
357 http_server.StopServer() 391 http_server.StopServer()
392 if webpagereplay_server:
393 webpagereplay_server.StopServer()
358 if options.xvfb: 394 if options.xvfb:
359 xvfb.StopVirtualX(slave_name) 395 xvfb.StopVirtualX(slave_name)
360 396
361 if options.generate_json_file: 397 if options.generate_json_file:
362 _GenerateJSONForTestResults(options, results_tracker) 398 _GenerateJSONForTestResults(options, results_tracker)
363 399
364 return result 400 return result
365 401
366 def main_win(options, args): 402 def main_win(options, args):
367 """Using the target build configuration, run the executable given in the 403 """Using the target build configuration, run the executable given in the
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 help='path to main build directory (the parent of ' 488 help='path to main build directory (the parent of '
453 'the Release or Debug directory)') 489 'the Release or Debug directory)')
454 option_parser.add_option('', '--enable-pageheap', action='store_true', 490 option_parser.add_option('', '--enable-pageheap', action='store_true',
455 default=False, 491 default=False,
456 help='enable pageheap checking for chrome.exe') 492 help='enable pageheap checking for chrome.exe')
457 # --with-httpd assumes a chromium checkout with src/tools/python. 493 # --with-httpd assumes a chromium checkout with src/tools/python.
458 option_parser.add_option('', '--with-httpd', dest='document_root', 494 option_parser.add_option('', '--with-httpd', dest='document_root',
459 default=None, metavar='DOC_ROOT', 495 default=None, metavar='DOC_ROOT',
460 help='Start a local httpd server using the given ' 496 help='Start a local httpd server using the given '
461 'document root, relative to the current dir') 497 'document root, relative to the current dir')
498 option_parser.add_option('', '--enable-wpr', action='store_true',
499 default=False,
500 help='Start the given Web Page Replay server using '
501 'the httpd document root as the archive root.')
462 option_parser.add_option('', '--total-shards', dest='total_shards', 502 option_parser.add_option('', '--total-shards', dest='total_shards',
463 default=None, type="int", 503 default=None, type="int",
464 help='Number of shards to split this test into.') 504 help='Number of shards to split this test into.')
465 option_parser.add_option('', '--shard-index', dest='shard_index', 505 option_parser.add_option('', '--shard-index', dest='shard_index',
466 default=None, type="int", 506 default=None, type="int",
467 help='Shard to run. Must be between 1 and ' 507 help='Shard to run. Must be between 1 and '
468 'total-shards.') 508 'total-shards.')
469 option_parser.add_option('', '--run-shell-script', action='store_true', 509 option_parser.add_option('', '--run-shell-script', action='store_true',
470 default=False, 510 default=False,
471 help='treat first argument as the shell script' 511 help='treat first argument as the shell script'
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 option_parser.add_option('--build-properties', action='callback', 556 option_parser.add_option('--build-properties', action='callback',
517 callback=chromium_utils.convert_json, type='string', 557 callback=chromium_utils.convert_json, type='string',
518 nargs=1, default={}, 558 nargs=1, default={},
519 help='build properties in JSON format') 559 help='build properties in JSON format')
520 option_parser.add_option('--factory-properties', action='callback', 560 option_parser.add_option('--factory-properties', action='callback',
521 callback=chromium_utils.convert_json, type='string', 561 callback=chromium_utils.convert_json, type='string',
522 nargs=1, default={}, 562 nargs=1, default={},
523 help='factory properties in JSON format') 563 help='factory properties in JSON format')
524 options, args = option_parser.parse_args() 564 options, args = option_parser.parse_args()
525 565
566 if options.enable_wpr and not options.document_root:
567 sys.stderr.write('--enable-wpr requires --with-httpd for the document root.' )
James Simonsen 2012/04/05 00:34:03 80 chars
568 return 1
526 if options.run_shell_script and options.run_python_script: 569 if options.run_shell_script and options.run_python_script:
527 sys.stderr.write('Use either --run-shell-script OR --run-python-script, ' 570 sys.stderr.write('Use either --run-shell-script OR --run-python-script, '
528 'not both.') 571 'not both.')
529 return 1 572 return 1
530 573
531 # Print out builder name for log_parser 574 # Print out builder name for log_parser
532 print '[Running on builder: "%s"]' % options.builder_name 575 print '[Running on builder: "%s"]' % options.builder_name
533 576
534 # Instruct GTK to use malloc while running ASAN tests. 577 # Instruct GTK to use malloc while running ASAN tests.
535 if options.factory_properties.get('asan', False): 578 if options.factory_properties.get('asan', False):
(...skipping 29 matching lines...) Expand all
565 '%d new files were left in %s: Fix the tests to clean up themselves.' 608 '%d new files were left in %s: Fix the tests to clean up themselves.'
566 ) % ((new_temp_files - temp_files), tempfile.gettempdir()) 609 ) % ((new_temp_files - temp_files), tempfile.gettempdir())
567 # TODO(maruel): Make it an error soon. Not yet since I want to iron out all 610 # TODO(maruel): Make it an error soon. Not yet since I want to iron out all
568 # the remaining cases before. 611 # the remaining cases before.
569 #result = 1 612 #result = 1
570 return result 613 return result
571 614
572 615
573 if '__main__' == __name__: 616 if '__main__' == __name__:
574 sys.exit(main()) 617 sys.exit(main())
OLDNEW
« no previous file with comments | « DEPS ('k') | scripts/slave/webpagereplay.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698