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.

llvm-svn: 127048
This commit is contained in:
Johnny Chen 2011-03-04 23:40:06 +00:00
parent f045b7ab45
commit 05178f6e54
3 changed files with 64 additions and 8 deletions

View File

@ -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()

View File

@ -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()

View File

@ -14,16 +14,16 @@ class TargetAPITestCase(TestBase):
@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 @@ class TargetAPITestCase(TestBase):
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.