[Lldb-commits] [lldb] r266327 - [test] make expect_state_changes actually expect *only* them
Pavel Labath via lldb-commits
lldb-commits at lists.llvm.org
Thu Apr 14 08:52:58 PDT 2016
Author: labath
Date: Thu Apr 14 10:52:58 2016
New Revision: 266327
URL: http://llvm.org/viewvc/llvm-project?rev=266327&view=rev
Log:
[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.
Modified:
lldb/trunk/packages/Python/lldbsuite/test/functionalities/attach_resume/TestAttachResume.py
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/state/TestThreadStates.py
lldb/trunk/packages/Python/lldbsuite/test/lldbutil.py
Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/attach_resume/TestAttachResume.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/attach_resume/TestAttachResume.py?rev=266327&r1=266326&r2=266327&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/attach_resume/TestAttachResume.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/attach_resume/TestAttachResume.py Thu Apr 14 10:52:58 2016
@@ -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])
Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/state/TestThreadStates.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/state/TestThreadStates.py?rev=266327&r1=266326&r2=266327&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/state/TestThreadStates.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/state/TestThreadStates.py Thu Apr 14 10:52:58 2016
@@ -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.")
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=266327&r1=266326&r2=266327&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/lldbutil.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/lldbutil.py Thu Apr 14 10:52:58 2016
@@ -750,14 +750,15 @@ def print_stacktraces(process, string_bu
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
More information about the lldb-commits
mailing list