| 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 """Set up and invoke telemetry tests.""" | 6 """Set up and invoke telemetry tests.""" |
| 7 | 7 |
| 8 import json | 8 import json |
| 9 import optparse | 9 import optparse |
| 10 import os | 10 import os |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 | 70 |
| 71 test_specification = [test_name] | 71 test_specification = [test_name] |
| 72 | 72 |
| 73 env = os.environ | 73 env = os.environ |
| 74 | 74 |
| 75 # List of command line arguments common to all test platforms. | 75 # List of command line arguments common to all test platforms. |
| 76 common_args = [ | 76 common_args = [ |
| 77 # INFO level verbosity. | 77 # INFO level verbosity. |
| 78 '-v', | 78 '-v', |
| 79 # Output results in the format the buildbot expects. | 79 # Output results in the format the buildbot expects. |
| 80 '--output-format=buildbot', | 80 '--output-format', |
| 81 'chartjson' |
| 81 ] | 82 ] |
| 82 | 83 |
| 83 if profile_type: | 84 if profile_type: |
| 84 profile_dir = os.path.join( | 85 profile_dir = os.path.join( |
| 85 build_dir, target, 'generated_profile', profile_type) | 86 build_dir, target, 'generated_profile', profile_type) |
| 86 common_args.append('--profile-dir=' + profile_dir) | 87 common_args.append('--profile-dir=' + profile_dir) |
| 87 if extra_args: | 88 if extra_args: |
| 88 common_args.extend(extra_args) | 89 common_args.extend(extra_args) |
| 89 | 90 |
| 90 commands = [] | 91 commands = [] |
| (...skipping 10 matching lines...) Expand all Loading... |
| 101 '--'] | 102 '--'] |
| 102 # If an executable is passed, use that instead. | 103 # If an executable is passed, use that instead. |
| 103 if browser_exe: | 104 if browser_exe: |
| 104 browser_info = ['--browser=exact', | 105 browser_info = ['--browser=exact', |
| 105 '--browser-executable=%s' % browser_exe] | 106 '--browser-executable=%s' % browser_exe] |
| 106 else: | 107 else: |
| 107 browser_info = ['--browser=%s' % browser] | 108 browser_info = ['--browser=%s' % browser] |
| 108 test_args = list(common_args) | 109 test_args = list(common_args) |
| 109 test_args.extend(browser_info) | 110 test_args.extend(browser_info) |
| 110 test_args.extend(test_specification) | 111 test_args.extend(test_specification) |
| 112 test_args.extend(['--output', options.chart_output_filename]) |
| 111 test_cmd = _GetPythonTestCommand(script, target, test_args, | 113 test_cmd = _GetPythonTestCommand(script, target, test_args, |
| 112 wrapper_args=wrapper_args, fp=fp) | 114 wrapper_args=wrapper_args, fp=fp) |
| 113 commands.append(test_cmd) | 115 commands.append(test_cmd) |
| 114 | 116 |
| 115 # Run the test against the target chrome build for different user profiles on | 117 # Run the test against the target chrome build for different user profiles on |
| 116 # certain page cyclers. | 118 # certain page cyclers. |
| 117 if target_os != 'android': | 119 if target_os != 'android': |
| 118 if test_name in ('page_cycler_moz', 'page_cycler_morejs'): | 120 if test_name in ('page_cycler_moz', 'page_cycler_morejs'): |
| 119 test_args = list(common_args) | 121 test_args = list(common_args) |
| 120 test_args.extend(['--profile-type=typical_user', | 122 test_args.extend(['--profile-type=typical_user', |
| (...skipping 13 matching lines...) Expand all Loading... |
| 134 | 136 |
| 135 # Run the test against the reference build on platforms where it exists. | 137 # Run the test against the reference build on platforms where it exists. |
| 136 ref_build = _GetReferenceBuildPath(target_os, target_platform) | 138 ref_build = _GetReferenceBuildPath(target_os, target_platform) |
| 137 ref_build = fp.get('reference_build_executable', ref_build) | 139 ref_build = fp.get('reference_build_executable', ref_build) |
| 138 if ref_build and fp.get('run_reference_build', True): | 140 if ref_build and fp.get('run_reference_build', True): |
| 139 ref_args = list(common_args) | 141 ref_args = list(common_args) |
| 140 ref_args.extend(['--browser=exact', | 142 ref_args.extend(['--browser=exact', |
| 141 '--browser-executable=%s' % ref_build, | 143 '--browser-executable=%s' % ref_build, |
| 142 '--output-trace-tag=_ref']) | 144 '--output-trace-tag=_ref']) |
| 143 ref_args.extend(test_specification) | 145 ref_args.extend(test_specification) |
| 146 ref_args.extend(['--output', options.ref_output_filename]) |
| 144 ref_cmd = _GetPythonTestCommand(script, target, ref_args, fp=fp) | 147 ref_cmd = _GetPythonTestCommand(script, target, ref_args, fp=fp) |
| 145 commands.append(ref_cmd) | 148 commands.append(ref_cmd) |
| 146 | 149 |
| 147 return commands, env | 150 return commands, env |
| 148 | 151 |
| 149 | 152 |
| 150 def main(argv): | 153 def main(argv): |
| 151 prog_desc = 'Invoke telemetry performance tests.' | 154 prog_desc = 'Invoke telemetry performance tests.' |
| 152 parser = optparse.OptionParser(usage=('%prog [options]' + '\n\n' + prog_desc)) | 155 parser = optparse.OptionParser(usage=('%prog [options]' + '\n\n' + prog_desc)) |
| 153 parser.add_option('--print-cmd', action='store_true', | 156 parser.add_option('--print-cmd', action='store_true', |
| 154 help='only print command instead of running it') | 157 help='only print command instead of running it') |
| 155 parser.add_option('--target-android-browser', | 158 parser.add_option('--target-android-browser', |
| 156 default='android-chrome-shell', | 159 default='android-chrome-shell', |
| 157 help='target browser used on Android') | 160 help='target browser used on Android') |
| 158 parser.add_option('--factory-properties', action='callback', | 161 parser.add_option('--factory-properties', action='callback', |
| 159 callback=chromium_utils.convert_json, type='string', | 162 callback=chromium_utils.convert_json, type='string', |
| 160 nargs=1, default={}, | 163 nargs=1, default={}, |
| 161 help='factory properties in JSON format') | 164 help='factory properties in JSON format') |
| 165 parser.add_option('--chart-output-filename', |
| 166 help='file to save telemetry test output') |
| 167 parser.add_option('--ref-output-filename', |
| 168 help='file to save reference telemetry test output') |
| 162 | 169 |
| 163 options, _ = parser.parse_args(argv[1:]) | 170 options, _ = parser.parse_args(argv[1:]) |
| 164 if not options.factory_properties: | 171 if not options.factory_properties: |
| 165 print 'This program requires a factory properties to run.' | 172 print 'This program requires a factory properties to run.' |
| 166 return 1 | 173 return 1 |
| 167 | 174 |
| 168 commands, env = _GenerateTelemetryCommandSequence(options) | 175 commands, env = _GenerateTelemetryCommandSequence(options) |
| 169 | 176 |
| 170 retval = 0 | 177 retval = 0 |
| 171 for command in commands: | 178 for command in commands: |
| 172 if options.print_cmd: | 179 if options.print_cmd: |
| 173 print ' '.join("'%s'" % c for c in command) | 180 print ' '.join("'%s'" % c for c in command) |
| 174 continue | 181 continue |
| 175 | 182 |
| 176 retval = chromium_utils.RunCommand(command, env=env) | 183 retval = chromium_utils.RunCommand(command, env=env) |
| 177 if retval != 0: | 184 if retval != 0: |
| 178 break | 185 break |
| 179 return retval | 186 return retval |
| 180 | 187 |
| 181 | 188 |
| 182 if '__main__' == __name__: | 189 if '__main__' == __name__: |
| 183 sys.exit(main(sys.argv)) | 190 sys.exit(main(sys.argv)) |
| OLD | NEW |