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.debug('output from %s:', test_name) | 127 logging.info('output from %s:' % test_name) |
128 for l in output: | 128 for l in output: |
129 logging.debug(' %s', l) | 129 logging.info(' %s' % l) |
130 | 130 |
131 result_code, result_bundle, statuses = ( | 131 _, _, statuses = self._test_instance.ParseAmInstrumentRawOutput(output) |
132 self._test_instance.ParseAmInstrumentRawOutput(output)) | 132 result = self._test_instance.GenerateTestResult( |
133 results = self._test_instance.GenerateTestResults( | 133 test_name, statuses, start_ms, duration_ms) |
134 result_code, result_bundle, statuses, start_ms, duration_ms) | |
135 if DidPackageCrashOnDevice(self._test_instance.test_package, device): | 134 if DidPackageCrashOnDevice(self._test_instance.test_package, device): |
136 for r in results: | 135 result.SetType(base_test_result.ResultType.CRASH) |
137 if r.GetType() == base_test_result.ResultType.UNKNOWN: | 136 return result |
138 r.SetType(base_test_result.ResultType.CRASH) | |
139 return results | |
140 | 137 |
141 #override | 138 #override |
142 def _ShouldShard(self): | 139 def _ShouldShard(self): |
143 return True | 140 return True |
144 | 141 |
145 @staticmethod | 142 @staticmethod |
146 def _GetTimeoutFromAnnotations(annotations, test_name): | 143 def _GetTimeoutFromAnnotations(annotations, test_name): |
147 for k, v in TIMEOUT_ANNOTATIONS: | 144 for k, v in TIMEOUT_ANNOTATIONS: |
148 if k in annotations: | 145 if k in annotations: |
149 timeout = v | 146 timeout = v |
150 else: | 147 else: |
151 logging.warning('Using default 1 minute timeout for %s' % test_name) | 148 logging.warning('Using default 1 minute timeout for %s' % test_name) |
152 timeout = 60 | 149 timeout = 60 |
153 | 150 |
154 try: | 151 try: |
155 scale = int(annotations.get('TimeoutScale', 1)) | 152 scale = int(annotations.get('TimeoutScale', 1)) |
156 except ValueError as e: | 153 except ValueError as e: |
157 logging.warning("Non-integer value of TimeoutScale ignored. (%s)", str(e)) | 154 logging.warning("Non-integer value of TimeoutScale ignored. (%s)", str(e)) |
158 scale = 1 | 155 scale = 1 |
159 timeout *= scale | 156 timeout *= scale |
160 | 157 |
161 return timeout | 158 return timeout |
162 | 159 |
OLD | NEW |