Commit ddb327c1 authored by dpranke's avatar dpranke Committed by Commit bot

Fix more android logging crashes in run-webkit-tests.

This CL attempts to fix yet more places where run-webkit-tests
can crash when running tests on Android because we get confused
over whether the byte stream coming from the device is unicode
or not.

R=jbudorick@chromium.org, mgiuca@chromium.org, mithro@chromium.org, robertshield@chromium.org
BUG=598449

Review-Url: https://codereview.chromium.org/1930783002
Cr-Commit-Position: refs/heads/master@{#390299}
parent f92633b8
...@@ -257,10 +257,12 @@ class AndroidCommands(object): ...@@ -257,10 +257,12 @@ class AndroidCommands(object):
error_handler = None error_handler = None
result = self._executive.run_command(self.adb_command() + command, result = self._executive.run_command(self.adb_command() + command,
error_handler=error_handler, debug_logging=self._debug_logging) error_handler=error_handler,
decode_output=False,
debug_logging=self._debug_logging)
# We limit the length to avoid outputting too verbose commands, such as "adb logcat". # We limit the length to avoid outputting too verbose commands, such as "adb logcat".
self._log_debug('Run adb result: ' + result[:80]) self._log_debug('Run adb result: ' + result[:80].decode('ascii', errors='replace'))
return result return result
def get_serial(self): def get_serial(self):
...@@ -313,12 +315,14 @@ class AndroidCommands(object): ...@@ -313,12 +315,14 @@ class AndroidCommands(object):
def _determine_adb_version(adb_command_path, executive, debug_logging): def _determine_adb_version(adb_command_path, executive, debug_logging):
re_version = re.compile('^.*version ([\d\.]+)') re_version = re.compile('^.*version ([\d\.]+)')
try: try:
output = executive.run_command([adb_command_path, 'version'], error_handler=executive.ignore_error, output = executive.run_command([adb_command_path, 'version'],
error_handler=executive.ignore_error,
decode_output=False,
debug_logging=debug_logging) debug_logging=debug_logging)
except OSError: except OSError:
return None return None
result = re_version.match(output) result = re_version.match(output.decode('ascii', errors='replace'))
if not output or not result: if not output or not result:
return None return None
...@@ -355,8 +359,10 @@ class AndroidDevices(object): ...@@ -355,8 +359,10 @@ class AndroidDevices(object):
re_device = re.compile('^([a-zA-Z0-9_:.-]+)\tdevice$', re.MULTILINE) re_device = re.compile('^([a-zA-Z0-9_:.-]+)\tdevice$', re.MULTILINE)
result = executive.run_command([AndroidCommands.adb_command_path(executive, debug_logging=self._debug_logging), 'devices'], result = executive.run_command([AndroidCommands.adb_command_path(executive, debug_logging=self._debug_logging), 'devices'],
error_handler=executive.ignore_error, debug_logging=self._debug_logging) error_handler=executive.ignore_error,
devices = re_device.findall(result) decode_output=False,
debug_logging=self._debug_logging)
devices = re_device.findall(result.decode('ascii', errors='replace'))
if not devices: if not devices:
return [] return []
...@@ -508,14 +514,16 @@ class AndroidPort(base.Port): ...@@ -508,14 +514,16 @@ class AndroidPort(base.Port):
pids = self._executive.running_pids(lambda name: 'adb' in name) pids = self._executive.running_pids(lambda name: 'adb' in name)
if not pids: if not pids:
# Apparently adb is not running, which is unusual. Running any adb command should start it. # Apparently adb is not running, which is unusual. Running any adb command should start it.
self._executive.run_command(['adb', 'devices']) self._executive.run_command(['adb', 'devices'],
decode_output=False)
pids = self._executive.running_pids(lambda name: 'adb' in name) pids = self._executive.running_pids(lambda name: 'adb' in name)
if not pids: if not pids:
_log.error("The adb daemon does not appear to be running.") _log.error("The adb daemon does not appear to be running.")
return False return False
for pid in pids: for pid in pids:
self._executive.run_command(['taskset', '-p', '-c', '0', str(pid)]) self._executive.run_command(['taskset', '-p', '-c', '0', str(pid)],
decode_output=False)
if not result: if not result:
_log.error('For complete Android build requirements, please see:') _log.error('For complete Android build requirements, please see:')
...@@ -734,7 +742,8 @@ http://goto.google.com/cr-android-perf-howto ...@@ -734,7 +742,8 @@ http://goto.google.com/cr-android-perf-howto
def _perf_version_string(self, perf_path): def _perf_version_string(self, perf_path):
try: try:
return self._host.executive.run_command([perf_path, '--version']) return self._host.executive.run_command([perf_path, '--version'],
decode_output=False)
except: except:
return None return None
...@@ -775,9 +784,10 @@ http://goto.google.com/cr-android-perf-howto ...@@ -775,9 +784,10 @@ http://goto.google.com/cr-android-perf-howto
] ]
if perfhost_path: if perfhost_path:
perfhost_args = [perfhost_path] + perfhost_report_command + ['--call-graph', 'none'] perfhost_args = [perfhost_path] + perfhost_report_command + ['--call-graph', 'none']
perf_output = self._host.executive.run_command(perfhost_args) perf_output = self._host.executive.run_command(perfhost_args,
decode_output=False)
# We could save off the full -g report to a file if users found that useful. # We could save off the full -g report to a file if users found that useful.
_log.debug(self._first_ten_lines_of_profile(perf_output)) _log.debug(self._first_ten_lines_of_profile(perf_output).decode('ascii', errors='replace'))
else: else:
_log.debug(""" _log.debug("""
Failed to find perfhost_linux binary, can't process samples from the device. Failed to find perfhost_linux binary, can't process samples from the device.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment