[Lldb-commits] [lldb] r130767 - in /lldb/trunk/test: lldbtest.py stop-hook/TestStopHook.py

Johnny Chen johnny.chen at apple.com
Tue May 3 10:38:06 PDT 2011


Author: johnny
Date: Tue May  3 12:38:06 2011
New Revision: 130767

URL: http://llvm.org/viewvc/llvm-project?rev=130767&view=rev
Log:
A more robust pexpect-based test case for testing against the firing of stop hooks.
Change one test sequence to detect the '** End Stop Hooks **' marker emitted by the
stop hooks mechanism and check for whether the 'expr ptr' stop-hook has been run.

Also, change the TestBase.tearDown() to wait for 2 seocnds before forcefully kill
the pexpect-spawned child lldb process.

Modified:
    lldb/trunk/test/lldbtest.py
    lldb/trunk/test/stop-hook/TestStopHook.py

Modified: lldb/trunk/test/lldbtest.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=130767&r1=130766&r2=130767&view=diff
==============================================================================
--- lldb/trunk/test/lldbtest.py (original)
+++ lldb/trunk/test/lldbtest.py Tue May  3 12:38:06 2011
@@ -679,7 +679,10 @@
         # This is for the case of directly spawning 'lldb' and interacting with it
         # using 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()
 
         # Terminate the current process being debugged, if any.

Modified: lldb/trunk/test/stop-hook/TestStopHook.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/stop-hook/TestStopHook.py?rev=130767&r1=130766&r2=130767&view=diff
==============================================================================
--- lldb/trunk/test/stop-hook/TestStopHook.py (original)
+++ lldb/trunk/test/stop-hook/TestStopHook.py Tue May  3 12:38:06 2011
@@ -34,51 +34,53 @@
     def stop_hook_command_sequence(self):
         """Test a sequence of target stop-hook commands."""
         exe = os.path.join(os.getcwd(), "a.out")
-        prompt = "\r\n\(lldb\) "
-        add_prompt = "Enter your stop hook command\(s\).  Type 'DONE' to end.\r\n> "
+        prompt = "(lldb) "
+        add_prompt = "Enter your stop hook command(s).  Type 'DONE' to end.\r\n> "
         add_prompt1 = "\r\n> "
 
-        child = pexpect.spawn('%s %s' % (self.lldbExec, exe))
+        # So that the child gets torn down after the test.
+        self.child = pexpect.spawn('%s %s' % (self.lldbExec, exe))
+        child = self.child
         # Turn on logging for what the child sends back.
         if self.TraceOn():
             child.logfile_read = sys.stdout
 
         # Set the breakpoint, followed by the target stop-hook commands.
-        child.expect(prompt)
+        child.expect_exact(prompt)
         child.sendline('breakpoint set -f main.cpp -l %d' % self.begl)
-        child.expect(prompt)
+        child.expect_exact(prompt)
         child.sendline('breakpoint set -f main.cpp -l %d' % self.line)
-        child.expect(prompt)
+        child.expect_exact(prompt)
         child.sendline('target stop-hook add -f main.cpp -l %d -e %d' % (self.begl, self.endl))
-        child.expect(add_prompt)
+        child.expect_exact(add_prompt)
         child.sendline('expr ptr')
-        child.expect(add_prompt1)
+        child.expect_exact(add_prompt1)
         child.sendline('DONE')
-        child.expect(prompt)
+        child.expect_exact(prompt)
         child.sendline('target stop-hook list')
 
         # Now run the program, expect to stop at the the first breakpoint which is within the stop-hook range.
-        child.expect(prompt)
+        child.expect_exact(prompt)
         child.sendline('run')
-        child.expect(prompt)
-        self.DebugPExpect(child)
+        child.expect_exact(prompt)
         child.sendline('thread step-over')
-        child.expect(prompt)
-        self.DebugPExpect(child)
+        #self.DebugPExpect(child)
+        child.expect_exact('** End Stop Hooks **')
+        #self.DebugPExpect(child)
         # Verify that the 'Stop Hooks' mechanism is fired off.
         self.expect(child.before, exe=False,
-            substrs = ['Stop Hooks'])
+            substrs = ['(void *) $0 = 0x'])
 
         # Now continue the inferior, we'll stop at another breakpoint which is outside the stop-hook range.
         child.sendline('process continue')
-        child.expect(prompt)
-        self.DebugPExpect(child)
+        child.expect_exact(prompt)
+        #self.DebugPExpect(child)
         child.sendline('thread step-over')
-        child.expect(prompt)
-        self.DebugPExpect(child)
+        child.expect_exact(prompt)
+        #self.DebugPExpect(child)
         # Verify that the 'Stop Hooks' mechanism is NOT BEING fired off.
         self.expect(child.before, exe=False, matching=False,
-            substrs = ['Stop Hooks'])
+            substrs = ['(void *) $0 = 0x'])
         
 
 if __name__ == '__main__':





More information about the lldb-commits mailing list