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 import flag_changer | 10 from devil.android import flag_changer |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
238 output = device.StartInstrumentation( | 238 output = device.StartInstrumentation( |
239 target, raw=True, extras=extras, timeout=timeout, retries=0) | 239 target, raw=True, extras=extras, timeout=timeout, retries=0) |
240 duration_ms = time_ms() - start_ms | 240 duration_ms = time_ms() - start_ms |
241 finally: | 241 finally: |
242 if flags: | 242 if flags: |
243 self._flag_changers[str(device)].Restore() | 243 self._flag_changers[str(device)].Restore() |
244 if test_timeout_scale: | 244 if test_timeout_scale: |
245 valgrind_tools.SetChromeTimeoutScale( | 245 valgrind_tools.SetChromeTimeoutScale( |
246 device, self._test_instance.timeout_scale) | 246 device, self._test_instance.timeout_scale) |
247 | 247 |
248 # TODO(jbudorick): Make instrumentation tests output a JSON so this | 248 # TODO(jbudorick): Make instrumentation tests output a JSON so this |
mikecase (-- gone --)
2016/04/20 22:50:31
Is the TODO outdated? Don't instrumentation tests
jbudorick
2016/04/20 22:54:37
No, this is to have the APK expose a JSON, not to
| |
249 # doesn't have to parse the output. | 249 # doesn't have to parse the output. |
250 logging.debug('output from %s:', test_display_name) | |
251 for l in output: | |
252 logging.debug(' %s', l) | |
253 | |
254 result_code, result_bundle, statuses = ( | 250 result_code, result_bundle, statuses = ( |
255 self._test_instance.ParseAmInstrumentRawOutput(output)) | 251 self._test_instance.ParseAmInstrumentRawOutput(output)) |
256 results = self._test_instance.GenerateTestResults( | 252 results = self._test_instance.GenerateTestResults( |
257 result_code, result_bundle, statuses, start_ms, duration_ms) | 253 result_code, result_bundle, statuses, start_ms, duration_ms) |
258 if flags: | 254 if flags: |
259 for r in results: | 255 for r in results: |
260 if r.GetName() == test_name: | 256 if r.GetName() == test_name: |
261 r.SetName(test_display_name) | 257 r.SetName(test_display_name) |
262 if DidPackageCrashOnDevice(self._test_instance.test_package, device): | 258 if DidPackageCrashOnDevice(self._test_instance.test_package, device): |
263 for r in results: | 259 for r in results: |
264 if r.GetType() == base_test_result.ResultType.UNKNOWN: | 260 if r.GetType() == base_test_result.ResultType.UNKNOWN: |
265 r.SetType(base_test_result.ResultType.CRASH) | 261 r.SetType(base_test_result.ResultType.CRASH) |
266 # TODO(jbudorick): ClearApplicationState on failure before switching | 262 |
267 # instrumentation tests to platform mode (but respect --skip-clear-data). | 263 if any(r.GetType() not in (base_test_result.ResultType.PASS, |
264 base_test_result.ResultType.SKIP) | |
265 for r in results): | |
266 logging.info('detected failure in %s. raw output:', test_display_name) | |
267 for l in output: | |
268 logging.info(' %s', l) | |
269 if (not self._env.skip_clear_data | |
270 and self._test_instance.package_info): | |
271 device.ClearApplicationState(self._test_instance.package_info.package) | |
272 else: | |
273 logging.debug('raw output from %s:', test_display_name) | |
274 for l in output: | |
275 logging.debug(' %s', l) | |
276 | |
268 return results | 277 return results |
269 | 278 |
270 #override | 279 #override |
271 def _ShouldShard(self): | 280 def _ShouldShard(self): |
272 return True | 281 return True |
273 | 282 |
274 @classmethod | 283 @classmethod |
275 def _GetTimeoutScaleFromAnnotations(cls, annotations): | 284 def _GetTimeoutScaleFromAnnotations(cls, annotations): |
276 try: | 285 try: |
277 return int(annotations.get('TimeoutScale', 1)) | 286 return int(annotations.get('TimeoutScale', 1)) |
278 except ValueError as e: | 287 except ValueError as e: |
279 logging.warning("Non-integer value of TimeoutScale ignored. (%s)", str(e)) | 288 logging.warning("Non-integer value of TimeoutScale ignored. (%s)", str(e)) |
280 return 1 | 289 return 1 |
281 | 290 |
282 @classmethod | 291 @classmethod |
283 def _GetTimeoutFromAnnotations(cls, annotations, test_name): | 292 def _GetTimeoutFromAnnotations(cls, annotations, test_name): |
284 for k, v in TIMEOUT_ANNOTATIONS: | 293 for k, v in TIMEOUT_ANNOTATIONS: |
285 if k in annotations: | 294 if k in annotations: |
286 timeout = v | 295 timeout = v |
287 break | 296 break |
288 else: | 297 else: |
289 logging.warning('Using default 1 minute timeout for %s', test_name) | 298 logging.warning('Using default 1 minute timeout for %s', test_name) |
290 timeout = 60 | 299 timeout = 60 |
291 | 300 |
292 timeout *= cls._GetTimeoutScaleFromAnnotations(annotations) | 301 timeout *= cls._GetTimeoutScaleFromAnnotations(annotations) |
293 | 302 |
294 return timeout | 303 return timeout |
295 | 304 |
OLD | NEW |