forked from OSchip/llvm-project
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. llvm-svn: 130767
This commit is contained in:
parent
09585e1c5d
commit
b2a27481c1
|
@ -679,7 +679,10 @@ class TestBase(unittest2.TestCase):
|
|||
# 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.
|
||||
|
|
|
@ -34,51 +34,53 @@ class StopHookTestCase(TestBase):
|
|||
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__':
|
||||
|
|
Loading…
Reference in New Issue