| 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 os | 6 import os |
| 7 import posixpath | 7 import posixpath |
| 8 import re | 8 import re |
| 9 import time | 9 import time |
| 10 | 10 |
| 11 from devil.android import device_errors | 11 from devil.android import device_errors |
| 12 from devil.android import flag_changer | 12 from devil.android import flag_changer |
| 13 from devil.utils import reraiser_thread | 13 from devil.utils import reraiser_thread |
| 14 from pylib import valgrind_tools | 14 from pylib import valgrind_tools |
| 15 from pylib.android import logdog_logcat_monitor | 15 from pylib.android import logdog_logcat_monitor |
| 16 from pylib.base import base_test_result | 16 from pylib.base import base_test_result |
| 17 from pylib.instrumentation import instrumentation_test_instance | 17 from pylib.instrumentation import instrumentation_test_instance |
| 18 from pylib.local.device import local_device_environment | 18 from pylib.local.device import local_device_environment |
| 19 from pylib.local.device import local_device_test_run | 19 from pylib.local.device import local_device_test_run |
| 20 from pylib.utils import logdog_helper |
| 20 from py_trace_event import trace_event | 21 from py_trace_event import trace_event |
| 21 from py_utils import contextlib_ext | 22 from py_utils import contextlib_ext |
| 22 import tombstones | 23 import tombstones |
| 23 | 24 |
| 24 _TAG = 'test_runner_py' | 25 _TAG = 'test_runner_py' |
| 25 | 26 |
| 26 TIMEOUT_ANNOTATIONS = [ | 27 TIMEOUT_ANNOTATIONS = [ |
| 27 ('Manual', 10 * 60 * 60), | 28 ('Manual', 10 * 60 * 60), |
| 28 ('IntegrationTest', 30 * 60), | 29 ('IntegrationTest', 30 * 60), |
| 29 ('External', 10 * 60), | 30 ('External', 10 * 60), |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 valgrind_tools.SetChromeTimeoutScale( | 283 valgrind_tools.SetChromeTimeoutScale( |
| 283 device, self._test_instance.timeout_scale) | 284 device, self._test_instance.timeout_scale) |
| 284 | 285 |
| 285 # TODO(jbudorick): Make instrumentation tests output a JSON so this | 286 # TODO(jbudorick): Make instrumentation tests output a JSON so this |
| 286 # doesn't have to parse the output. | 287 # doesn't have to parse the output. |
| 287 result_code, result_bundle, statuses = ( | 288 result_code, result_bundle, statuses = ( |
| 288 self._test_instance.ParseAmInstrumentRawOutput(output)) | 289 self._test_instance.ParseAmInstrumentRawOutput(output)) |
| 289 results = self._test_instance.GenerateTestResults( | 290 results = self._test_instance.GenerateTestResults( |
| 290 result_code, result_bundle, statuses, start_ms, duration_ms) | 291 result_code, result_bundle, statuses, start_ms, duration_ms) |
| 291 for result in results: | 292 for result in results: |
| 292 result.SetLogcatUrl(logcat_url) | 293 result.AddLink('logcat', logcat_url) |
| 293 | 294 |
| 294 # Update the result name if the test used flags. | 295 # Update the result name if the test used flags. |
| 295 if flags: | 296 if flags: |
| 296 for r in results: | 297 for r in results: |
| 297 if r.GetName() == test_name: | 298 if r.GetName() == test_name: |
| 298 r.SetName(test_display_name) | 299 r.SetName(test_display_name) |
| 299 | 300 |
| 300 # Add UNKNOWN results for any missing tests. | 301 # Add UNKNOWN results for any missing tests. |
| 301 iterable_test = test if isinstance(test, list) else [test] | 302 iterable_test = test if isinstance(test, list) else [test] |
| 302 test_names = set(self._GetUniqueTestName(t) for t in iterable_test) | 303 test_names = set(self._GetUniqueTestName(t) for t in iterable_test) |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 if result.GetType() == base_test_result.ResultType.CRASH: | 355 if result.GetType() == base_test_result.ResultType.CRASH: |
| 355 if not tombstones_url: | 356 if not tombstones_url: |
| 356 resolved_tombstones = tombstones.ResolveTombstones( | 357 resolved_tombstones = tombstones.ResolveTombstones( |
| 357 device, | 358 device, |
| 358 resolve_all_tombstones=True, | 359 resolve_all_tombstones=True, |
| 359 include_stack_symbols=False, | 360 include_stack_symbols=False, |
| 360 wipe_tombstones=True) | 361 wipe_tombstones=True) |
| 361 stream_name = 'tombstones_%s_%s' % ( | 362 stream_name = 'tombstones_%s_%s' % ( |
| 362 time.strftime('%Y%m%dT%H%M%S', time.localtime()), | 363 time.strftime('%Y%m%dT%H%M%S', time.localtime()), |
| 363 device.serial) | 364 device.serial) |
| 364 tombstones_url = tombstones.LogdogTombstones(resolved_tombstones, | 365 tombstones_url = logdog_helper.text( |
| 365 stream_name) | 366 stream_name, resolved_tombstones) |
| 366 result.SetTombstonesUrl(tombstones_url) | 367 result.AddLink('tombstones', tombstones_url) |
| 367 return results, None | 368 return results, None |
| 368 | 369 |
| 369 #override | 370 #override |
| 370 def _ShouldRetry(self, test): | 371 def _ShouldRetry(self, test): |
| 371 if 'RetryOnFailure' in test.get('annotations', {}): | 372 if 'RetryOnFailure' in test.get('annotations', {}): |
| 372 return True | 373 return True |
| 373 | 374 |
| 374 # TODO(jbudorick): Remove this log message once @RetryOnFailure has been | 375 # TODO(jbudorick): Remove this log message once @RetryOnFailure has been |
| 375 # enabled for a while. See crbug.com/619055 for more details. | 376 # enabled for a while. See crbug.com/619055 for more details. |
| 376 logging.error('Default retries are being phased out. crbug.com/619055') | 377 logging.error('Default retries are being phased out. crbug.com/619055') |
| (...skipping 18 matching lines...) Expand all Loading... |
| 395 timeout = v | 396 timeout = v |
| 396 break | 397 break |
| 397 else: | 398 else: |
| 398 logging.warning('Using default 1 minute timeout for %s', test_name) | 399 logging.warning('Using default 1 minute timeout for %s', test_name) |
| 399 timeout = 60 | 400 timeout = 60 |
| 400 | 401 |
| 401 timeout *= cls._GetTimeoutScaleFromAnnotations(annotations) | 402 timeout *= cls._GetTimeoutScaleFromAnnotations(annotations) |
| 402 | 403 |
| 403 return timeout | 404 return timeout |
| 404 | 405 |
| OLD | NEW |