| OLD | NEW |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 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 import logging | 5 import logging |
| 6 import re | 6 import re |
| 7 import time | 7 import time |
| 8 | 8 |
| 9 from devil.android import device_errors | 9 from devil.android import device_errors |
| 10 from devil.android.sdk import keyevent | |
| 11 from pylib import flag_changer | 10 from pylib import flag_changer |
| 12 from pylib.base import base_test_result | 11 from pylib.base import base_test_result |
| 13 from pylib.base import test_run | |
| 14 from pylib.local.device import local_device_test_run | 12 from pylib.local.device import local_device_test_run |
| 15 | 13 |
| 16 | 14 |
| 17 TIMEOUT_ANNOTATIONS = [ | 15 TIMEOUT_ANNOTATIONS = [ |
| 18 ('Manual', 10 * 60 * 60), | 16 ('Manual', 10 * 60 * 60), |
| 19 ('IntegrationTest', 30 * 60), | 17 ('IntegrationTest', 30 * 60), |
| 20 ('External', 10 * 60), | 18 ('External', 10 * 60), |
| 21 ('EnormousTest', 10 * 60), | 19 ('EnormousTest', 10 * 60), |
| 22 ('LargeTest', 5 * 60), | 20 ('LargeTest', 5 * 60), |
| 23 ('MediumTest', 3 * 60), | 21 ('MediumTest', 3 * 60), |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 self._test_instance.GetDriverEnvironmentVars( | 134 self._test_instance.GetDriverEnvironmentVars( |
| 137 test_list=test_names)) | 135 test_list=test_names)) |
| 138 timeout = sum(timeouts) | 136 timeout = sum(timeouts) |
| 139 else: | 137 else: |
| 140 test_name = self._GetTestName(test) | 138 test_name = self._GetTestName(test) |
| 141 target = '%s/%s' % ( | 139 target = '%s/%s' % ( |
| 142 self._test_instance.test_package, self._test_instance.test_runner) | 140 self._test_instance.test_package, self._test_instance.test_runner) |
| 143 extras['class'] = test_name | 141 extras['class'] = test_name |
| 144 timeout = self._GetTimeoutFromAnnotations(test['annotations'], test_name) | 142 timeout = self._GetTimeoutFromAnnotations(test['annotations'], test_name) |
| 145 | 143 |
| 146 logging.info('preparing to run %s: %s' % (test_name, test)) | 144 logging.info('preparing to run %s: %s', test_name, test) |
| 147 | 145 |
| 148 time_ms = lambda: int(time.time() * 1e3) | 146 time_ms = lambda: int(time.time() * 1e3) |
| 149 start_ms = time_ms() | 147 start_ms = time_ms() |
| 150 output = device.StartInstrumentation( | 148 output = device.StartInstrumentation( |
| 151 target, raw=True, extras=extras, timeout=timeout, retries=0) | 149 target, raw=True, extras=extras, timeout=timeout, retries=0) |
| 152 duration_ms = time_ms() - start_ms | 150 duration_ms = time_ms() - start_ms |
| 153 | 151 |
| 154 # TODO(jbudorick): Make instrumentation tests output a JSON so this | 152 # TODO(jbudorick): Make instrumentation tests output a JSON so this |
| 155 # doesn't have to parse the output. | 153 # doesn't have to parse the output. |
| 156 logging.debug('output from %s:', test_name) | 154 logging.debug('output from %s:', test_name) |
| (...skipping 12 matching lines...) Expand all Loading... |
| 169 | 167 |
| 170 #override | 168 #override |
| 171 def _ShouldShard(self): | 169 def _ShouldShard(self): |
| 172 return True | 170 return True |
| 173 | 171 |
| 174 @staticmethod | 172 @staticmethod |
| 175 def _GetTimeoutFromAnnotations(annotations, test_name): | 173 def _GetTimeoutFromAnnotations(annotations, test_name): |
| 176 for k, v in TIMEOUT_ANNOTATIONS: | 174 for k, v in TIMEOUT_ANNOTATIONS: |
| 177 if k in annotations: | 175 if k in annotations: |
| 178 timeout = v | 176 timeout = v |
| 177 break |
| 179 else: | 178 else: |
| 180 logging.warning('Using default 1 minute timeout for %s' % test_name) | 179 logging.warning('Using default 1 minute timeout for %s', test_name) |
| 181 timeout = 60 | 180 timeout = 60 |
| 182 | 181 |
| 183 try: | 182 try: |
| 184 scale = int(annotations.get('TimeoutScale', 1)) | 183 scale = int(annotations.get('TimeoutScale', 1)) |
| 185 except ValueError as e: | 184 except ValueError as e: |
| 186 logging.warning("Non-integer value of TimeoutScale ignored. (%s)", str(e)) | 185 logging.warning("Non-integer value of TimeoutScale ignored. (%s)", str(e)) |
| 187 scale = 1 | 186 scale = 1 |
| 188 timeout *= scale | 187 timeout *= scale |
| 189 | 188 |
| 190 return timeout | 189 return timeout |
| 191 | 190 |
| OLD | NEW |