[Android] Restore filter specs to AdbWrapper.Logcat and LogcatMonitor.
BUG=459672 Review URL: https://codereview.chromium.org/930373006 Cr-Original-Commit-Position: refs/heads/master@{#317069} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: 1860e5f6b74eee2e2c5b5f9bbcea3f79aa3b17d7
This commit is contained in:
Родитель
d17c671ce6
Коммит
b6eaa64b25
|
@ -299,14 +299,14 @@ class AdbWrapper(object):
|
|||
cmd, 'path does not specify an accessible directory in the device',
|
||||
device_serial=self._device_serial)
|
||||
|
||||
def Logcat(self, clear=False, dump=False, filter_spec=None,
|
||||
def Logcat(self, clear=False, dump=False, filter_specs=None,
|
||||
logcat_format=None, timeout=None, retries=_DEFAULT_RETRIES):
|
||||
"""Get an iterable over the logcat output.
|
||||
|
||||
Args:
|
||||
clear: If true, clear the logcat.
|
||||
dump: If true, dump the current logcat contents.
|
||||
filter_spec: If set, spec to filter the logcat.
|
||||
filter_specs: If set, a list of specs to filter the logcat.
|
||||
logcat_format: If set, the format in which the logcat should be output.
|
||||
Options include "brief", "process", "tag", "thread", "raw", "time",
|
||||
"threadtime", and "long"
|
||||
|
@ -328,8 +328,8 @@ class AdbWrapper(object):
|
|||
use_iter = False
|
||||
if logcat_format:
|
||||
cmd.extend(['-v', logcat_format])
|
||||
if filter_spec is not None:
|
||||
cmd.append(filter_spec)
|
||||
if filter_specs:
|
||||
cmd.extend(filter_specs)
|
||||
|
||||
if use_iter:
|
||||
return self._IterRunDeviceAdbCmd(cmd, timeout)
|
||||
|
|
|
@ -22,18 +22,20 @@ class LogcatMonitor(object):
|
|||
# Format: <DATE> <TIME> <PID> <TID> <LEVEL> <COMPONENT>: <MESSAGE>
|
||||
_THREADTIME_RE_FORMAT = r'\S* +\S* +(%s) +(%s) +(%s) +(%s): +(%s)$'
|
||||
|
||||
def __init__(self, adb, clear=True):
|
||||
def __init__(self, adb, clear=True, filter_specs=None):
|
||||
"""Create a LogcatMonitor instance.
|
||||
|
||||
Args:
|
||||
adb: An instance of adb_wrapper.AdbWrapper.
|
||||
clear: If True, clear the logcat when monitoring starts.
|
||||
filter_specs: An optional list of '<tag>[:priority]' strings.
|
||||
"""
|
||||
if isinstance(adb, adb_wrapper.AdbWrapper):
|
||||
self._adb = adb
|
||||
else:
|
||||
raise ValueError('Unsupported type passed for argument "device"')
|
||||
self._clear = clear
|
||||
self._filter_specs = filter_specs
|
||||
self._logcat_out = None
|
||||
self._logcat_out_file = None
|
||||
self._logcat_proc = None
|
||||
|
@ -76,7 +78,7 @@ class LogcatMonitor(object):
|
|||
# returned.
|
||||
# - failure_regex matches a line, in which case None is returned
|
||||
# - the timeout is hit, in which case a CommandTimeoutError is raised.
|
||||
for l in self._adb.Logcat():
|
||||
for l in self._adb.Logcat(filter_specs=self._filter_specs):
|
||||
m = success_regex.search(l)
|
||||
if m:
|
||||
return m
|
||||
|
|
|
@ -123,7 +123,7 @@ def _StartActivityAndWaitForLinkerTestStatus(device, timeout):
|
|||
"""
|
||||
|
||||
# 1. Start recording logcat with appropriate filters.
|
||||
with device.GetLogcatMonitor(filters=_LOGCAT_FILTERS) as logmon:
|
||||
with device.GetLogcatMonitor(filter_specs=_LOGCAT_FILTERS) as logmon:
|
||||
|
||||
# 2. Force-start activity.
|
||||
device.StartActivity(
|
||||
|
|
Загрузка…
Ссылка в новой задаче