OLD | NEW |
1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """Runs perf tests. | 5 """Runs perf tests. |
6 | 6 |
7 Our buildbot infrastructure requires each slave to run steps serially. | 7 Our buildbot infrastructure requires each slave to run steps serially. |
8 This is sub-optimal for android, where these steps can run independently on | 8 This is sub-optimal for android, where these steps can run independently on |
9 multiple connected devices. | 9 multiple connected devices. |
10 | 10 |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 def _CleanupOutputDirectory(self): | 226 def _CleanupOutputDirectory(self): |
227 if self._output_dir: | 227 if self._output_dir: |
228 shutil.rmtree(self._output_dir, ignore_errors=True) | 228 shutil.rmtree(self._output_dir, ignore_errors=True) |
229 self._output_dir = None | 229 self._output_dir = None |
230 | 230 |
231 def _ReadChartjsonOutput(self): | 231 def _ReadChartjsonOutput(self): |
232 if not self._output_dir: | 232 if not self._output_dir: |
233 return '' | 233 return '' |
234 | 234 |
235 json_output_path = os.path.join(self._output_dir, 'results-chart.json') | 235 json_output_path = os.path.join(self._output_dir, 'results-chart.json') |
236 with open(json_output_path) as f: | 236 try: |
237 return f.read() | 237 with open(json_output_path) as f: |
| 238 return f.read() |
| 239 except IOError: |
| 240 logging.exception('Exception when reading chartjson.') |
| 241 logging.error('This usually means that telemetry did not run, so it could' |
| 242 ' not generate the file. Please check the device running' |
| 243 ' the test.') |
| 244 return '' |
238 | 245 |
239 def _LaunchPerfTest(self, test_name): | 246 def _LaunchPerfTest(self, test_name): |
240 """Runs a perf test. | 247 """Runs a perf test. |
241 | 248 |
242 Args: | 249 Args: |
243 test_name: the name of the test to be executed. | 250 test_name: the name of the test to be executed. |
244 | 251 |
245 Returns: | 252 Returns: |
246 A tuple containing (Output, base_test_result.ResultType) | 253 A tuple containing (Output, base_test_result.ResultType) |
247 """ | 254 """ |
(...skipping 11 matching lines...) Expand all Loading... |
259 (self._tests['steps'][test_name]['cmd'], | 266 (self._tests['steps'][test_name]['cmd'], |
260 self.device_serial)) | 267 self.device_serial)) |
261 | 268 |
262 if self._options.collect_chartjson_data: | 269 if self._options.collect_chartjson_data: |
263 self._output_dir = tempfile.mkdtemp() | 270 self._output_dir = tempfile.mkdtemp() |
264 cmd = cmd + ' --output-dir=%s' % self._output_dir | 271 cmd = cmd + ' --output-dir=%s' % self._output_dir |
265 | 272 |
266 logging.info( | 273 logging.info( |
267 'temperature: %s (0.1 C)', | 274 'temperature: %s (0.1 C)', |
268 str(self._device_battery.GetBatteryInfo().get('temperature'))) | 275 str(self._device_battery.GetBatteryInfo().get('temperature'))) |
| 276 if self._options.max_battery_temp: |
| 277 self._device_battery.LetBatteryCoolToTemperature( |
| 278 self._options.max_battery_temp) |
| 279 |
269 logging.info('%s : %s', test_name, cmd) | 280 logging.info('%s : %s', test_name, cmd) |
270 start_time = datetime.datetime.now() | 281 start_time = datetime.datetime.now() |
271 | 282 |
272 timeout = self._tests['steps'][test_name].get('timeout', 5400) | 283 timeout = self._tests['steps'][test_name].get('timeout', 5400) |
273 if self._options.no_timeout: | 284 if self._options.no_timeout: |
274 timeout = None | 285 timeout = None |
275 logging.info('Timeout for %s test: %s', test_name, timeout) | 286 logging.info('Timeout for %s test: %s', test_name, timeout) |
276 full_cmd = cmd | 287 full_cmd = cmd |
277 if self._options.dry_run: | 288 if self._options.dry_run: |
278 full_cmd = 'echo %s' % cmd | 289 full_cmd = 'echo %s' % cmd |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 Returns: | 359 Returns: |
349 A tuple of (TestRunResults, retry). | 360 A tuple of (TestRunResults, retry). |
350 """ | 361 """ |
351 _, result_type = self._LaunchPerfTest(test_name) | 362 _, result_type = self._LaunchPerfTest(test_name) |
352 results = base_test_result.TestRunResults() | 363 results = base_test_result.TestRunResults() |
353 results.AddResult(base_test_result.BaseTestResult(test_name, result_type)) | 364 results.AddResult(base_test_result.BaseTestResult(test_name, result_type)) |
354 retry = None | 365 retry = None |
355 if not results.DidRunPass(): | 366 if not results.DidRunPass(): |
356 retry = test_name | 367 retry = test_name |
357 return results, retry | 368 return results, retry |
OLD | NEW |