[Lldb-commits] [lldb] r255581 - test infra: catch and print exception info on test runner socket listener

Todd Fiala via lldb-commits lldb-commits at lists.llvm.org
Mon Dec 14 15:45:38 PST 2015


Author: tfiala
Date: Mon Dec 14 17:45:38 2015
New Revision: 255581

URL: http://llvm.org/viewvc/llvm-project?rev=255581&view=rev
Log:
test infra: catch and print exception info on test runner socket listener

This is the listener's spawned connection, not the listener itself.
(i.e. this is the test runner's receiving side of test event sockets).
A standard socket.error will just issue an INFO statement and continue.
Something other than a socket.error will get an ERROR: printed (and
also continue).

Hopefully this gets us more info and also handles the completely
to-be-expected scenario that the test inferior might go down at
any point.

Modified:
    lldb/trunk/packages/Python/lldbsuite/test/dotest_channels.py

Modified: lldb/trunk/packages/Python/lldbsuite/test/dotest_channels.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/dotest_channels.py?rev=255581&r1=255580&r2=255581&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/dotest_channels.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/dotest_channels.py Mon Dec 14 17:45:38 2015
@@ -27,6 +27,7 @@ from six.moves import cPickle
 
 # LLDB modules
 
+
 class UnpicklingForwardingReaderChannel(asyncore.dispatcher):
     """Provides an unpickling, forwarding asyncore dispatch channel reader.
 
@@ -71,7 +72,7 @@ class UnpicklingForwardingReaderChannel(
 
         full_header_len = 4
 
-        assert(len(self.header_contents) < full_header_len)
+        assert len(self.header_contents) < full_header_len
 
         bytes_avail = len(data)
         bytes_needed = full_header_len - len(self.header_contents)
@@ -80,7 +81,8 @@ class UnpicklingForwardingReaderChannel(
         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.packet_bytes_remaining = struct.unpack(
+                "!I", self.header_contents)[0]
             self.header_contents = b""
             self.reading_header = False
             return data[header_bytes_avail:]
@@ -130,9 +132,23 @@ class UnpicklingForwardingReaderChannel(
             return data
 
     def handle_read(self):
-        data = self.recv(8192)
-        # print('driver socket READ: %d bytes' % len(data))
+        # Read some data from the socket.
+        try:
+            data = self.recv(8192)
+            # print('driver socket READ: %d bytes' % len(data))
+        except socket.error as socket_error:
+            print(
+                "\nINFO: received socket error when reading data "
+                "from test inferior:\n{}".format(socket_error))
+            # Should be good to return here.
+            return
+        except Exception as general_exception:
+            print(
+                "\nERROR: received non-socket error when reading data "
+                "from the test inferior:\n{}".format(general_exception))
+            return
 
+        # Consume the message content.
         while data and (len(data) > 0):
             # If we're reading the header, gather header bytes.
             if self.reading_header:




More information about the lldb-commits mailing list