[Lldb-commits] [lldb] 65e843c - [lldb] Add a test for launch failure and its error message

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Thu Feb 13 23:44:51 PST 2020


Author: Pavel Labath
Date: 2020-02-14T08:43:03+01:00
New Revision: 65e843c9e0b91d5ac156130f61b378bad2e8e2fd

URL: https://github.com/llvm/llvm-project/commit/65e843c9e0b91d5ac156130f61b378bad2e8e2fd
DIFF: https://github.com/llvm/llvm-project/commit/65e843c9e0b91d5ac156130f61b378bad2e8e2fd.diff

LOG: [lldb] Add a test for launch failure and its error message

Added: 
    

Modified: 
    lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py
    lldb/test/API/functionalities/gdb_remote_client/gdbclientutils.py

Removed: 
    


################################################################################
diff  --git a/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py b/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py
index 8f0ed9a4933d..238a4559d6fb 100644
--- a/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py
+++ b/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py
@@ -50,6 +50,30 @@ def vAttach(self, pid):
         target.AttachToProcessWithID(lldb.SBListener(), 47, error)
         self.assertEquals(error_msg, error.GetCString())
 
+    def test_launch_fail(self):
+        class MyResponder(MockGDBServerResponder):
+            # Pretend we don't have any process during the initial queries.
+            def qC(self):
+                return "E42"
+
+            def qfThreadInfo(self):
+                return "OK" # No threads.
+
+            # Then, when we are asked to attach, error out.
+            def A(self, packet):
+                return "E47"
+
+        self.server.responder = MyResponder()
+
+        target = self.createTarget("a.yaml")
+        process = self.connect(target)
+        lldbutil.expect_state_changes(self, self.dbg.GetListener(), process, [lldb.eStateConnected])
+
+        error = lldb.SBError()
+        target.Launch(lldb.SBListener(), None, None, None, None, None,
+                None, 0, True, error)
+        self.assertEquals("process launch failed: 'A' packet returned an error: 71", error.GetCString())
+
     def test_read_registers_using_g_packets(self):
         """Test reading registers using 'g' packets (default behavior)"""
         self.dbg.HandleCommand(

diff  --git a/lldb/test/API/functionalities/gdb_remote_client/gdbclientutils.py b/lldb/test/API/functionalities/gdb_remote_client/gdbclientutils.py
index 392aeba5bd68..486485c8e28d 100644
--- a/lldb/test/API/functionalities/gdb_remote_client/gdbclientutils.py
+++ b/lldb/test/API/functionalities/gdb_remote_client/gdbclientutils.py
@@ -106,6 +106,8 @@ def respond(self, packet):
             return self.cont()
         if packet.startswith("vCont;c"):
             return self.vCont(packet)
+        if packet[0] == "A":
+            return self.A(packet)
         if packet[0] == "g":
             return self.readRegisters()
         if packet[0] == "G":
@@ -201,6 +203,9 @@ def cont(self):
     def vCont(self, packet):
         raise self.UnexpectedPacketException()
 
+    def A(self, packet):
+        return ""
+
     def readRegisters(self):
         return "00000000" * self.registerCount
 


        


More information about the lldb-commits mailing list