diff options
author | Pavel Labath <pavel@labath.sk> | 2019-02-15 10:47:34 +0000 |
---|---|---|
committer | Pavel Labath <pavel@labath.sk> | 2019-02-15 10:47:34 +0000 |
commit | 5f54fe2332ef3fcb34e20f5d62e6c2664d065ef1 (patch) | |
tree | 64291282f45b4c10048398f1cc1d4fd3bea1bf71 /lldb/packages/Python/lldbsuite/test/functionalities | |
parent | a00425ff0d04ac862a7990e3826f5aa00dad5d56 (diff) | |
download | bcm5719-llvm-5f54fe2332ef3fcb34e20f5d62e6c2664d065ef1.tar.gz bcm5719-llvm-5f54fe2332ef3fcb34e20f5d62e6c2664d065ef1.zip |
Fix the gdb-client test suite for python3
This applies the same fix that was done in r354106 to the lldb-server
test: bitcasting the string to a bytes object before sending it over a
socket. Since the gdb-remote protocol occasionally contains binary data,
and it does not assign any particular encoding to them, this is the
right thing to do here.
llvm-svn: 354114
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/functionalities')
-rw-r--r-- | lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py b/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py index a9e553cbb7d..fb8f61bdf8c 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py @@ -4,6 +4,7 @@ import subprocess import threading import socket import lldb +from lldbsuite.support import seven from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbtest_config @@ -305,13 +306,9 @@ class MockGDBServer: data = None while True: try: - data = self._client.recv(4096) + data = seven.bitcast_to_string(self._client.recv(4096)) if data is None or len(data) == 0: break - # In Python 2, sockets return byte strings. In Python 3, sockets return bytes. - # If we got bytes (and not a byte string), decode them to a string for later handling. - if isinstance(data, bytes) and not isinstance(data, str): - data = data.decode() self._receive(data) except Exception as e: self._client.close() @@ -406,7 +403,7 @@ class MockGDBServer: # We'll handle the ack stuff here since it's not something any of the # tests will be concerned about, and it'll get turned off quickly anyway. if self._shouldSendAck: - self._client.sendall('+'.encode()) + self._client.sendall(seven.bitcast_to_bytes('+')) if packet == "QStartNoAckMode": self._shouldSendAck = False response = "OK" @@ -416,11 +413,7 @@ class MockGDBServer: # Handle packet framing since we don't want to bother tests with it. if response is not None: framed = frame_packet(response) - # In Python 2, sockets send byte strings. In Python 3, sockets send bytes. - # If we got a string (and not a byte string), encode it before sending. - if isinstance(framed, str) and not isinstance(framed, bytes): - framed = framed.encode() - self._client.sendall(framed) + self._client.sendall(seven.bitcast_to_bytes(framed)) PACKET_ACK = object() PACKET_INTERRUPT = object() @@ -504,4 +497,4 @@ class GDBRemoteTestBase(TestBase): j += 1 if i < len(packets): self.fail(u"Did not receive: %s\nLast 10 packets:\n\t%s" % - (packets[i], u'\n\t'.join(log[-10:]))) + (packets[i], u'\n\t'.join(log))) |