OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Run Performance Test Bisect Tool | 6 """Run Performance Test Bisect Tool |
7 | 7 |
8 This script is used by a try bot to run the bisect script with the parameters | 8 This script is used by a try bot to run the bisect script with the parameters |
9 specified in the bisect config file. It checks out a copy of the depot in | 9 specified in the bisect config file. It checks out a copy of the depot in |
10 a subdirectory 'bisect' of the working directory provided, annd runs the | 10 a subdirectory 'bisect' of the working directory provided, annd runs the |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 local_vars = {} | 104 local_vars = {} |
105 execfile(config_file_path, local_vars) | 105 execfile(config_file_path, local_vars) |
106 return local_vars['config'] | 106 return local_vars['config'] |
107 except Exception: | 107 except Exception: |
108 print | 108 print |
109 traceback.print_exc() | 109 traceback.print_exc() |
110 print | 110 print |
111 return {} | 111 return {} |
112 | 112 |
113 | 113 |
114 def _ValidateConfigFile(config_contents, valid_parameters): | 114 def _ValidateConfigFile(config_contents, required_parameters): |
115 """Validates the config file contents, checking whether all values are | 115 """Validates the config file contents, checking whether all values are |
116 non-empty. | 116 non-empty. |
117 | 117 |
118 Args: | 118 Args: |
119 config_contents: A config dictionary. | 119 config_contents: A config dictionary. |
120 valid_parameters: A list of parameters to check for. | 120 required_parameters: A list of parameters to check for. |
121 | 121 |
122 Returns: | 122 Returns: |
123 True if valid. | 123 True if valid. |
124 """ | 124 """ |
125 for parameter in valid_parameters: | 125 for parameter in required_parameters: |
126 if parameter not in config_contents: | 126 if parameter not in config_contents: |
127 return False | 127 return False |
128 value = config_contents[parameter] | 128 value = config_contents[parameter] |
129 if not value or type(value) is not str: | 129 if not value or type(value) is not str: |
130 return False | 130 return False |
131 return True | 131 return True |
132 | 132 |
133 | 133 |
134 def _ValidatePerfConfigFile(config_contents): | 134 def _ValidatePerfConfigFile(config_contents): |
135 """Validates the perf config file contents. | 135 """Validates the perf config file contents. |
136 | 136 |
137 This is used when we're doing a perf try job, rather than a bisect. | 137 This is used when we're doing a perf try job, rather than a bisect. |
138 The config file is called run-perf-test.cfg by default. | 138 The config file is called run-perf-test.cfg by default. |
139 | 139 |
140 The parameters checked are the required parameters; any additional optional | 140 The parameters checked are the required parameters; any additional optional |
141 parameters won't be checked and validation will still pass. | 141 parameters won't be checked and validation will still pass. |
142 | 142 |
143 Args: | 143 Args: |
144 config_contents: A config dictionary. | 144 config_contents: A config dictionary. |
145 | 145 |
146 Returns: | 146 Returns: |
147 True if valid. | 147 True if valid. |
148 """ | 148 """ |
149 valid_parameters = [ | 149 required_parameters = [ |
150 'command', | 150 'command', |
151 'repeat_count', | 151 'repeat_count', |
152 'truncate_percent', | 152 'truncate_percent', |
153 'max_time_minutes', | 153 'max_time_minutes', |
154 ] | 154 ] |
155 return _ValidateConfigFile(config_contents, valid_parameters) | 155 return _ValidateConfigFile(config_contents, required_parameters) |
156 | 156 |
157 | 157 |
158 def _ValidateBisectConfigFile(config_contents): | 158 def _ValidateBisectConfigFile(config_contents): |
159 """Validates the bisect config file contents. | 159 """Validates the bisect config file contents. |
160 | 160 |
161 The parameters checked are the required parameters; any additional optional | 161 The parameters checked are the required parameters; any additional optional |
162 parameters won't be checked and validation will still pass. | 162 parameters won't be checked and validation will still pass. |
163 | 163 |
164 Args: | 164 Args: |
165 config_contents: A config dictionary. | 165 config_contents: A config dictionary. |
166 | 166 |
167 Returns: | 167 Returns: |
168 True if valid. | 168 True if valid. |
169 """ | 169 """ |
170 valid_params = [ | 170 required_params = [ |
171 'command', | 171 'command', |
172 'good_revision', | 172 'good_revision', |
173 'bad_revision', | 173 'bad_revision', |
174 'metric', | 174 'metric', |
175 'repeat_count', | 175 'repeat_count', |
176 'truncate_percent', | 176 'truncate_percent', |
177 'max_time_minutes', | 177 'max_time_minutes', |
178 ] | 178 ] |
179 return _ValidateConfigFile(config_contents, valid_params) | 179 return _ValidateConfigFile(config_contents, required_params) |
180 | 180 |
181 | 181 |
182 def _OutputFailedResults(text_to_print): | 182 def _OutputFailedResults(text_to_print): |
183 bisect_utils.OutputAnnotationStepStart('Results - Failed') | 183 bisect_utils.OutputAnnotationStepStart('Results - Failed') |
184 print | 184 print |
185 print text_to_print | 185 print text_to_print |
186 print | 186 print |
187 bisect_utils.OutputAnnotationStepClosed() | 187 bisect_utils.OutputAnnotationStepClosed() |
188 | 188 |
189 | 189 |
(...skipping 13 matching lines...) Expand all Loading... |
203 opts_dict['max_time_minutes'] = int(config['max_time_minutes']) | 203 opts_dict['max_time_minutes'] = int(config['max_time_minutes']) |
204 | 204 |
205 if config.has_key('use_goma'): | 205 if config.has_key('use_goma'): |
206 opts_dict['use_goma'] = config['use_goma'] | 206 opts_dict['use_goma'] = config['use_goma'] |
207 if config.has_key('goma_dir'): | 207 if config.has_key('goma_dir'): |
208 opts_dict['goma_dir'] = config['goma_dir'] | 208 opts_dict['goma_dir'] = config['goma_dir'] |
209 | 209 |
210 if config.has_key('improvement_direction'): | 210 if config.has_key('improvement_direction'): |
211 opts_dict['improvement_direction'] = int(config['improvement_direction']) | 211 opts_dict['improvement_direction'] = int(config['improvement_direction']) |
212 | 212 |
| 213 if config.has_key('bug_id') and str(config['bug_id']).isdigit(): |
| 214 opts_dict['bug_id'] = config['bug_id'] |
| 215 |
213 opts_dict['build_preference'] = 'ninja' | 216 opts_dict['build_preference'] = 'ninja' |
214 opts_dict['output_buildbot_annotations'] = True | 217 opts_dict['output_buildbot_annotations'] = True |
215 | 218 |
216 if '--browser=cros' in config['command']: | 219 if '--browser=cros' in config['command']: |
217 opts_dict['target_platform'] = 'cros' | 220 opts_dict['target_platform'] = 'cros' |
218 | 221 |
219 if os.environ[CROS_BOARD_ENV] and os.environ[CROS_IP_ENV]: | 222 if os.environ[CROS_BOARD_ENV] and os.environ[CROS_IP_ENV]: |
220 opts_dict['cros_board'] = os.environ[CROS_BOARD_ENV] | 223 opts_dict['cros_board'] = os.environ[CROS_BOARD_ENV] |
221 opts_dict['cros_remote_ip'] = os.environ[CROS_IP_ENV] | 224 opts_dict['cros_remote_ip'] = os.environ[CROS_IP_ENV] |
222 else: | 225 else: |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 | 405 |
403 if config['max_time_minutes']: | 406 if config['max_time_minutes']: |
404 cmd.extend(['--max_time_minutes', config['max_time_minutes']]) | 407 cmd.extend(['--max_time_minutes', config['max_time_minutes']]) |
405 | 408 |
406 if config.has_key('bisect_mode'): | 409 if config.has_key('bisect_mode'): |
407 cmd.extend(['--bisect_mode', config['bisect_mode']]) | 410 cmd.extend(['--bisect_mode', config['bisect_mode']]) |
408 | 411 |
409 if config.has_key('improvement_direction'): | 412 if config.has_key('improvement_direction'): |
410 cmd.extend(['-d', config['improvement_direction']]) | 413 cmd.extend(['-d', config['improvement_direction']]) |
411 | 414 |
| 415 if config.has_key('bug_id'): |
| 416 cmd.extend(['--bug_id', config['bug_id']]) |
| 417 |
412 cmd.extend(['--build_preference', 'ninja']) | 418 cmd.extend(['--build_preference', 'ninja']) |
413 | 419 |
414 if '--browser=cros' in config['command']: | 420 if '--browser=cros' in config['command']: |
415 cmd.extend(['--target_platform', 'cros']) | 421 cmd.extend(['--target_platform', 'cros']) |
416 | 422 |
417 if os.environ[CROS_BOARD_ENV] and os.environ[CROS_IP_ENV]: | 423 if os.environ[CROS_BOARD_ENV] and os.environ[CROS_IP_ENV]: |
418 cmd.extend(['--cros_board', os.environ[CROS_BOARD_ENV]]) | 424 cmd.extend(['--cros_board', os.environ[CROS_BOARD_ENV]]) |
419 cmd.extend(['--cros_remote_ip', os.environ[CROS_IP_ENV]]) | 425 cmd.extend(['--cros_remote_ip', os.environ[CROS_IP_ENV]]) |
420 else: | 426 else: |
421 print ('Error: Cros build selected, but BISECT_CROS_IP or' | 427 print ('Error: Cros build selected, but BISECT_CROS_IP or' |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
563 if config and config_is_valid: | 569 if config and config_is_valid: |
564 return _SetupAndRunPerformanceTest(config, opts.path_to_goma) | 570 return _SetupAndRunPerformanceTest(config, opts.path_to_goma) |
565 | 571 |
566 print ('Error: Could not load config file. Double check your changes to ' | 572 print ('Error: Could not load config file. Double check your changes to ' |
567 'auto_bisect/bisect.cfg or run-perf-test.cfg for syntax errors.\n') | 573 'auto_bisect/bisect.cfg or run-perf-test.cfg for syntax errors.\n') |
568 return 1 | 574 return 1 |
569 | 575 |
570 | 576 |
571 if __name__ == '__main__': | 577 if __name__ == '__main__': |
572 sys.exit(main()) | 578 sys.exit(main()) |
OLD | NEW |