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 | |
54 from pylib import constants | 53 from pylib import constants |
55 from pylib import forwarder | |
56 from pylib.base import base_test_result | 54 from pylib.base import base_test_result |
57 from pylib.base import base_test_runner | 55 from pylib.base import base_test_runner |
58 | 56 |
59 | 57 |
60 def PrintTestOutput(test_name): | 58 def PrintTestOutput(test_name): |
61 """Helper method to print the output of previously executed test_name. | 59 """Helper method to print the output of previously executed test_name. |
62 | 60 |
63 Args: | 61 Args: |
64 test_name: name of the test that has been previously executed. | 62 test_name: name of the test that has been previously executed. |
65 | 63 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 'name': test_name, | 146 'name': test_name, |
149 'output': output, | 147 'output': output, |
150 'exit_code': exit_code, | 148 'exit_code': exit_code, |
151 'result_type': result_type, | 149 'result_type': result_type, |
152 'total_time': (end_time - start_time).seconds, | 150 'total_time': (end_time - start_time).seconds, |
153 'device': self.device, | 151 'device': self.device, |
154 'cmd': cmd, | 152 'cmd': cmd, |
155 } | 153 } |
156 self._SaveResult(persisted_result) | 154 self._SaveResult(persisted_result) |
157 | 155 |
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 | |
165 return (output, result_type) | 156 return (output, result_type) |
166 | 157 |
167 def RunTest(self, test_name): | 158 def RunTest(self, test_name): |
168 """Run a perf test on the device. | 159 """Run a perf test on the device. |
169 | 160 |
170 Args: | 161 Args: |
171 test_name: String to use for logging the test result. | 162 test_name: String to use for logging the test result. |
172 | 163 |
173 Returns: | 164 Returns: |
174 A tuple of (TestRunResults, retry). | 165 A tuple of (TestRunResults, retry). |
175 """ | 166 """ |
176 output, result_type = self._LaunchPerfTest(test_name) | 167 output, result_type = self._LaunchPerfTest(test_name) |
177 results = base_test_result.TestRunResults() | 168 results = base_test_result.TestRunResults() |
178 results.AddResult(base_test_result.BaseTestResult(test_name, result_type)) | 169 results.AddResult(base_test_result.BaseTestResult(test_name, result_type)) |
179 retry = None | 170 retry = None |
180 if not results.DidRunPass(): | 171 if not results.DidRunPass(): |
181 retry = test_name | 172 retry = test_name |
182 return results, retry | 173 return results, retry |
OLD | NEW |