[Lldb-commits] [lldb] r217388 - Fix test failure for test/functionalities/connect_remote/TestConnectRemote.py when port 12345 is already in use

Kuba Brecka kuba.brecka at gmail.com
Mon Sep 8 10:06:55 PDT 2014


Author: kuba.brecka
Date: Mon Sep  8 12:06:54 2014
New Revision: 217388

URL: http://llvm.org/viewvc/llvm-project?rev=217388&view=rev
Log:
Fix test failure for test/functionalities/connect_remote/TestConnectRemote.py when port 12345 is already in use

Reviewed at http://reviews.llvm.org/D5221


Modified:
    lldb/trunk/test/functionalities/connect_remote/EchoServer.py
    lldb/trunk/test/functionalities/connect_remote/TestConnectRemote.py

Modified: lldb/trunk/test/functionalities/connect_remote/EchoServer.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/connect_remote/EchoServer.py?rev=217388&r1=217387&r2=217388&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/connect_remote/EchoServer.py (original)
+++ lldb/trunk/test/functionalities/connect_remote/EchoServer.py Mon Sep  8 12:06:54 2014
@@ -8,10 +8,11 @@ Taken from http://docs.python.org/librar
 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

Modified: lldb/trunk/test/functionalities/connect_remote/TestConnectRemote.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/connect_remote/TestConnectRemote.py?rev=217388&r1=217387&r2=217388&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/connect_remote/TestConnectRemote.py (original)
+++ lldb/trunk/test/functionalities/connect_remote/TestConnectRemote.py Mon Sep  8 12:06:54 2014
@@ -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__':





More information about the lldb-commits mailing list