From 0934268ee107fb23591734a6a6dd1cad6347ec17 Mon Sep 17 00:00:00 2001 From: Johnny Chen Date: Tue, 3 May 2011 22:14:19 +0000 Subject: [PATCH] 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 --- lldb/test/command_regex/TestCommandRegex.py | 10 +++++----- lldb/test/connect_remote/TestConnectRemote.py | 2 +- lldb/test/lldbtest.py | 7 +++++-- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/lldb/test/command_regex/TestCommandRegex.py b/lldb/test/command_regex/TestCommandRegex.py index a11077d116c2..45af6e41490f 100644 --- a/lldb/test/command_regex/TestCommandRegex.py +++ b/lldb/test/command_regex/TestCommandRegex.py @@ -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///' 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!') diff --git a/lldb/test/connect_remote/TestConnectRemote.py b/lldb/test/connect_remote/TestConnectRemote.py index 428038e4af74..d7674feeef04 100644 --- a/lldb/test/connect_remote/TestConnectRemote.py +++ b/lldb/test/connect_remote/TestConnectRemote.py @@ -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") diff --git a/lldb/test/lldbtest.py b/lldb/test/lldbtest.py index a0cb3cdaf609..35c2595d2b97 100644 --- a/lldb/test/lldbtest.py +++ b/lldb/test/lldbtest.py @@ -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: