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