[Lldb-commits] [lldb] r256928 - Fix a bug in lldbutil.expect_state_changes
Pavel Labath via lldb-commits
lldb-commits at lists.llvm.org
Wed Jan 6 03:40:07 PST 2016
Author: labath
Date: Wed Jan 6 05:40:06 2016
New Revision: 256928
URL: http://llvm.org/viewvc/llvm-project?rev=256928&view=rev
Log:
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.
Modified:
lldb/trunk/packages/Python/lldbsuite/test/lldbutil.py
Modified: lldb/trunk/packages/Python/lldbsuite/test/lldbutil.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lldbutil.py?rev=256928&r1=256927&r2=256928&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/lldbutil.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/lldbutil.py Wed Jan 6 05:40:06 2016
@@ -737,17 +737,25 @@ def print_stacktraces(process, string_bu
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
More information about the lldb-commits
mailing list