| 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 time | 6 import time |
| 7 | 7 |
| 8 from pylib import flag_changer | 8 from pylib import flag_changer |
| 9 from pylib.base import base_test_result | 9 from pylib.base import base_test_result |
| 10 from pylib.base import test_run | 10 from pylib.base import test_run |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 time_ms = lambda: int(time.time() * 1e3) | 117 time_ms = lambda: int(time.time() * 1e3) |
| 118 start_ms = time_ms() | 118 start_ms = time_ms() |
| 119 output = device.StartInstrumentation( | 119 output = device.StartInstrumentation( |
| 120 '%s/%s' % (self._test_instance.test_package, | 120 '%s/%s' % (self._test_instance.test_package, |
| 121 self._test_instance.test_runner), | 121 self._test_instance.test_runner), |
| 122 raw=True, extras=extras, timeout=timeout, retries=0) | 122 raw=True, extras=extras, timeout=timeout, retries=0) |
| 123 duration_ms = time_ms() - start_ms | 123 duration_ms = time_ms() - start_ms |
| 124 | 124 |
| 125 # TODO(jbudorick): Make instrumentation tests output a JSON so this | 125 # TODO(jbudorick): Make instrumentation tests output a JSON so this |
| 126 # doesn't have to parse the output. | 126 # doesn't have to parse the output. |
| 127 logging.info('output from %s:' % test_name) | 127 logging.debug('output from %s:', test_name) |
| 128 for l in output: | 128 for l in output: |
| 129 logging.info(' %s' % l) | 129 logging.debug(' %s', l) |
| 130 | 130 |
| 131 _, _, statuses = self._test_instance.ParseAmInstrumentRawOutput(output) | 131 result_code, result_bundle, statuses = ( |
| 132 result = self._test_instance.GenerateTestResult( | 132 self._test_instance.ParseAmInstrumentRawOutput(output)) |
| 133 test_name, statuses, start_ms, duration_ms) | 133 results = self._test_instance.GenerateTestResults( |
| 134 result_code, result_bundle, statuses, start_ms, duration_ms) |
| 134 if DidPackageCrashOnDevice(self._test_instance.test_package, device): | 135 if DidPackageCrashOnDevice(self._test_instance.test_package, device): |
| 135 result.SetType(base_test_result.ResultType.CRASH) | 136 for r in results: |
| 136 return result | 137 if r.GetType() == base_test_result.ResultType.UNKNOWN: |
| 138 r.SetType(base_test_result.ResultType.CRASH) |
| 139 return results |
| 137 | 140 |
| 138 #override | 141 #override |
| 139 def _ShouldShard(self): | 142 def _ShouldShard(self): |
| 140 return True | 143 return True |
| 141 | 144 |
| 142 @staticmethod | 145 @staticmethod |
| 143 def _GetTimeoutFromAnnotations(annotations, test_name): | 146 def _GetTimeoutFromAnnotations(annotations, test_name): |
| 144 for k, v in TIMEOUT_ANNOTATIONS: | 147 for k, v in TIMEOUT_ANNOTATIONS: |
| 145 if k in annotations: | 148 if k in annotations: |
| 146 timeout = v | 149 timeout = v |
| 147 else: | 150 else: |
| 148 logging.warning('Using default 1 minute timeout for %s' % test_name) | 151 logging.warning('Using default 1 minute timeout for %s' % test_name) |
| 149 timeout = 60 | 152 timeout = 60 |
| 150 | 153 |
| 151 try: | 154 try: |
| 152 scale = int(annotations.get('TimeoutScale', 1)) | 155 scale = int(annotations.get('TimeoutScale', 1)) |
| 153 except ValueError as e: | 156 except ValueError as e: |
| 154 logging.warning("Non-integer value of TimeoutScale ignored. (%s)", str(e)) | 157 logging.warning("Non-integer value of TimeoutScale ignored. (%s)", str(e)) |
| 155 scale = 1 | 158 scale = 1 |
| 156 timeout *= scale | 159 timeout *= scale |
| 157 | 160 |
| 158 return timeout | 161 return timeout |
| 159 | 162 |
| OLD | NEW |