forked from OSchip/llvm-project
Fix test result serialization to use bytes.
llvm-svn: 254563
This commit is contained in:
parent
70497c696a
commit
fe868acafa
|
@ -44,7 +44,7 @@ class UnpicklingForwardingReaderChannel(asyncore.dispatcher):
|
|||
def __init__(self, file_object, async_map, forwarding_func):
|
||||
asyncore.dispatcher.__init__(self, sock=file_object, map=async_map)
|
||||
|
||||
self.header_contents = ''
|
||||
self.header_contents = b""
|
||||
self.packet_bytes_remaining = 0
|
||||
self.reading_header = True
|
||||
self.ibuffer = b''
|
||||
|
@ -69,17 +69,21 @@ class UnpicklingForwardingReaderChannel(asyncore.dispatcher):
|
|||
if not data or (len(data) == 0):
|
||||
return None
|
||||
|
||||
for index in range(len(data)):
|
||||
byte = data[index]
|
||||
if byte != '#':
|
||||
# Header byte.
|
||||
self.header_contents += byte
|
||||
else:
|
||||
# End of header.
|
||||
self.packet_bytes_remaining = int(self.header_contents)
|
||||
self.header_contents = ''
|
||||
self.reading_header = False
|
||||
return data[(index+1):]
|
||||
full_header_len = 4
|
||||
|
||||
assert(len(self.header_contents) < full_header_len)
|
||||
|
||||
bytes_avail = len(data)
|
||||
bytes_needed = full_header_len - len(self.header_contents)
|
||||
header_bytes_avail = min(bytes_needed, bytes_avail)
|
||||
self.header_contents += data[:header_bytes_avail]
|
||||
if len(self.header_contents) == full_header_len:
|
||||
import struct
|
||||
# End of header.
|
||||
self.packet_bytes_remaining = struct.unpack("!I", self.header_contents)[0]
|
||||
self.header_contents = b""
|
||||
self.reading_header = False
|
||||
return data[header_bytes_avail:]
|
||||
|
||||
# If we made it here, we've exhausted the data and
|
||||
# we're still parsing header content.
|
||||
|
|
|
@ -1027,10 +1027,11 @@ class RawPickledFormatter(ResultsFormatter):
|
|||
# Tack on the pid.
|
||||
test_event["pid"] = self.pid
|
||||
|
||||
# Send it as {serialized_length_of_serialized_bytes}#{serialized_bytes}
|
||||
pickled_message = cPickle.dumps(test_event)
|
||||
self.out_file.send("{}#".format(len(pickled_message)))
|
||||
self.out_file.send(pickled_message)
|
||||
# Send it as {serialized_length_of_serialized_bytes}{serialized_bytes}
|
||||
import struct
|
||||
msg = cPickle.dumps(test_event)
|
||||
packet = struct.pack("!I%ds" % len(msg), len(msg), msg)
|
||||
self.out_file.send(packet)
|
||||
|
||||
|
||||
class DumpFormatter(ResultsFormatter):
|
||||
|
|
Loading…
Reference in New Issue