diff options
| -rw-r--r-- | third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/port/android.py | 15 | ||||
| -rw-r--r-- | third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/port/base.py | 15 |
2 files changed, 27 insertions, 3 deletions
diff --git a/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/port/android.py b/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/port/android.py index 2eacecc..61e3d05 100644 --- a/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/port/android.py +++ b/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/port/android.py @@ -659,6 +659,12 @@ class AndroidPort(base.Port): @staticmethod def _android_server_process_constructor(port, server_name, cmd_line, env=None, logging=False): + # We need universal_newlines=True, because 'adb shell' for some unknown reason + # does newline conversion of unix-style LF into win-style CRLF (and we need + # to convert that back). This can cause headaches elsewhere because + # server_process' stdout and stderr are now unicode file-like objects, + # not binary file-like objects like all of the other ports are. + # FIXME: crbug.com/496983. return server_process.ServerProcess(port, server_name, cmd_line, env, universal_newlines=True, treat_no_data_as_crash=True, logging=logging) @@ -1040,7 +1046,14 @@ class ChromiumAndroidDriver(driver.Driver): for crash in crashes: stderr += '********* [%s] breakpad minidump %s:\n%s' % (self._port.host.filesystem.basename(crash), self._android_commands.get_serial(), self._port._dump_reader._get_stack_from_dump(crash)) - return super(ChromiumAndroidDriver, self)._get_crash_log(stdout, stderr, newer_than) + # The parent method expects stdout and stderr to be byte streams, but + # since adb shell does newline conversion, we used universal_newlines + # when launching the processes, and hence our stdout and stderr are + # text objects that need to be encoded back into bytes. + return super(ChromiumAndroidDriver, self)._get_crash_log( + stdout.encode('utf8', 'replace'), + stderr.encode('utf8', 'replace'), + newer_than) def cmd_line(self, pixel_tests, per_test_args): # The returned command line is used to start _server_process. In our case, it's an interactive 'adb shell'. diff --git a/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/port/base.py b/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/port/base.py index bb42fbc..493cecf 100644 --- a/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/port/base.py +++ b/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/port/base.py @@ -1535,8 +1535,19 @@ class Port(object): name_str = name or '<unknown process name>' pid_str = str(pid or '<unknown>') - stdout_lines = (stdout or '<empty>').decode('utf8', 'replace').splitlines() - stderr_lines = (stderr or '<empty>').decode('utf8', 'replace').splitlines() + + # We require stdout and stderr to be bytestrings, not character strings. + if stdout: + assert isinstance(stdout, str) + stdout_lines = stdout.decode('utf8', 'replace').splitlines() + else: + stdout_lines = [u'<empty>'] + if stderr: + assert isinstance(stderr, str) + stderr_lines = stderr.decode('utf8', 'replace').splitlines() + else: + stderr_lines = [u'<empty>'] + return (stderr, 'crash log for %s (pid %s):\n%s\n%s\n' % (name_str, pid_str, '\n'.join(('STDOUT: ' + l) for l in stdout_lines), '\n'.join(('STDERR: ' + l) for l in stderr_lines))) |
