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']])
75 if config
['max_time_minutes']:
76 cmd
.extend(['--repeat_test_max_time', config
['max_time_minutes']])
79 cmd
.extend(['--build_preference', 'ninja'])
81 cmd
.extend(['--build_preference', 'make'])
85 path_to_goma
= os
.path
.abspath(path_to_goma
)
88 os
.environ
['CC'] = os
.path
.join(path_to_goma
, 'gomacc.exe') + ' cl.exe'
89 os
.environ
['CXX'] = os
.path
.join(path_to_goma
, 'gomacc.exe') + ' cl.exe'
90 goma_file
= os
.path
.join(path_to_goma
, 'goma_ctl.bat')
92 os
.environ
['PATH'] = os
.pathsep
.join([path_to_goma
, os
.environ
['PATH']])
93 goma_file
= os
.path
.join(path_to_goma
, 'goma_ctl.sh')
95 cmd
.append('--use_goma')
97 # Sometimes goma is lingering around if something went bad on a previous
98 # run. Stop it before starting a new process. Can ignore the return code
99 # since it will return an error if it wasn't running.
100 subprocess
.call([goma_file
, 'stop'])
102 return_code
= subprocess
.call([goma_file
, 'start'])
104 print 'Error: goma failed to start.'
108 cmd
= [str(c
) for c
in cmd
]
110 return_code
= subprocess
.call(cmd
)
113 subprocess
.call([goma_file
, 'stop'])
116 print 'Error: bisect-perf-regression.py returned with error %d' %\
125 usage
= ('%prog [options] [-- chromium-options]\n'
126 'Used by a trybot to run the bisection script using the parameters'
127 ' provided in the run-bisect-perf-regression.cfg file.')
129 parser
= optparse
.OptionParser(usage
=usage
)
130 parser
.add_option('-w', '--working_directory',
132 help='A working directory to supply to the bisection '
133 'script, which will use it as the location to checkout '
134 'a copy of the chromium depot.')
135 parser
.add_option('-p', '--path_to_goma',
137 help='Path to goma directory. If this is supplied, goma '
138 'builds will be enabled.')
139 (opts
, args
) = parser
.parse_args()
141 if not opts
.working_directory
:
142 print 'Error: missing required parameter: --working_directory'
147 path_to_file
= os
.path
.abspath(os
.path
.dirname(sys
.argv
[0]))
149 config
= LoadConfigFile(path_to_file
)
151 print 'Error: Could not load config file.'
155 return RunBisectionScript(config
, opts
.working_directory
, path_to_file
,
159 if __name__
== '__main__':