Support WebRTC in Android build toolchain
[chromium-blink-merge.git] / tools / run-bisect-manual-test.py
blob3b69358cb9145dcbc7937968dc3fa9211fd98e19
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.
6 """Run Manual Test Bisect Tool
8 An example usage:
9 tools/run-bisect-manual-test.py -g 201281 -b 201290
11 """
13 import os
14 import subprocess
15 import sys
17 CROS_BOARD_ENV = 'BISECT_CROS_BOARD'
18 CROS_IP_ENV = 'BISECT_CROS_IP'
19 _DIR_TOOLS_ROOT = os.path.abspath(os.path.dirname(__file__))
21 sys.path.append(os.path.join(_DIR_TOOLS_ROOT, 'telemetry'))
22 from telemetry.core import browser_options
25 def _RunBisectionScript(options):
26 """Attempts to execute src/tools/bisect-perf-regression.py with the parameters
27 passed in.
29 Args:
30 options: The configuration options to pass to the bisect script.
32 Returns:
33 0 on success, otherwise 1.
34 """
35 test_command = 'python %s --browser=%s --chrome-root=.' %\
36 (os.path.join(_DIR_TOOLS_ROOT, 'bisect-manual-test.py'),
37 options.browser_type)
39 cmd = ['python', os.path.join(_DIR_TOOLS_ROOT, 'bisect-perf-regression.py'),
40 '-c', test_command,
41 '-g', options.good_revision,
42 '-b', options.bad_revision,
43 '-m', 'manual_test/manual_test',
44 '-r', '1',
45 '--working_directory', options.working_directory,
46 '--build_preference', 'ninja',
47 '--use_goma',
48 '--no_custom_deps']
50 if 'cros' in options.browser_type:
51 cmd.extend(['--target_platform', 'cros'])
53 if os.environ[CROS_BOARD_ENV] and os.environ[CROS_IP_ENV]:
54 cmd.extend(['--cros_board', os.environ[CROS_BOARD_ENV]])
55 cmd.extend(['--cros_remote_ip', os.environ[CROS_IP_ENV]])
56 else:
57 print 'Error: Cros build selected, but BISECT_CROS_IP or'\
58 'BISECT_CROS_BOARD undefined.'
59 print
60 return 1
61 elif 'android' in options.browser_type:
62 cmd.extend(['--target_platform', 'android'])
64 cmd = [str(c) for c in cmd]
66 return_code = subprocess.call(cmd)
68 if return_code:
69 print 'Error: bisect-perf-regression.py returned with error %d' %\
70 return_code
71 print
73 return return_code
76 def main():
77 usage = ('%prog [options]\n'
78 'Used to run the bisection script with a manual test.')
80 options = browser_options.BrowserOptions('release')
81 parser = options.CreateParser(usage)
83 parser.add_option('-b', '--bad_revision',
84 type='str',
85 help='A bad revision to start bisection. ' +
86 'Must be later than good revision. May be either a git' +
87 ' or svn revision.')
88 parser.add_option('-g', '--good_revision',
89 type='str',
90 help='A revision to start bisection where performance' +
91 ' test is known to pass. Must be earlier than the ' +
92 'bad revision. May be either a git or svn revision.')
93 parser.add_option('-w', '--working_directory',
94 type='str',
95 default='..',
96 help='A working directory to supply to the bisection '
97 'script, which will use it as the location to checkout '
98 'a copy of the chromium depot.')
100 options, args = parser.parse_args()
101 error_msg = ''
102 if not options.good_revision:
103 error_msg += 'Error: missing required parameter: --good_revision\n'
104 if not options.bad_revision:
105 error_msg += 'Error: missing required parameter: --bad_revision\n'
107 if error_msg:
108 print error_msg
109 parser.print_help()
110 return 1
112 return _RunBisectionScript(options)
115 if __name__ == '__main__':
116 sys.exit(main())