diff options
author | rnephew <rnephew@chromium.org> | 2015-08-12 11:09:05 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-08-12 18:09:36 +0000 |
commit | f768a19437cfcee351469c104c442bc2be14b6fe (patch) | |
tree | cb0341a635fa213e8d0ed0967d87a208acaef20c | |
parent | 47c75040af42bf8d8ddcb8aad88b65aa740d1a73 (diff) | |
download | chromium_src-f768a19437cfcee351469c104c442bc2be14b6fe.zip chromium_src-f768a19437cfcee351469c104c442bc2be14b6fe.tar.gz chromium_src-f768a19437cfcee351469c104c442bc2be14b6fe.tar.bz2 |
[Android] Move remote device platform errors to test run base class.
Currently gtests have logic for detecting platform errors on the remote device
platform. This moves it up to the base class for remote_device_test_run and
adds this functionality to instrumentation test runs.
BUG=485842
Review URL: https://codereview.chromium.org/1279873004
Cr-Commit-Position: refs/heads/master@{#343052}
3 files changed, 30 insertions, 19 deletions
diff --git a/build/android/pylib/remote/device/remote_device_gtest_run.py b/build/android/pylib/remote/device/remote_device_gtest_run.py index 96b217b..b16031a 100644 --- a/build/android/pylib/remote/device/remote_device_gtest_run.py +++ b/build/android/pylib/remote/device/remote_device_gtest_run.py @@ -6,7 +6,6 @@ import logging import os -import re import tempfile from pylib import constants @@ -17,7 +16,6 @@ from pylib.remote.device import remote_device_helper _EXTRA_COMMAND_LINE_FILE = ( 'org.chromium.native_test.NativeTestActivity.CommandLineFile') -_NATIVE_CRASH_RE = re.compile('native crash', re.IGNORECASE) class RemoteDeviceGtestTestRun(remote_device_test_run.RemoteDeviceTestRun): @@ -74,22 +72,6 @@ class RemoteDeviceGtestTestRun(remote_device_test_run.RemoteDeviceTestRun): results.AddResults(results_list) if self._env.only_output_failures: logging.info('See logcat for more results information.') - if not self._results['results']['pass']: - if any(_NATIVE_CRASH_RE.search(l) - for l in self._results['results']['output'].splitlines()): - logging.critical('Native crash detected. Printing Logcat.') - self._LogLogcat() - results.AddResult(base_test_result.BaseTestResult( - 'Remote Service detected native crash.', - base_test_result.ResultType.CRASH)) - elif self._DidDeviceGoOffline(): - self._LogLogcat() - self._LogAdbTraceLog() - raise remote_device_helper.RemoteDeviceError( - 'Remote service unable to reach device.', is_infra_error=True) - else: - results.AddResult(base_test_result.BaseTestResult( - 'Remote Service detected error.', - base_test_result.ResultType.UNKNOWN)) + self._DetectPlatformErrors(results) return results diff --git a/build/android/pylib/remote/device/remote_device_instrumentation_test_run.py b/build/android/pylib/remote/device/remote_device_instrumentation_test_run.py index bcdb90c..c03bb65 100644 --- a/build/android/pylib/remote/device/remote_device_instrumentation_test_run.py +++ b/build/android/pylib/remote/device/remote_device_instrumentation_test_run.py @@ -71,4 +71,5 @@ class RemoteDeviceInstrumentationTestRun( else: raise Exception('Unexpected result type: %s' % type(result).__name__) + self._DetectPlatformErrors(r) return r diff --git a/build/android/pylib/remote/device/remote_device_test_run.py b/build/android/pylib/remote/device/remote_device_test_run.py index 6ccfc88..b82b06a 100644 --- a/build/android/pylib/remote/device/remote_device_test_run.py +++ b/build/android/pylib/remote/device/remote_device_test_run.py @@ -14,6 +14,8 @@ import tempfile import time import zipfile + +from pylib.base import base_test_result from pylib.base import test_run from pylib.remote.device import appurify_constants from pylib.remote.device import appurify_sanitized @@ -21,6 +23,8 @@ from pylib.remote.device import remote_device_helper from pylib.utils import zip_utils _DEVICE_OFFLINE_RE = re.compile('error: device not found') +_LONG_MSG_RE = re.compile('longMsg=') +_SHORT_MSG_RE = re.compile('shortMsg=') class RemoteDeviceTestRun(test_run.TestRun): @@ -359,3 +363,27 @@ class RemoteDeviceTestRun(test_run.TestRun): if any(_DEVICE_OFFLINE_RE.search(l) for l in adb_trace_log.splitlines()): return True return False + + def _DetectPlatformErrors(self, results): + if not self._results['results']['pass']: + if any(_SHORT_MSG_RE.search(l) + for l in self._results['results']['output'].splitlines()): + self._LogLogcat() + for line in self._results['results']['output'].splitlines(): + if _LONG_MSG_RE.search(line): + results.AddResult(base_test_result.BaseTestResult( + line.split('=')[1], base_test_result.ResultType.CRASH)) + break + else: + results.AddResult(base_test_result.BaseTestResult( + 'Unknown platform error detected.', + base_test_result.ResultType.UNKNOWN)) + elif self._DidDeviceGoOffline(): + self._LogLogcat() + self._LogAdbTraceLog() + raise remote_device_helper.RemoteDeviceError( + 'Remote service unable to reach device.', is_infra_error=True) + else: + results.AddResult(base_test_result.BaseTestResult( + 'Remote Service detected error.', + base_test_result.ResultType.UNKNOWN)) |