blob: e1e6aeb6121502fc18699b90506d44a3a1410030 [file] [log] [blame]
[email protected]19cbf132013-07-10 13:10:231#!/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]97b6b1e22013-08-21 17:05:116"""Run Manual Test Bisect Tool
7
8An example usage:
9tools/run-bisect-manual-test.py -g 201281 -b 201290
10
[email protected]fded4f72013-08-29 22:58:5011On Linux platform, follow the instructions in this document
mostynb7a126292015-12-28 14:19:3912https://chromium.googlesource.com/chromium/src/+/master/docs/linux_suid_sandbox_development.md
[email protected]fded4f72013-08-29 22:58:5013to setup the sandbox manually before running the script. Otherwise the script
14fails to launch Chrome and exits with an error.
15
[email protected]12a703a2014-07-25 19:03:1116This script serves a similar function to bisect-builds.py, except it uses
qyearsley62edbcf2014-09-26 01:19:3417the bisect_perf_regression.py. This means that that it can obtain builds of
18Chromium for revisions where builds aren't available in cloud storage.
[email protected]97b6b1e22013-08-21 17:05:1119"""
[email protected]19cbf132013-07-10 13:10:2320
21import os
22import subprocess
23import sys
24
25CROS_BOARD_ENV = 'BISECT_CROS_BOARD'
26CROS_IP_ENV = 'BISECT_CROS_IP'
qyearsley62edbcf2014-09-26 01:19:3427_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]19cbf132013-07-10 13:10:2330
eakuefnera5d5d3d62016-01-22 19:48:3331sys.path.append(os.path.join(_TOOLS_DIR, 'perf'))
32from chrome_telemetry_build import chromium_config
33sys.path.append(chromium_config.GetTelemetryDir())
wolenetz484640e2015-08-04 21:51:4834from telemetry.internal.browser import browser_options
[email protected]19cbf132013-07-10 13:10:2335
36
37def _RunBisectionScript(options):
qyearsley62edbcf2014-09-26 01:19:3438 """Attempts to execute the bisect script (bisect_perf_regression.py).
[email protected]19cbf132013-07-10 13:10:2339
40 Args:
41 options: The configuration options to pass to the bisect script.
42
43 Returns:
qyearsley62edbcf2014-09-26 01:19:3444 An exit code; 0 for success, 1 for failure.
[email protected]19cbf132013-07-10 13:10:2345 """
bcwhite6ad35b02015-04-30 13:17:0446 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]12a703a2014-07-25 19:03:1150 test_command = ('python %s --browser=%s --chrome-root=.' %
bcwhite6ad35b02015-04-30 13:17:0451 (abs_script_path, options.browser_type))
[email protected]19cbf132013-07-10 13:10:2352
qyearsley62edbcf2014-09-26 01:19:3453 cmd = ['python', _BISECT_SCRIPT_PATH,
[email protected]19cbf132013-07-10 13:10:2354 '-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',
bcwhite6ad35b02015-04-30 13:17:0461 '--no_custom_deps',
62 '--builder_type', options.builder_type]
[email protected]19cbf132013-07-10 13:10:2363
[email protected]128e3e9382014-06-18 15:23:0664 if options.extra_src:
65 cmd.extend(['--extra_src', options.extra_src])
66
[email protected]19cbf132013-07-10 13:10:2367 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]12a703a2014-07-25 19:03:1174 print ('Error: Cros build selected, but BISECT_CROS_IP or'
75 'BISECT_CROS_BOARD undefined.\n')
[email protected]19cbf132013-07-10 13:10:2376 return 1
bcwhite6ad35b02015-04-30 13:17:0477 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]128e3e9382014-06-18 15:23:0681 cmd.extend(['--target_platform', 'android-chrome'])
[email protected]19cbf132013-07-10 13:10:2382 elif 'android' in options.browser_type:
83 cmd.extend(['--target_platform', 'android'])
[email protected]128e3e9382014-06-18 15:23:0684 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
wolenetz80420e62014-10-29 18:57:4090 if options.goma_threads:
bcwhite6ad35b02015-04-30 13:17:0491 cmd.extend(['--use_goma', '--goma_threads', options.goma_threads])
wolenetz80420e62014-10-29 18:57:4092
[email protected]19cbf132013-07-10 13:10:2393 cmd = [str(c) for c in cmd]
94
95 return_code = subprocess.call(cmd)
96
97 if return_code:
qyearsley62edbcf2014-09-26 01:19:3498 print 'Error: bisect_perf_regression.py had exit code %d.' % return_code
[email protected]19cbf132013-07-10 13:10:2399 print
100
101 return return_code
102
103
104def main():
[email protected]12a703a2014-07-25 19:03:11105 """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]19cbf132013-07-10 13:10:23109 usage = ('%prog [options]\n'
110 'Used to run the bisection script with a manual test.')
111
[email protected]4177df532013-08-30 03:37:05112 options = browser_options.BrowserFinderOptions('release')
[email protected]19cbf132013-07-10 13:10:23113 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]97b6b1e22013-08-21 17:05:11127 default='..',
[email protected]19cbf132013-07-10 13:10:23128 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]128e3e9382014-06-18 15:23:06131 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',
wolenetz80420e62014-10-29 18:57:40136 type='choice',
137 choices=['Release', 'Debug'],
138 help='The target build type. Choices are "Release" '
139 'or "Debug".')
bcwhite6ad35b02015-04-30 13:17:04140 parser.add_option('--goma_threads', default=64,
wolenetz80420e62014-10-29 18:57:40141 type='int',
bcwhite6ad35b02015-04-30 13:17:04142 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]12a703a2014-07-25 19:03:11150 options, _ = parser.parse_args()
[email protected]19cbf132013-07-10 13:10:23151 error_msg = ''
[email protected]19cbf132013-07-10 13:10:23152 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]0d273862013-11-20 22:23:38162 if 'android' not in options.browser_type and sys.platform.startswith('linux'):
[email protected]fded4f72013-08-29 22:58:50163 if not os.environ.get('CHROME_DEVEL_SANDBOX'):
164 print 'SUID sandbox has not been setup.'\
mostynb7a126292015-12-28 14:19:39165 ' See https://chromium.googlesource.com/chromium/src/'\
166 '+/master/docs/linux_suid_sandbox_development.md.'
[email protected]fded4f72013-08-29 22:58:50167 return 1
168
[email protected]19cbf132013-07-10 13:10:23169 return _RunBisectionScript(options)
170
171
172if __name__ == '__main__':
173 sys.exit(main())