[Lldb-commits] [lldb] r130015 - in /lldb/trunk/test: command_regex/TestCommandRegex.py connect_remote/TestConnectRemote.py

Johnny Chen johnny.chen at apple.com
Fri Apr 22 14:47:08 PDT 2011


Author: johnny
Date: Fri Apr 22 16:47:07 2011
New Revision: 130015

URL: http://llvm.org/viewvc/llvm-project?rev=130015&view=rev
Log:
Make test_connect_remote() more robust by waiting on the server ready message
before issuing the 'process connect ...' command.

test_comand_regex(): assign the spawned child to self.child so it gets automatically
shutdown during TestBase.tearDown(self).

Modified:
    lldb/trunk/test/command_regex/TestCommandRegex.py
    lldb/trunk/test/connect_remote/TestConnectRemote.py

Modified: lldb/trunk/test/command_regex/TestCommandRegex.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/command_regex/TestCommandRegex.py?rev=130015&r1=130014&r2=130015&view=diff
==============================================================================
--- lldb/trunk/test/command_regex/TestCommandRegex.py (original)
+++ lldb/trunk/test/command_regex/TestCommandRegex.py Fri Apr 22 16:47:07 2011
@@ -22,6 +22,8 @@
         # Turn on logging for what the child sends back.
         if self.TraceOn():
             child.logfile_read = sys.stdout
+        # So that the spawned lldb session gets shutdown durng teardown.
+        self.child = child
 
         # Substitute 'Help!' with 'help' using the 'commands regex' mechanism.
         child.expect(prompt)
@@ -33,7 +35,7 @@
         # Help!
         child.sendline('Help!')
         # If we see the familiar 'help' output, the test is done.
-        child.expect('The following is a list of built-in, permanent debugger commands:')        
+        child.expect('The following is a list of built-in, permanent debugger commands:')
 
 if __name__ == '__main__':
     import atexit

Modified: lldb/trunk/test/connect_remote/TestConnectRemote.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/connect_remote/TestConnectRemote.py?rev=130015&r1=130014&r2=130015&view=diff
==============================================================================
--- lldb/trunk/test/connect_remote/TestConnectRemote.py (original)
+++ lldb/trunk/test/connect_remote/TestConnectRemote.py Fri Apr 22 16:47:07 2011
@@ -2,9 +2,10 @@
 Test lldb 'process connect' command.
 """
 
-import os, time
+import os
 import unittest2
 import lldb
+import pexpect
 from lldbtest import *
 
 class ConnectRemoteTestCase(TestBase):
@@ -16,14 +17,21 @@
         """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)
+        fakeserver = pexpect.spawn('./EchoServer.py')
 
+        # Turn on logging for what the child sends back.
+        if self.TraceOn():
+            fakeserver.logfile = sys.stdout
+
+        # Schedule the fake debugserver to be shut down during teardown.
+        def shutdown_fakeserver():
+            fakeserver.close()
+        self.addTearDownHook(shutdown_fakeserver)
+
+        # Wait until we receive the server ready message before continuing.
+        fakeserver.expect('Listening on localhost:12345')
+
+        # Connect to the fake server....
         self.runCmd("process connect connect://localhost:12345")
 
 





More information about the lldb-commits mailing list