2 # Copyright (c) 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 Performance Test Bisect Tool
8 This script is used by a trybot to run the src/tools/bisect-perf-regression.py
9 script with the parameters specified in run-bisect-perf-regression.cfg. It will
10 check out a copy of the depot in a subdirectory 'bisect' of the working
11 directory provided, and run the bisect-perf-regression.py script there.
22 def LoadConfigFile(path_to_file
):
23 """Attempts to load the file 'run-bisect-perf-regression.cfg' as a module
24 and grab the global config dict.
27 path_to_file: Path to the run-bisect-perf-regression.cfg file.
30 The config dict which should be formatted as follows:
31 {'command': string, 'good_revision': string, 'bad_revision': string
33 Returns None on failure.
37 execfile(os
.path
.join(path_to_file
, 'run-bisect-perf-regression.cfg'),
40 return local_vars
['config']
45 def RunBisectionScript(config
, working_directory
, path_to_file
, path_to_goma
):
46 """Attempts to execute src/tools/bisect-perf-regression.py with the parameters
50 config: A dict containing the parameters to pass to the script.
51 working_directory: A working directory to provide to the
52 bisect-perf-regression.py script, where it will store it's own copy of
54 path_to_file: Path to the bisect-perf-regression.py script.
55 path_to_goma: Path to goma directory.
58 0 on success, otherwise 1.
61 cmd
= ['python', os
.path
.join(path_to_file
, 'bisect-perf-regression.py'),
62 '-c', config
['command'],
63 '-g', config
['good_revision'],
64 '-b', config
['bad_revision'],
65 '-m', config
['metric'],
66 '--working_directory', working_directory
,
67 '--output_buildbot_annotations']
69 if config
['repeat_count']:
70 cmd
.extend(['-r', config
['repeat_count']])
72 if config
['truncate_percent']:
73 cmd
.extend(['-t', config
['truncate_percent']])
77 path_to_goma
= os
.path
.abspath(path_to_goma
)
80 os
.environ
['CC'] = os
.path
.join(path_to_goma
, 'gomacc.exe') + ' cl.exe'
81 os
.environ
['CXX'] = os
.path
.join(path_to_goma
, 'gomacc.exe') + ' cl.exe'
82 goma_file
= os
.path
.join(path_to_goma
, 'goma_ctl.bat')
84 os
.environ
['PATH'] = os
.pathsep
.join([path_to_goma
, os
.environ
['PATH']])
85 goma_file
= os
.path
.join(path_to_goma
, 'goma_ctl.sh')
87 cmd
.append('--use_goma')
89 return_code
= subprocess
.call([goma_file
, 'start'])
91 print 'Error: goma failed to start.'
95 return_code
= subprocess
.call(cmd
)
98 subprocess
.call([goma_file
, 'stop'])
101 print 'Error: bisect-perf-regression.py returned with error %d' %\
110 usage
= ('%prog [options] [-- chromium-options]\n'
111 'Used by a trybot to run the bisection script using the parameters'
112 ' provided in the run-bisect-perf-regression.cfg file.')
114 parser
= optparse
.OptionParser(usage
=usage
)
115 parser
.add_option('-w', '--working_directory',
117 help='A working directory to supply to the bisection '
118 'script, which will use it as the location to checkout '
119 'a copy of the chromium depot.')
120 parser
.add_option('-p', '--path_to_goma',
122 help='Path to goma directory. If this is supplied, goma '
123 'builds will be enabled.')
124 (opts
, args
) = parser
.parse_args()
126 if not opts
.working_directory
:
127 print 'Error: missing required parameter: --working_directory'
132 path_to_file
= os
.path
.abspath(os
.path
.dirname(sys
.argv
[0]))
134 config
= LoadConfigFile(path_to_file
)
136 print 'Error: Could not load config file.'
140 return RunBisectionScript(config
, opts
.working_directory
, path_to_file
,
144 if __name__
== '__main__':