| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 """ | 42 """ |
| 43 | 43 |
| 44 import datetime | 44 import datetime |
| 45 import logging | 45 import logging |
| 46 import os | 46 import os |
| 47 import pickle | 47 import pickle |
| 48 import sys | 48 import sys |
| 49 import threading | 49 import threading |
| 50 import time | 50 import time |
| 51 | 51 |
| 52 from pylib import cmd_helper |
| 52 from pylib import constants | 53 from pylib import constants |
| 53 from pylib import forwarder | 54 from pylib import forwarder |
| 54 from pylib import pexpect | |
| 55 from pylib.base import base_test_result | 55 from pylib.base import base_test_result |
| 56 from pylib.base import base_test_runner | 56 from pylib.base import base_test_runner |
| 57 | 57 |
| 58 | 58 |
| 59 def PrintTestOutput(test_name): | 59 def PrintTestOutput(test_name): |
| 60 """Helper method to print the output of previously executed test_name. | 60 """Helper method to print the output of previously executed test_name. |
| 61 | 61 |
| 62 Args: | 62 Args: |
| 63 test_name: name of the test that has been previously executed. | 63 test_name: name of the test that has been previously executed. |
| 64 | 64 |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 full_cmd = 'echo %s' % cmd | 193 full_cmd = 'echo %s' % cmd |
| 194 | 194 |
| 195 logfile = sys.stdout | 195 logfile = sys.stdout |
| 196 if self._options.single_step: | 196 if self._options.single_step: |
| 197 # Just print a heart-beat so that the outer buildbot scripts won't timeout | 197 # Just print a heart-beat so that the outer buildbot scripts won't timeout |
| 198 # without response. | 198 # without response. |
| 199 logfile = _HeartBeatLogger() | 199 logfile = _HeartBeatLogger() |
| 200 cwd = os.path.abspath(constants.DIR_SOURCE_ROOT) | 200 cwd = os.path.abspath(constants.DIR_SOURCE_ROOT) |
| 201 if full_cmd.startswith('src/'): | 201 if full_cmd.startswith('src/'): |
| 202 cwd = os.path.abspath(os.path.join(constants.DIR_SOURCE_ROOT, os.pardir)) | 202 cwd = os.path.abspath(os.path.join(constants.DIR_SOURCE_ROOT, os.pardir)) |
| 203 output, exit_code = pexpect.run( | 203 try: |
| 204 full_cmd, cwd=cwd, | 204 exit_code, output = cmd_helper.GetCmdStatusAndOutputWithTimeout( |
| 205 withexitstatus=True, logfile=logfile, timeout=timeout, | 205 full_cmd, timeout, cwd=cwd, shell=True, logfile=logfile) |
| 206 env=os.environ) | 206 finally: |
| 207 if self._options.single_step: | 207 if self._options.single_step: |
| 208 # Stop the logger. | 208 logfile.stop() |
| 209 logfile.stop() | |
| 210 end_time = datetime.datetime.now() | 209 end_time = datetime.datetime.now() |
| 211 if exit_code is None: | 210 if exit_code is None: |
| 212 exit_code = -1 | 211 exit_code = -1 |
| 213 logging.info('%s : exit_code=%d in %d secs at %s', | 212 logging.info('%s : exit_code=%d in %d secs at %s', |
| 214 test_name, exit_code, (end_time - start_time).seconds, | 213 test_name, exit_code, (end_time - start_time).seconds, |
| 215 self.device.old_interface.GetDevice()) | 214 self.device.old_interface.GetDevice()) |
| 216 result_type = base_test_result.ResultType.FAIL | 215 result_type = base_test_result.ResultType.FAIL |
| 217 if exit_code == 0: | 216 if exit_code == 0: |
| 218 result_type = base_test_result.ResultType.PASS | 217 result_type = base_test_result.ResultType.PASS |
| 219 actual_exit_code = exit_code | 218 actual_exit_code = exit_code |
| (...skipping 27 matching lines...) Expand all Loading... |
| 247 Returns: | 246 Returns: |
| 248 A tuple of (TestRunResults, retry). | 247 A tuple of (TestRunResults, retry). |
| 249 """ | 248 """ |
| 250 _, result_type = self._LaunchPerfTest(test_name) | 249 _, result_type = self._LaunchPerfTest(test_name) |
| 251 results = base_test_result.TestRunResults() | 250 results = base_test_result.TestRunResults() |
| 252 results.AddResult(base_test_result.BaseTestResult(test_name, result_type)) | 251 results.AddResult(base_test_result.BaseTestResult(test_name, result_type)) |
| 253 retry = None | 252 retry = None |
| 254 if not results.DidRunPass(): | 253 if not results.DidRunPass(): |
| 255 retry = test_name | 254 retry = test_name |
| 256 return results, retry | 255 return results, retry |
| OLD | NEW |