Use a more gentle way of shutting down the child process spawned during the test execution using pexpect.

Change some child.expect() to child.expect_exact() as they try to match the string, not a regular expression.

llvm-svn: 130797
This commit is contained in:
Johnny Chen 2011-05-03 22:14:19 +00:00
parent effe5c956b
commit 0934268ee1
3 changed files with 11 additions and 8 deletions

View File

@ -14,7 +14,7 @@ class CommandRegexTestCase(TestBase):
def test_command_regex(self):
"""Test a simple scenario of 'command regexp' invocation and subsequent use."""
prompt = "\(lldb\) "
prompt = "(lldb) "
regex_prompt = "Enter regular expressions in the form 's/<regex>/<subst>/' and terminate with an empty line:\r\n"
regex_prompt1 = "\r\n"
@ -25,12 +25,12 @@ class CommandRegexTestCase(TestBase):
# 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)
# Substitute 'Help!' for 'help' using the 'commands regex' mechanism.
child.expect_exact(prompt)
child.sendline("command regex 'Help!'")
child.expect(regex_prompt)
child.expect_exact(regex_prompt)
child.sendline('s/^$/help/')
child.expect(regex_prompt1)
child.expect_exact(regex_prompt1)
child.sendline('')
# Help!
child.sendline('Help!')

View File

@ -29,7 +29,7 @@ class ConnectRemoteTestCase(TestBase):
self.addTearDownHook(shutdown_fakeserver)
# Wait until we receive the server ready message before continuing.
fakeserver.expect('Listening on localhost:12345')
fakeserver.expect_exact('Listening on localhost:12345')
# Connect to the fake server....
self.runCmd("process connect connect://localhost:12345")

View File

@ -678,12 +678,15 @@ class TestBase(unittest2.TestCase):
# This is for the case of directly spawning 'lldb' and interacting with it
# using pexpect.
import pexpect
if self.child and self.child.isalive():
with recording(self, traceAlways) as sbuf:
print >> sbuf, "tearing down the child process...."
self.child.sendline('quit')
time.sleep(2)
self.child.close()
try:
self.child.expect(pexpect.EOF)
except:
pass
# Terminate the current process being debugged, if any.
if self.runStarted: