OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/env python |
| 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. |
| 5 |
| 6 """Run Performance Test Bisect Tool |
| 7 |
| 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. |
| 12 |
| 13 """ |
| 14 |
| 15 import imp |
| 16 import optparse |
| 17 import os |
| 18 import subprocess |
| 19 import sys |
| 20 |
| 21 |
| 22 def LoadConfigFile(): |
| 23 """Attempts to load the file 'run-bisect-perf-regression.cfg' as a module |
| 24 and grab the global config dict. |
| 25 |
| 26 Returns: |
| 27 The config dict which should be formatted as follows: |
| 28 {'command': string, 'good_revision': string, 'bad_revision': string |
| 29 'metric': string}. |
| 30 Returns None on failure. |
| 31 """ |
| 32 try: |
| 33 local_vars = {} |
| 34 execfile('run-bisect-perf-regression.cfg', local_vars) |
| 35 |
| 36 return local_vars['config'] |
| 37 except: |
| 38 return None |
| 39 |
| 40 |
| 41 def RunBisectionScript(config, working_directory): |
| 42 """Attempts to execute src/tools/bisect-perf-regression.py with the parameters |
| 43 passed in. |
| 44 |
| 45 Args: |
| 46 config: A dict containing the parameters to pass to the script. |
| 47 |
| 48 Returns: |
| 49 0 on success, otherwise 1. |
| 50 """ |
| 51 |
| 52 cmd = ['python', 'bisect-perf-regression.py', |
| 53 '-c', config['command'], |
| 54 '-g', config['good_revision'], |
| 55 '-b', config['bad_revision'], |
| 56 '-m', config['metric'], |
| 57 '--working_directory', working_directory, |
| 58 '--output_buildbot_annotations'] |
| 59 |
| 60 return_code = subprocess.call(cmd) |
| 61 |
| 62 if return_code: |
| 63 print 'Error: bisect-perf-regression.py returned with error %d' %\ |
| 64 return_code |
| 65 print |
| 66 |
| 67 return return_code |
| 68 |
| 69 |
| 70 def main(): |
| 71 |
| 72 usage = ('%prog [options] [-- chromium-options]\n' |
| 73 'Used by a trybot to run the bisection script using the parameters' |
| 74 ' provided in the run-bisect-perf-regression.cfg file.') |
| 75 |
| 76 parser = optparse.OptionParser(usage=usage) |
| 77 parser.add_option('-w', '--working_directory', |
| 78 type='str', |
| 79 help='A working directory to supply to the bisection ' |
| 80 'script, which will use it as the location to checkout ' |
| 81 'a copy of the chromium depot.') |
| 82 (opts, args) = parser.parse_args() |
| 83 |
| 84 if not opts.working_directory: |
| 85 print 'Error: missing required parameter: --working_directory' |
| 86 print |
| 87 parser.print_help() |
| 88 return 1 |
| 89 |
| 90 config = LoadConfigFile() |
| 91 if not config: |
| 92 print 'Error: Could not load config file.' |
| 93 print |
| 94 return 1 |
| 95 |
| 96 return RunBisectionScript(config, opts.working_directory) |
| 97 |
| 98 |
| 99 if __name__ == '__main__': |
| 100 sys.exit(main()) |
OLD | NEW |