Chromium Code Reviews| Index: scripts/slave/runtest.py |
| =================================================================== |
| --- scripts/slave/runtest.py (revision 122337) |
| +++ scripts/slave/runtest.py (working copy) |
| @@ -37,6 +37,7 @@ |
| from common import chromium_utils |
| from slave import gtest_slave_utils |
| from slave import slave_utils |
| +from slave import webpagereplay |
| from slave import xvfb |
| import config |
| @@ -171,6 +172,27 @@ |
| (e, output_dir)) |
| return http_server |
| +def start_wpr_server(platform, build_dir, test_exe_path, data_dir, |
|
James Simonsen
2012/04/05 00:34:03
platform is unused.
|
| + wpr_dir=None): |
| + """Start Web Page Replay server. |
| + |
| + WPR makes it easy to record all the resources for a web page and serve |
| + that page with a simulated network. |
| + """ |
| + # Name the output directory for the exe, without its path or suffix. |
| + # e.g., chrome-release/httpd_logs/unit_tests/ |
| + test_exe_name = os.path.splitext(os.path.basename(test_exe_path))[0] |
| + output_dir = os.path.join(slave_utils.SlaveBaseDir(build_dir), |
| + 'webpagereplay_logs', |
| + test_exe_name) |
| + if wpr_dir is None: |
| + wpr_dir = os.path.abspath(os.path.join( |
| + __file__, '..', '..', '..', 'third_party', 'webpagereplay')) |
| + data_dir = os.path.abspath(data_dir) |
| + wpr_server = webpagereplay.ReplayLauncher(wpr_dir, data_dir, output_dir) |
| + wpr_server.StartServer() |
| + return wpr_server |
| + |
| def main_mac(options, args): |
| if len(args) < 1: |
| raise chromium_utils.MissingArgument('Usage: %s' % USAGE) |
| @@ -230,14 +252,21 @@ |
| try: |
| http_server = None |
| + webpagereplay_server = None |
| if options.document_root: |
| http_server = start_http_server('mac', build_dir=build_dir, |
| test_exe_path=test_exe_path, |
| document_root=options.document_root) |
| + if options.enable_wpr: |
| + webpagereplay_server = start_wpr_server( |
| + 'mac', build_dir=build_dir, test_exe_path=test_exe_path, |
| + data_dir=os.path.join(options.document_root, 'webpagereplay')) |
| result = _RunGTestCommand(command, results_tracker) |
| finally: |
| if http_server: |
| http_server.StopServer() |
| + if webpagereplay_server: |
| + webpagereplay_server.StopServer() |
| if options.generate_json_file: |
| _GenerateJSONForTestResults(options, results_tracker) |
| @@ -336,10 +365,15 @@ |
| try: |
| http_server = None |
| + webpagereplay_server = None |
| if options.document_root: |
| http_server = start_http_server('linux', build_dir=build_dir, |
| test_exe_path=test_exe_path, |
| document_root=options.document_root) |
| + if options.enable_wpr: |
| + webpagereplay_server = start_wpr_server( |
| + 'linux', build_dir=build_dir, test_exe_path=test_exe_path, |
| + data_dir=os.path.join(options.document_root, 'webpagereplay')) |
| if options.xvfb: |
| xvfb.StartVirtualX( |
| slave_name, bin_dir, |
| @@ -355,6 +389,8 @@ |
| finally: |
| if http_server: |
| http_server.StopServer() |
| + if webpagereplay_server: |
| + webpagereplay_server.StopServer() |
| if options.xvfb: |
| xvfb.StopVirtualX(slave_name) |
| @@ -459,6 +495,10 @@ |
| default=None, metavar='DOC_ROOT', |
| help='Start a local httpd server using the given ' |
| 'document root, relative to the current dir') |
| + option_parser.add_option('', '--enable-wpr', action='store_true', |
| + default=False, |
| + help='Start the given Web Page Replay server using ' |
| + 'the httpd document root as the archive root.') |
| option_parser.add_option('', '--total-shards', dest='total_shards', |
| default=None, type="int", |
| help='Number of shards to split this test into.') |
| @@ -523,6 +563,9 @@ |
| help='factory properties in JSON format') |
| options, args = option_parser.parse_args() |
| + if options.enable_wpr and not options.document_root: |
| + sys.stderr.write('--enable-wpr requires --with-httpd for the document root.') |
|
James Simonsen
2012/04/05 00:34:03
80 chars
|
| + return 1 |
| if options.run_shell_script and options.run_python_script: |
| sys.stderr.write('Use either --run-shell-script OR --run-python-script, ' |
| 'not both.') |