[Lldb-commits] [lldb] r127048 - in /lldb/trunk/test: connect_remote/ connect_remote/EchoServer.py connect_remote/TestConnectRemote.py python_api/target/TestTargetAPI.py

Johnny Chen johnny.chen at apple.com
Fri Mar 4 15:40:07 PST 2011


Author: johnny
Date: Fri Mar  4 17:40:06 2011
New Revision: 127048

URL: http://llvm.org/viewvc/llvm-project?rev=127048&view=rev
Log:
Add a test case for the lldb command 'process connect'.
We start a fake debugserver listening on localhost:12345 and issue the command
'process connect connect://localhost:12345' to connect to it.

Added:
    lldb/trunk/test/connect_remote/
    lldb/trunk/test/connect_remote/EchoServer.py   (with props)
    lldb/trunk/test/connect_remote/TestConnectRemote.py
Modified:
    lldb/trunk/test/python_api/target/TestTargetAPI.py

Added: lldb/trunk/test/connect_remote/EchoServer.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/connect_remote/EchoServer.py?rev=127048&view=auto
==============================================================================
--- lldb/trunk/test/connect_remote/EchoServer.py (added)
+++ lldb/trunk/test/connect_remote/EchoServer.py Fri Mar  4 17:40:06 2011
@@ -0,0 +1,23 @@
+#!/usr/bin/env python 
+
+""" 
+A simple echo server.
+Taken from http://docs.python.org/library/socket.html#example.
+"""
+
+import socket
+
+HOST = 'localhost'        # Symbolic name meaning local interfaces
+PORT = 12345              # Arbitrary non-privileged port
+s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+s.bind((HOST, PORT))
+print '\nListening on %s:%d' % (HOST, PORT)
+s.listen(1)
+conn, addr = s.accept()
+print 'Connected by', addr
+while 1:
+    data = conn.recv(1024)
+    if not data: break
+    conn.send(data)
+    print 'Received:', data
+conn.close()

Propchange: lldb/trunk/test/connect_remote/EchoServer.py
------------------------------------------------------------------------------
    svn:executable = *

Added: lldb/trunk/test/connect_remote/TestConnectRemote.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/connect_remote/TestConnectRemote.py?rev=127048&view=auto
==============================================================================
--- lldb/trunk/test/connect_remote/TestConnectRemote.py (added)
+++ lldb/trunk/test/connect_remote/TestConnectRemote.py Fri Mar  4 17:40:06 2011
@@ -0,0 +1,33 @@
+"""
+Test lldb 'process connect' command.
+"""
+
+import os, time
+import unittest2
+import lldb
+from lldbtest import *
+
+class ConnectRemoteTestCase(TestBase):
+
+    mydir = "connect_remote"
+
+    def test_connect_remote(self):
+        """Test "process connect connect:://localhost:12345"."""
+
+        # First, we'll start a fake debugserver (a simple echo server).
+        import subprocess
+        fakeserver = subprocess.Popen('./EchoServer.py')
+        # This does the cleanup afterwards.
+        def cleanup_fakeserver():
+            fakeserver.kill()
+            fakeserver.wait()
+        self.addTearDownHook(cleanup_fakeserver)
+
+        self.runCmd("process connect connect://localhost:12345")
+
+
+if __name__ == '__main__':
+    import atexit
+    lldb.SBDebugger.Initialize()
+    atexit.register(lambda: lldb.SBDebugger.Terminate())
+    unittest2.main()

Modified: lldb/trunk/test/python_api/target/TestTargetAPI.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/target/TestTargetAPI.py?rev=127048&r1=127047&r2=127048&view=diff
==============================================================================
--- lldb/trunk/test/python_api/target/TestTargetAPI.py (original)
+++ lldb/trunk/test/python_api/target/TestTargetAPI.py Fri Mar  4 17:40:06 2011
@@ -14,16 +14,16 @@
 
     @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
     @python_api_test
-    def test_with_dsym(self):
-        """Exercise SBTaget APIs."""
+    def test_resolve_symbol_context_with_address_with_dsym(self):
+        """Exercise SBTaget.ResolveSymbolContextForAddress() API."""
         self.buildDsym()
-        self.target_api()
+        self.resolve_symbol_context_with_address()
 
     @python_api_test
-    def test_with_dwarf(self):
-        """Exercise SBTarget APIs."""
+    def test_resolve_symbol_context_with_address_with_dwarf(self):
+        """Exercise SBTarget.ResolveSymbolContextForAddress() API."""
         self.buildDwarf()
-        self.target_api()
+        self.resolve_symbol_context_with_address()
 
     def setUp(self):
         # Call super's setUp().
@@ -32,8 +32,8 @@
         self.line1 = line_number('main.c', '// Find the line number for breakpoint 1 here.')
         self.line2 = line_number('main.c', '// Find the line number for breakpoint 2 here.')
 
-    def target_api(self):
-        """Exercise SBTarget APIs."""
+    def resolve_symbol_context_with_address(self):
+        """Exercise SBTaget.ResolveSymbolContextForAddress() API."""
         exe = os.path.join(os.getcwd(), "a.out")
 
         # Create a target by the debugger.





More information about the lldb-commits mailing list