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
9 tools/run-bisect-manual-test.py -g 201281 -b 201290
11 On Linux platform, follow the instructions in this document
12 https://code.google.com/p/chromium/wiki/LinuxSUIDSandboxDevelopment
13 to setup the sandbox manually before running the script. Otherwise the script
14 fails to launch Chrome and exits with an error.
22 CROS_BOARD_ENV
= 'BISECT_CROS_BOARD'
23 CROS_IP_ENV
= 'BISECT_CROS_IP'
24 _DIR_TOOLS_ROOT
= os
.path
.abspath(os
.path
.dirname(__file__
))
26 sys
.path
.append(os
.path
.join(_DIR_TOOLS_ROOT
, 'telemetry'))
27 from telemetry
.core
import browser_options
30 def _RunBisectionScript(options
):
31 """Attempts to execute src/tools/bisect-perf-regression.py with the parameters
35 options: The configuration options to pass to the bisect script.
38 0 on success, otherwise 1.
40 test_command
= 'python %s --browser=%s --chrome-root=.' %\
41 (os
.path
.join(_DIR_TOOLS_ROOT
, 'bisect-manual-test.py'),
44 cmd
= ['python', os
.path
.join(_DIR_TOOLS_ROOT
, 'bisect-perf-regression.py'),
46 '-g', options
.good_revision
,
47 '-b', options
.bad_revision
,
48 '-m', 'manual_test/manual_test',
50 '--working_directory', options
.working_directory
,
51 '--build_preference', 'ninja',
56 cmd
.extend(['--extra_src', options
.extra_src
])
58 if 'cros' in options
.browser_type
:
59 cmd
.extend(['--target_platform', 'cros'])
61 if os
.environ
[CROS_BOARD_ENV
] and os
.environ
[CROS_IP_ENV
]:
62 cmd
.extend(['--cros_board', os
.environ
[CROS_BOARD_ENV
]])
63 cmd
.extend(['--cros_remote_ip', os
.environ
[CROS_IP_ENV
]])
65 print 'Error: Cros build selected, but BISECT_CROS_IP or'\
66 'BISECT_CROS_BOARD undefined.'
69 elif 'android-chrome' in options
.browser_type
:
70 cmd
.extend(['--target_platform', 'android-chrome'])
71 elif 'android' in options
.browser_type
:
72 cmd
.extend(['--target_platform', 'android'])
73 elif not options
.target_build_type
:
74 cmd
.extend(['--target_build_type', options
.browser_type
.title()])
76 if options
.target_build_type
:
77 cmd
.extend(['--target_build_type', options
.target_build_type
])
80 cmd
= [str(c
) for c
in cmd
]
82 return_code
= subprocess
.call(cmd
)
85 print 'Error: bisect-perf-regression.py returned with error %d' %\
93 usage
= ('%prog [options]\n'
94 'Used to run the bisection script with a manual test.')
96 options
= browser_options
.BrowserFinderOptions('release')
97 parser
= options
.CreateParser(usage
)
99 parser
.add_option('-b', '--bad_revision',
101 help='A bad revision to start bisection. ' +
102 'Must be later than good revision. May be either a git' +
104 parser
.add_option('-g', '--good_revision',
106 help='A revision to start bisection where performance' +
107 ' test is known to pass. Must be earlier than the ' +
108 'bad revision. May be either a git or svn revision.')
109 parser
.add_option('-w', '--working_directory',
112 help='A working directory to supply to the bisection '
113 'script, which will use it as the location to checkout '
114 'a copy of the chromium depot.')
115 parser
.add_option('--extra_src',
117 help='Path to extra source file. If this is supplied, '
118 'bisect script will use this to override default behavior.')
119 parser
.add_option('--target_build_type',
121 choices
=['Release', 'Debug'],
122 help='The target build type. Choices are "Release" '
124 options
, args
= parser
.parse_args()
126 if not options
.good_revision
:
127 error_msg
+= 'Error: missing required parameter: --good_revision\n'
128 if not options
.bad_revision
:
129 error_msg
+= 'Error: missing required parameter: --bad_revision\n'
136 if 'android' not in options
.browser_type
and sys
.platform
.startswith('linux'):
137 if not os
.environ
.get('CHROME_DEVEL_SANDBOX'):
138 print 'SUID sandbox has not been setup.'\
139 ' See https://code.google.com/p/chromium/wiki/'\
140 'LinuxSUIDSandboxDevelopment for more information.'
143 return _RunBisectionScript(options
)
146 if __name__
== '__main__':