[email protected] | 19cbf13 | 2013-07-10 13:10:23 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | # Copyright 2013 The Chromium Authors. All rights reserved. |
| 3 | # Use of this source code is governed by a BSD-style license that can be |
| 4 | # found in the LICENSE file. |
| 5 | |
[email protected] | 97b6b1e2 | 2013-08-21 17:05:11 | [diff] [blame] | 6 | """Run Manual Test Bisect Tool |
| 7 | |
| 8 | An example usage: |
| 9 | tools/run-bisect-manual-test.py -g 201281 -b 201290 |
| 10 | |
[email protected] | fded4f7 | 2013-08-29 22:58:50 | [diff] [blame] | 11 | On Linux platform, follow the instructions in this document |
mostynb | 7a12629 | 2015-12-28 14:19:39 | [diff] [blame] | 12 | https://chromium.googlesource.com/chromium/src/+/master/docs/linux_suid_sandbox_development.md |
[email protected] | fded4f7 | 2013-08-29 22:58:50 | [diff] [blame] | 13 | to setup the sandbox manually before running the script. Otherwise the script |
| 14 | fails to launch Chrome and exits with an error. |
| 15 | |
[email protected] | 12a703a | 2014-07-25 19:03:11 | [diff] [blame] | 16 | This script serves a similar function to bisect-builds.py, except it uses |
qyearsley | 62edbcf | 2014-09-26 01:19:34 | [diff] [blame] | 17 | the bisect_perf_regression.py. This means that that it can obtain builds of |
| 18 | Chromium for revisions where builds aren't available in cloud storage. |
[email protected] | 97b6b1e2 | 2013-08-21 17:05:11 | [diff] [blame] | 19 | """ |
[email protected] | 19cbf13 | 2013-07-10 13:10:23 | [diff] [blame] | 20 | |
| 21 | import os |
| 22 | import subprocess |
| 23 | import sys |
| 24 | |
| 25 | CROS_BOARD_ENV = 'BISECT_CROS_BOARD' |
| 26 | CROS_IP_ENV = 'BISECT_CROS_IP' |
qyearsley | 62edbcf | 2014-09-26 01:19:34 | [diff] [blame] | 27 | _TOOLS_DIR = os.path.abspath(os.path.dirname(__file__)) |
| 28 | _BISECT_SCRIPT_PATH = os.path.join( |
| 29 | _TOOLS_DIR, 'auto_bisect', 'bisect_perf_regression.py') |
[email protected] | 19cbf13 | 2013-07-10 13:10:23 | [diff] [blame] | 30 | |
eakuefner | a5d5d3d6 | 2016-01-22 19:48:33 | [diff] [blame] | 31 | sys.path.append(os.path.join(_TOOLS_DIR, 'perf')) |
| 32 | from chrome_telemetry_build import chromium_config |
| 33 | sys.path.append(chromium_config.GetTelemetryDir()) |
wolenetz | 484640e | 2015-08-04 21:51:48 | [diff] [blame] | 34 | from telemetry.internal.browser import browser_options |
[email protected] | 19cbf13 | 2013-07-10 13:10:23 | [diff] [blame] | 35 | |
| 36 | |
| 37 | def _RunBisectionScript(options): |
qyearsley | 62edbcf | 2014-09-26 01:19:34 | [diff] [blame] | 38 | """Attempts to execute the bisect script (bisect_perf_regression.py). |
[email protected] | 19cbf13 | 2013-07-10 13:10:23 | [diff] [blame] | 39 | |
| 40 | Args: |
| 41 | options: The configuration options to pass to the bisect script. |
| 42 | |
| 43 | Returns: |
qyearsley | 62edbcf | 2014-09-26 01:19:34 | [diff] [blame] | 44 | An exit code; 0 for success, 1 for failure. |
[email protected] | 19cbf13 | 2013-07-10 13:10:23 | [diff] [blame] | 45 | """ |
bcwhite | 6ad35b0 | 2015-04-30 13:17:04 | [diff] [blame] | 46 | script_path = os.path.join(options.working_directory, |
| 47 | 'bisect', 'src', 'tools','bisect-manual-test.py') |
| 48 | abs_script_path = os.path.abspath(script_path) |
| 49 | |
[email protected] | 12a703a | 2014-07-25 19:03:11 | [diff] [blame] | 50 | test_command = ('python %s --browser=%s --chrome-root=.' % |
bcwhite | 6ad35b0 | 2015-04-30 13:17:04 | [diff] [blame] | 51 | (abs_script_path, options.browser_type)) |
[email protected] | 19cbf13 | 2013-07-10 13:10:23 | [diff] [blame] | 52 | |
qyearsley | 62edbcf | 2014-09-26 01:19:34 | [diff] [blame] | 53 | cmd = ['python', _BISECT_SCRIPT_PATH, |
[email protected] | 19cbf13 | 2013-07-10 13:10:23 | [diff] [blame] | 54 | '-c', test_command, |
| 55 | '-g', options.good_revision, |
| 56 | '-b', options.bad_revision, |
| 57 | '-m', 'manual_test/manual_test', |
| 58 | '-r', '1', |
| 59 | '--working_directory', options.working_directory, |
| 60 | '--build_preference', 'ninja', |
bcwhite | 6ad35b0 | 2015-04-30 13:17:04 | [diff] [blame] | 61 | '--no_custom_deps', |
| 62 | '--builder_type', options.builder_type] |
[email protected] | 19cbf13 | 2013-07-10 13:10:23 | [diff] [blame] | 63 | |
[email protected] | 128e3e938 | 2014-06-18 15:23:06 | [diff] [blame] | 64 | if options.extra_src: |
| 65 | cmd.extend(['--extra_src', options.extra_src]) |
| 66 | |
[email protected] | 19cbf13 | 2013-07-10 13:10:23 | [diff] [blame] | 67 | if 'cros' in options.browser_type: |
| 68 | cmd.extend(['--target_platform', 'cros']) |
| 69 | |
| 70 | if os.environ[CROS_BOARD_ENV] and os.environ[CROS_IP_ENV]: |
| 71 | cmd.extend(['--cros_board', os.environ[CROS_BOARD_ENV]]) |
| 72 | cmd.extend(['--cros_remote_ip', os.environ[CROS_IP_ENV]]) |
| 73 | else: |
[email protected] | 12a703a | 2014-07-25 19:03:11 | [diff] [blame] | 74 | print ('Error: Cros build selected, but BISECT_CROS_IP or' |
| 75 | 'BISECT_CROS_BOARD undefined.\n') |
[email protected] | 19cbf13 | 2013-07-10 13:10:23 | [diff] [blame] | 76 | return 1 |
bcwhite | 6ad35b0 | 2015-04-30 13:17:04 | [diff] [blame] | 77 | elif 'android-chrome' == options.browser_type: |
| 78 | if not options.extra_src: |
| 79 | print 'Error: Missing --extra_src to run bisect for android-chrome.' |
| 80 | sys.exit(-1) |
[email protected] | 128e3e938 | 2014-06-18 15:23:06 | [diff] [blame] | 81 | cmd.extend(['--target_platform', 'android-chrome']) |
[email protected] | 19cbf13 | 2013-07-10 13:10:23 | [diff] [blame] | 82 | elif 'android' in options.browser_type: |
| 83 | cmd.extend(['--target_platform', 'android']) |
[email protected] | 128e3e938 | 2014-06-18 15:23:06 | [diff] [blame] | 84 | elif not options.target_build_type: |
| 85 | cmd.extend(['--target_build_type', options.browser_type.title()]) |
| 86 | |
| 87 | if options.target_build_type: |
| 88 | cmd.extend(['--target_build_type', options.target_build_type]) |
| 89 | |
wolenetz | 80420e6 | 2014-10-29 18:57:40 | [diff] [blame] | 90 | if options.goma_threads: |
bcwhite | 6ad35b0 | 2015-04-30 13:17:04 | [diff] [blame] | 91 | cmd.extend(['--use_goma', '--goma_threads', options.goma_threads]) |
wolenetz | 80420e6 | 2014-10-29 18:57:40 | [diff] [blame] | 92 | |
[email protected] | 19cbf13 | 2013-07-10 13:10:23 | [diff] [blame] | 93 | cmd = [str(c) for c in cmd] |
| 94 | |
| 95 | return_code = subprocess.call(cmd) |
| 96 | |
| 97 | if return_code: |
qyearsley | 62edbcf | 2014-09-26 01:19:34 | [diff] [blame] | 98 | print 'Error: bisect_perf_regression.py had exit code %d.' % return_code |
[email protected] | 19cbf13 | 2013-07-10 13:10:23 | [diff] [blame] | 99 | print |
| 100 | |
| 101 | return return_code |
| 102 | |
| 103 | |
| 104 | def main(): |
[email protected] | 12a703a | 2014-07-25 19:03:11 | [diff] [blame] | 105 | """Does a bisect based on the command-line arguments passed in. |
| 106 | |
| 107 | The user will be prompted to classify each revision as good or bad. |
| 108 | """ |
[email protected] | 19cbf13 | 2013-07-10 13:10:23 | [diff] [blame] | 109 | usage = ('%prog [options]\n' |
| 110 | 'Used to run the bisection script with a manual test.') |
| 111 | |
[email protected] | 4177df53 | 2013-08-30 03:37:05 | [diff] [blame] | 112 | options = browser_options.BrowserFinderOptions('release') |
[email protected] | 19cbf13 | 2013-07-10 13:10:23 | [diff] [blame] | 113 | parser = options.CreateParser(usage) |
| 114 | |
| 115 | parser.add_option('-b', '--bad_revision', |
| 116 | type='str', |
| 117 | help='A bad revision to start bisection. ' + |
| 118 | 'Must be later than good revision. May be either a git' + |
| 119 | ' or svn revision.') |
| 120 | parser.add_option('-g', '--good_revision', |
| 121 | type='str', |
| 122 | help='A revision to start bisection where performance' + |
| 123 | ' test is known to pass. Must be earlier than the ' + |
| 124 | 'bad revision. May be either a git or svn revision.') |
| 125 | parser.add_option('-w', '--working_directory', |
| 126 | type='str', |
[email protected] | 97b6b1e2 | 2013-08-21 17:05:11 | [diff] [blame] | 127 | default='..', |
[email protected] | 19cbf13 | 2013-07-10 13:10:23 | [diff] [blame] | 128 | help='A working directory to supply to the bisection ' |
| 129 | 'script, which will use it as the location to checkout ' |
| 130 | 'a copy of the chromium depot.') |
[email protected] | 128e3e938 | 2014-06-18 15:23:06 | [diff] [blame] | 131 | parser.add_option('--extra_src', |
| 132 | type='str', |
| 133 | help='Path to extra source file. If this is supplied, ' |
| 134 | 'bisect script will use this to override default behavior.') |
| 135 | parser.add_option('--target_build_type', |
wolenetz | 80420e6 | 2014-10-29 18:57:40 | [diff] [blame] | 136 | type='choice', |
| 137 | choices=['Release', 'Debug'], |
| 138 | help='The target build type. Choices are "Release" ' |
| 139 | 'or "Debug".') |
bcwhite | 6ad35b0 | 2015-04-30 13:17:04 | [diff] [blame] | 140 | parser.add_option('--goma_threads', default=64, |
wolenetz | 80420e6 | 2014-10-29 18:57:40 | [diff] [blame] | 141 | type='int', |
bcwhite | 6ad35b0 | 2015-04-30 13:17:04 | [diff] [blame] | 142 | help='Number of goma threads to use. 0 will disable goma.') |
| 143 | parser.add_option('--builder_type', default='', |
| 144 | choices=['perf', |
| 145 | 'full', |
| 146 | 'android-chrome-perf', ''], |
| 147 | help='Type of builder to get build from. This allows ' |
| 148 | 'script to use cached builds. By default (empty), binaries ' |
| 149 | 'are built locally.') |
[email protected] | 12a703a | 2014-07-25 19:03:11 | [diff] [blame] | 150 | options, _ = parser.parse_args() |
[email protected] | 19cbf13 | 2013-07-10 13:10:23 | [diff] [blame] | 151 | error_msg = '' |
[email protected] | 19cbf13 | 2013-07-10 13:10:23 | [diff] [blame] | 152 | if not options.good_revision: |
| 153 | error_msg += 'Error: missing required parameter: --good_revision\n' |
| 154 | if not options.bad_revision: |
| 155 | error_msg += 'Error: missing required parameter: --bad_revision\n' |
| 156 | |
| 157 | if error_msg: |
| 158 | print error_msg |
| 159 | parser.print_help() |
| 160 | return 1 |
| 161 | |
[email protected] | 0d27386 | 2013-11-20 22:23:38 | [diff] [blame] | 162 | if 'android' not in options.browser_type and sys.platform.startswith('linux'): |
[email protected] | fded4f7 | 2013-08-29 22:58:50 | [diff] [blame] | 163 | if not os.environ.get('CHROME_DEVEL_SANDBOX'): |
| 164 | print 'SUID sandbox has not been setup.'\ |
mostynb | 7a12629 | 2015-12-28 14:19:39 | [diff] [blame] | 165 | ' See https://chromium.googlesource.com/chromium/src/'\ |
| 166 | '+/master/docs/linux_suid_sandbox_development.md.' |
[email protected] | fded4f7 | 2013-08-29 22:58:50 | [diff] [blame] | 167 | return 1 |
| 168 | |
[email protected] | 19cbf13 | 2013-07-10 13:10:23 | [diff] [blame] | 169 | return _RunBisectionScript(options) |
| 170 | |
| 171 | |
| 172 | if __name__ == '__main__': |
| 173 | sys.exit(main()) |