forked from OSchip/llvm-project
Fix a bug in lldbutil.expect_state_changes
The logic for skipping over the stop-and-restart events was incorrect as it was also skipping the expectations. Implement it properly. No test is affected by this as they were not encountering these events, but I encountered this issue when trying to use this function in a new test. llvm-svn: 256928
This commit is contained in:
parent
070fac02c3
commit
e5c9808efd
|
@ -737,17 +737,25 @@ def print_stacktraces(process, string_buffer = False):
|
|||
def expect_state_changes(test, listener, 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."""
|
||||
event = lldb.SBEvent()
|
||||
|
||||
for expected_state in states:
|
||||
if not listener.WaitForEvent(timeout, event):
|
||||
test.fail("Timed out while waiting for a transition to state %s" %
|
||||
lldb.SBDebugger.StateAsCString(expected_state))
|
||||
def get_next_event():
|
||||
event = lldb.SBEvent()
|
||||
if not listener.WaitForEvent(timeout, event):
|
||||
test.fail("Timed out while waiting for a transition to state %s" %
|
||||
lldb.SBDebugger.StateAsCString(expected_state))
|
||||
return event
|
||||
|
||||
got_state = lldb.SBProcess.GetStateFromEvent(event)
|
||||
if got_state == lldb.eStateStopped and lldb.SBProcess.GetRestartedFromEvent(event):
|
||||
continue
|
||||
event = get_next_event()
|
||||
while (lldb.SBProcess.GetStateFromEvent(event) == lldb.eStateStopped and
|
||||
lldb.SBProcess.GetRestartedFromEvent(event)):
|
||||
# Ignore restarted event and the subsequent running event.
|
||||
event = get_next_event()
|
||||
test.assertEqual(lldb.SBProcess.GetStateFromEvent(event), lldb.eStateRunning,
|
||||
"Restarted event followed by a running event")
|
||||
event = get_next_event()
|
||||
|
||||
test.assertEqual(expected_state, got_state)
|
||||
test.assertEqual(lldb.SBProcess.GetStateFromEvent(event), expected_state)
|
||||
|
||||
# ===================================
|
||||
# Utility functions related to Frames
|
||||
|
|
Loading…
Reference in New Issue