summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohnny Chen <johnny.chen@apple.com>2011-04-22 21:47:07 +0000
committerJohnny Chen <johnny.chen@apple.com>2011-04-22 21:47:07 +0000
commitea76c4f229bdcbb955465bdc3f8a081c8dbd7ee8 (patch)
treefbe95134fe1a69d1cb0d5f23b12cd9bb9a44c150
parent8a51be9e1b5f11ca64fd7d1d0f5816897ef91b05 (diff)
downloadbcm5719-llvm-ea76c4f229bdcbb955465bdc3f8a081c8dbd7ee8.tar.gz
bcm5719-llvm-ea76c4f229bdcbb955465bdc3f8a081c8dbd7ee8.zip
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). llvm-svn: 130015
-rw-r--r--lldb/test/command_regex/TestCommandRegex.py4
-rw-r--r--lldb/test/connect_remote/TestConnectRemote.py24
2 files changed, 19 insertions, 9 deletions
diff --git a/lldb/test/command_regex/TestCommandRegex.py b/lldb/test/command_regex/TestCommandRegex.py
index fdb5246d1f1..a11077d116c 100644
--- a/lldb/test/command_regex/TestCommandRegex.py
+++ b/lldb/test/command_regex/TestCommandRegex.py
@@ -22,6 +22,8 @@ class CommandRegexTestCase(TestBase):
# 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 @@ class CommandRegexTestCase(TestBase):
# 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
diff --git a/lldb/test/connect_remote/TestConnectRemote.py b/lldb/test/connect_remote/TestConnectRemote.py
index eb8b4b90616..72ed6466d18 100644
--- a/lldb/test/connect_remote/TestConnectRemote.py
+++ b/lldb/test/connect_remote/TestConnectRemote.py
@@ -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 @@ class ConnectRemoteTestCase(TestBase):
"""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")
OpenPOWER on IntegriCloud