Fix way of sending packets in compliance tests

According to the documentation of python 3 socket::send method
(https://docs.python.org/3/library/socket.html#socket.socket.send),
the call to send must be retry until all data is sent while sending
packet with a "large" amount of data.

Signed-off-by: Jerome Malinge <gromgromm@yahoo.com>
pull/1487/head
Jerome Malinge 6 years ago
parent 253326dcc9
commit d76e5fd199

@ -106,7 +106,13 @@ def packet_matches(name, recvd, expected):
def do_send_receive(sock, send_packet, receive_packet, error_string="send receive error"):
sock.send(send_packet)
size = len(send_packet)
total_sent = 0
while total_sent < size:
sent = sock.send(send_packet[total_sent:])
if sent == 0:
raise RuntimeError("socket connection broken")
total_sent += sent
if expect_packet(sock, error_string, receive_packet):
return sock

Loading…
Cancel
Save