| 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 a perf test on a single device. | 5 """Runs a perf test on a single device. |
| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 reset test server port allocation. | 43 reset test server port allocation. |
| 44 """ | 44 """ |
| 45 | 45 |
| 46 import datetime | 46 import datetime |
| 47 import logging | 47 import logging |
| 48 import pexpect | 48 import pexpect |
| 49 import pickle | 49 import pickle |
| 50 import os | 50 import os |
| 51 import sys | 51 import sys |
| 52 | 52 |
| 53 from pylib import android_commands |
| 53 from pylib import constants | 54 from pylib import constants |
| 55 from pylib import forwarder |
| 54 from pylib.base import base_test_result | 56 from pylib.base import base_test_result |
| 55 from pylib.base import base_test_runner | 57 from pylib.base import base_test_runner |
| 56 | 58 |
| 57 | 59 |
| 58 def PrintTestOutput(test_name): | 60 def PrintTestOutput(test_name): |
| 59 """Helper method to print the output of previously executed test_name. | 61 """Helper method to print the output of previously executed test_name. |
| 60 | 62 |
| 61 Args: | 63 Args: |
| 62 test_name: name of the test that has been previously executed. | 64 test_name: name of the test that has been previously executed. |
| 63 | 65 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 'name': test_name, | 148 'name': test_name, |
| 147 'output': output, | 149 'output': output, |
| 148 'exit_code': exit_code, | 150 'exit_code': exit_code, |
| 149 'result_type': result_type, | 151 'result_type': result_type, |
| 150 'total_time': (end_time - start_time).seconds, | 152 'total_time': (end_time - start_time).seconds, |
| 151 'device': self.device, | 153 'device': self.device, |
| 152 'cmd': cmd, | 154 'cmd': cmd, |
| 153 } | 155 } |
| 154 self._SaveResult(persisted_result) | 156 self._SaveResult(persisted_result) |
| 155 | 157 |
| 158 try: |
| 159 logging.warning('Unmapping device ports') |
| 160 forwarder.Forwarder.UnmapAllDevicePorts(self.adb) |
| 161 self.adb.KillAdbdDevice() |
| 162 except Exception as e: |
| 163 logging.error('Exception when tearing down device %s', e) |
| 164 |
| 156 return (output, result_type) | 165 return (output, result_type) |
| 157 | 166 |
| 158 def RunTest(self, test_name): | 167 def RunTest(self, test_name): |
| 159 """Run a perf test on the device. | 168 """Run a perf test on the device. |
| 160 | 169 |
| 161 Args: | 170 Args: |
| 162 test_name: String to use for logging the test result. | 171 test_name: String to use for logging the test result. |
| 163 | 172 |
| 164 Returns: | 173 Returns: |
| 165 A tuple of (TestRunResults, retry). | 174 A tuple of (TestRunResults, retry). |
| 166 """ | 175 """ |
| 167 output, result_type = self._LaunchPerfTest(test_name) | 176 output, result_type = self._LaunchPerfTest(test_name) |
| 168 results = base_test_result.TestRunResults() | 177 results = base_test_result.TestRunResults() |
| 169 results.AddResult(base_test_result.BaseTestResult(test_name, result_type)) | 178 results.AddResult(base_test_result.BaseTestResult(test_name, result_type)) |
| 170 retry = None | 179 retry = None |
| 171 if not results.DidRunPass(): | 180 if not results.DidRunPass(): |
| 172 retry = test_name | 181 retry = test_name |
| 173 return results, retry | 182 return results, retry |
| OLD | NEW |