[Lldb-commits] [lldb] r354114 - Fix the gdb-client test suite for python3
Pavel Labath via lldb-commits
lldb-commits at lists.llvm.org
Fri Feb 15 02:47:35 PST 2019
Author: labath
Date: Fri Feb 15 02:47:34 2019
New Revision: 354114
URL: http://llvm.org/viewvc/llvm-project?rev=354114&view=rev
Log:
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.
Modified:
lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py
Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py?rev=354114&r1=354113&r2=354114&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py Fri Feb 15 02:47:34 2019
@@ -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)))
More information about the lldb-commits
mailing list