[Lldb-commits] [lldb] r206731 - Added a basic connection test for lldb-gdbserver.

Todd Fiala tfiala at google.com
Sun Apr 20 22:30:09 PDT 2014


Author: tfiala
Date: Mon Apr 21 00:30:08 2014
New Revision: 206731

URL: http://llvm.org/viewvc/llvm-project?rev=206731&view=rev
Log:
Added a basic connection test for lldb-gdbserver.

The lldb-gdbserver tests are skipped if the lldb-gdbserver exe cannot be found (currently only built for Linux and FreeBSD).  The lldb-gdbserver exe is found by the LLDB_EXEC environment variable, using the same dir as the lldb exe, and then replacing lldb with lldb-gdbserver.

Added:
    lldb/trunk/test/tools/
    lldb/trunk/test/tools/lldb-gdbserver/
    lldb/trunk/test/tools/lldb-gdbserver/TestLldbGdbServer.py
    lldb/trunk/test/tools/lldb-gdbserver/lldbgdbserverutils.py

Added: lldb/trunk/test/tools/lldb-gdbserver/TestLldbGdbServer.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/tools/lldb-gdbserver/TestLldbGdbServer.py?rev=206731&view=auto
==============================================================================
--- lldb/trunk/test/tools/lldb-gdbserver/TestLldbGdbServer.py (added)
+++ lldb/trunk/test/tools/lldb-gdbserver/TestLldbGdbServer.py Mon Apr 21 00:30:08 2014
@@ -0,0 +1,40 @@
+"""
+Test lldb-gdbserver operation
+"""
+
+import unittest2
+import pexpect
+import sys
+from lldbtest import *
+from lldbgdbserverutils import *
+
+class LldbGdbServerTestCase(TestBase):
+
+    mydir = TestBase.compute_mydir(__file__)
+
+    port = 12345
+
+    def setUp(self):
+        TestBase.setUp(self)
+        self.lldb_gdbserver_exe = get_lldb_gdbserver_exe()
+        if not self.lldb_gdbserver_exe:
+            self.skipTest("lldb_gdbserver exe not specified")
+
+    def test_exe_starts(self):
+        # start the server
+        server = pexpect.spawn("{} localhost:{}".format(self.lldb_gdbserver_exe, self.port))
+
+        # Turn on logging for what the child sends back.
+        if self.TraceOn():
+            server.logfile_read = sys.stdout
+
+        # Schedule lldb-gdbserver to be shutting down during teardown.
+        def shutdown_lldb_gdbserver():
+            server.close()
+        self.addTearDownHook(shutdown_lldb_gdbserver)
+
+        # Wait until we receive the server ready message before continuing.
+        server.expect_exact('Listening for a connection on localhost:{}'.format(self.port))
+
+if __name__ == '__main__':
+    unittest2.main()

Added: lldb/trunk/test/tools/lldb-gdbserver/lldbgdbserverutils.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/tools/lldb-gdbserver/lldbgdbserverutils.py?rev=206731&view=auto
==============================================================================
--- lldb/trunk/test/tools/lldb-gdbserver/lldbgdbserverutils.py (added)
+++ lldb/trunk/test/tools/lldb-gdbserver/lldbgdbserverutils.py Mon Apr 21 00:30:08 2014
@@ -0,0 +1,25 @@
+import os
+import os.path
+
+def _get_lldb_gdbserver_from_lldb(lldb_exe):
+    lldb_gdbserver = os.path.join(os.path.dirname(lldb_exe), "lldb-gdbserver")
+    if os.path.exists(lldb_gdbserver):
+        return lldb_gdbserver
+    else:
+        return None
+
+def get_lldb_gdbserver_exe():
+    # check for --lldb-gdbserver='{some-path}' in args
+    lldb_exe = os.environ["LLDB_EXEC"]
+    if not lldb_exe:
+        return None
+    else:
+        return _get_lldb_gdbserver_from_lldb(lldb_exe)
+
+if __name__ == '__main__':
+    import sys
+    exe = get_lldb_gdbserver_exe()
+    if exe:
+        print "lldb-gdbserver exe at: {}".format(exe)
+    else:
+        print "lldb-gdbserver not specified"





More information about the lldb-commits mailing list