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"""
12 CROS_BOARD_ENV
= 'BISECT_CROS_BOARD'
13 CROS_IP_ENV
= 'BISECT_CROS_IP'
14 _DIR_TOOLS_ROOT
= os
.path
.abspath(os
.path
.dirname(__file__
))
16 sys
.path
.append(os
.path
.join(_DIR_TOOLS_ROOT
, 'telemetry'))
17 from telemetry
.core
import browser_options
20 def _RunBisectionScript(options
):
21 """Attempts to execute src/tools/bisect-perf-regression.py with the parameters
25 options: The configuration options to pass to the bisect script.
28 0 on success, otherwise 1.
30 test_command
= 'python %s --browser=%s' %\
31 (os
.path
.join(_DIR_TOOLS_ROOT
, 'bisect-manual-test.py'),
34 cmd
= ['python', os
.path
.join(_DIR_TOOLS_ROOT
, 'bisect-perf-regression.py'),
36 '-g', options
.good_revision
,
37 '-b', options
.bad_revision
,
38 '-m', 'manual_test/manual_test',
40 '--working_directory', options
.working_directory
,
41 '--build_preference', 'ninja',
44 if 'cros' in options
.browser_type
:
45 cmd
.extend(['--target_platform', 'cros'])
47 if os
.environ
[CROS_BOARD_ENV
] and os
.environ
[CROS_IP_ENV
]:
48 cmd
.extend(['--cros_board', os
.environ
[CROS_BOARD_ENV
]])
49 cmd
.extend(['--cros_remote_ip', os
.environ
[CROS_IP_ENV
]])
51 print 'Error: Cros build selected, but BISECT_CROS_IP or'\
52 'BISECT_CROS_BOARD undefined.'
55 elif 'android' in options
.browser_type
:
56 cmd
.extend(['--target_platform', 'android'])
58 cmd
= [str(c
) for c
in cmd
]
60 return_code
= subprocess
.call(cmd
)
63 print 'Error: bisect-perf-regression.py returned with error %d' %\
71 usage
= ('%prog [options]\n'
72 'Used to run the bisection script with a manual test.')
74 options
= browser_options
.BrowserOptions()
75 parser
= options
.CreateParser(usage
)
77 parser
.add_option('-b', '--bad_revision',
79 help='A bad revision to start bisection. ' +
80 'Must be later than good revision. May be either a git' +
82 parser
.add_option('-g', '--good_revision',
84 help='A revision to start bisection where performance' +
85 ' test is known to pass. Must be earlier than the ' +
86 'bad revision. May be either a git or svn revision.')
87 parser
.add_option('-w', '--working_directory',
89 help='A working directory to supply to the bisection '
90 'script, which will use it as the location to checkout '
91 'a copy of the chromium depot.')
92 options
, args
= parser
.parse_args()
95 if not options
.browser_type
:
96 error_msg
+= 'Error: missing required parameter: --browser\n'
97 if not options
.working_directory
:
98 error_msg
+= 'Error: missing required parameter: --working_directory\n'
99 if not options
.good_revision
:
100 error_msg
+= 'Error: missing required parameter: --good_revision\n'
101 if not options
.bad_revision
:
102 error_msg
+= 'Error: missing required parameter: --bad_revision\n'
109 return _RunBisectionScript(options
)
112 if __name__
== '__main__':