diff options
author | Kuba Brecka <kuba.brecka@gmail.com> | 2014-09-08 17:06:54 +0000 |
---|---|---|
committer | Kuba Brecka <kuba.brecka@gmail.com> | 2014-09-08 17:06:54 +0000 |
commit | ea65e37beea96207b6fa64959112dc7ba6e44b3c (patch) | |
tree | 576755ca12ab2ae5ebaa0f7ca846250cead8ae90 /lldb/test | |
parent | 3d3e2c72ec17876fb1b77cf61cad2e552958c09e (diff) | |
download | bcm5719-llvm-ea65e37beea96207b6fa64959112dc7ba6e44b3c.tar.gz bcm5719-llvm-ea65e37beea96207b6fa64959112dc7ba6e44b3c.zip |
Fix test failure for test/functionalities/connect_remote/TestConnectRemote.py when port 12345 is already in use
Reviewed at http://reviews.llvm.org/D5221
llvm-svn: 217388
Diffstat (limited to 'lldb/test')
-rwxr-xr-x | lldb/test/functionalities/connect_remote/EchoServer.py | 5 | ||||
-rw-r--r-- | lldb/test/functionalities/connect_remote/TestConnectRemote.py | 10 |
2 files changed, 10 insertions, 5 deletions
diff --git a/lldb/test/functionalities/connect_remote/EchoServer.py b/lldb/test/functionalities/connect_remote/EchoServer.py index 3e6823c89d4..658690ec754 100755 --- a/lldb/test/functionalities/connect_remote/EchoServer.py +++ b/lldb/test/functionalities/connect_remote/EchoServer.py @@ -8,10 +8,11 @@ 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 +PORT = 0 # Let the system give us a random free port s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.bind((HOST, PORT)) -print '\nListening on %s:%d' % (HOST, PORT) +PORT = s.getsockname()[1] +print 'Listening on %s:%d' % (HOST, PORT) s.listen(1) conn, addr = s.accept() print 'Connected by', addr diff --git a/lldb/test/functionalities/connect_remote/TestConnectRemote.py b/lldb/test/functionalities/connect_remote/TestConnectRemote.py index 7b838b6f495..fed832dbf55 100644 --- a/lldb/test/functionalities/connect_remote/TestConnectRemote.py +++ b/lldb/test/functionalities/connect_remote/TestConnectRemote.py @@ -5,6 +5,7 @@ Test lldb 'process connect' command. import os import unittest2 import lldb +import re from lldbtest import * class ConnectRemoteTestCase(TestBase): @@ -12,7 +13,7 @@ class ConnectRemoteTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) def test_connect_remote(self): - """Test "process connect connect:://localhost:12345".""" + """Test "process connect connect:://localhost:[port]".""" import pexpect # First, we'll start a fake debugserver (a simple echo server). @@ -28,10 +29,13 @@ class ConnectRemoteTestCase(TestBase): self.addTearDownHook(shutdown_fakeserver) # Wait until we receive the server ready message before continuing. - fakeserver.expect_exact('Listening on localhost:12345') + line = fakeserver.readline() + self.assertTrue(line.startswith("Listening on localhost:")) + port = int(re.match('Listening on localhost:([0-9]+)', line).group(1)) + self.assertTrue(port > 0) # Connect to the fake server.... - self.runCmd("process connect -p gdb-remote connect://localhost:12345") + self.runCmd("process connect -p gdb-remote connect://localhost:" + str(port)) if __name__ == '__main__': |