[test] make expect_state_changes actually expect *only* them
The android dirty stderr problem has uncovered an issue where lldbutil.expect_state_changes was reading events other than state change events, which resulted in general confusion. Make it more strict to accept *only* state changes. llvm-svn: 266327
This commit is contained in:
parent
e6961d0306
commit
7e49e3d97c
|
@ -38,19 +38,20 @@ class AttachResumeTestCase(TestBase):
|
|||
|
||||
self.setAsync(True)
|
||||
listener = self.dbg.GetListener()
|
||||
process = self.dbg.GetSelectedTarget().GetProcess()
|
||||
|
||||
self.runCmd("c")
|
||||
lldbutil.expect_state_changes(self, listener, [lldb.eStateRunning])
|
||||
lldbutil.expect_state_changes(self, listener, process, [lldb.eStateRunning])
|
||||
|
||||
self.runCmd("process interrupt")
|
||||
lldbutil.expect_state_changes(self, listener, [lldb.eStateStopped])
|
||||
lldbutil.expect_state_changes(self, listener, process, [lldb.eStateStopped])
|
||||
|
||||
# be sure to continue/interrupt/continue (r204504)
|
||||
self.runCmd("c")
|
||||
lldbutil.expect_state_changes(self, listener, [lldb.eStateRunning])
|
||||
lldbutil.expect_state_changes(self, listener, process, [lldb.eStateRunning])
|
||||
|
||||
self.runCmd("process interrupt")
|
||||
lldbutil.expect_state_changes(self, listener, [lldb.eStateStopped])
|
||||
lldbutil.expect_state_changes(self, listener, process, [lldb.eStateStopped])
|
||||
|
||||
# Second interrupt should have no effect.
|
||||
self.expect("process interrupt", patterns=["Process is not running"], error=True)
|
||||
|
@ -59,7 +60,7 @@ class AttachResumeTestCase(TestBase):
|
|||
self.runCmd("br set -f main.cpp -l %u" % (line_number('main.cpp', '// Set breakpoint here')))
|
||||
|
||||
self.runCmd("c")
|
||||
lldbutil.expect_state_changes(self, listener, [lldb.eStateRunning, lldb.eStateStopped])
|
||||
lldbutil.expect_state_changes(self, listener, process, [lldb.eStateRunning, lldb.eStateStopped])
|
||||
self.expect('br list', 'Breakpoint not hit',
|
||||
substrs = ['hit count = 1'])
|
||||
|
||||
|
@ -67,8 +68,8 @@ class AttachResumeTestCase(TestBase):
|
|||
self.expect("expr debugger_flag = false", substrs=[" = false"]);
|
||||
|
||||
self.runCmd("c")
|
||||
lldbutil.expect_state_changes(self, listener, [lldb.eStateRunning])
|
||||
lldbutil.expect_state_changes(self, listener, process, [lldb.eStateRunning])
|
||||
|
||||
# make sure to detach while in running state (r204759)
|
||||
self.runCmd("detach")
|
||||
lldbutil.expect_state_changes(self, listener, [lldb.eStateDetached])
|
||||
lldbutil.expect_state_changes(self, listener, process, [lldb.eStateDetached])
|
||||
|
|
|
@ -89,11 +89,11 @@ class ThreadStateTestCase(TestBase):
|
|||
# Kill the process
|
||||
self.runCmd("process kill")
|
||||
|
||||
def wait_for_running_event(self):
|
||||
def wait_for_running_event(self, process):
|
||||
listener = self.dbg.GetListener()
|
||||
if lldb.remote_platform:
|
||||
lldbutil.expect_state_changes(self, listener, [lldb.eStateConnected])
|
||||
lldbutil.expect_state_changes(self, listener, [lldb.eStateRunning])
|
||||
lldbutil.expect_state_changes(self, listener, process, [lldb.eStateConnected])
|
||||
lldbutil.expect_state_changes(self, listener, process, [lldb.eStateRunning])
|
||||
|
||||
def thread_state_after_continue_test(self):
|
||||
"""Test thread state after continue."""
|
||||
|
@ -117,7 +117,7 @@ class ThreadStateTestCase(TestBase):
|
|||
# Continue, the inferior will go into an infinite loop waiting for 'g_test' to change.
|
||||
self.dbg.SetAsync(True)
|
||||
self.runCmd("continue")
|
||||
self.wait_for_running_event()
|
||||
self.wait_for_running_event(process)
|
||||
|
||||
# Check the thread state. It should be running.
|
||||
self.assertFalse(thread.IsStopped(), "Thread state is \'stopped\' when it should be running.")
|
||||
|
|
|
@ -750,14 +750,15 @@ def print_stacktraces(process, string_buffer = False):
|
|||
if string_buffer:
|
||||
return output.getvalue()
|
||||
|
||||
def expect_state_changes(test, listener, states, timeout = 5):
|
||||
def expect_state_changes(test, listener, process, states, timeout = 5):
|
||||
"""Listens for state changed events on the listener and makes sure they match what we
|
||||
expect. Stop-and-restart events (where GetRestartedFromEvent() returns true) are ignored."""
|
||||
|
||||
for expected_state in states:
|
||||
def get_next_event():
|
||||
event = lldb.SBEvent()
|
||||
if not listener.WaitForEvent(timeout, event):
|
||||
if not listener.WaitForEventForBroadcasterWithType(timeout, process.GetBroadcaster(),
|
||||
lldb.SBProcess.eBroadcastBitStateChanged, event):
|
||||
test.fail("Timed out while waiting for a transition to state %s" %
|
||||
lldb.SBDebugger.StateAsCString(expected_state))
|
||||
return event
|
||||
|
|
Loading…
Reference in New Issue