summaryrefslogtreecommitdiffstats
path: root/lldb/packages/Python/lldbsuite/test
diff options
context:
space:
mode:
authorPavel Labath <labath@google.com>2016-04-14 15:52:58 +0000
committerPavel Labath <labath@google.com>2016-04-14 15:52:58 +0000
commit7e49e3d97cd84ac5c758fd444788a33ac5171be0 (patch)
treea6868334394d588db590776aea2717f901e001b1 /lldb/packages/Python/lldbsuite/test
parente6961d0306d0631bb9218d2c88a8ca657259eb35 (diff)
downloadbcm5719-llvm-7e49e3d97cd84ac5c758fd444788a33ac5171be0.tar.gz
bcm5719-llvm-7e49e3d97cd84ac5c758fd444788a33ac5171be0.zip
[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
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test')
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/attach_resume/TestAttachResume.py15
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/thread/state/TestThreadStates.py8
-rw-r--r--lldb/packages/Python/lldbsuite/test/lldbutil.py5
3 files changed, 15 insertions, 13 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/attach_resume/TestAttachResume.py b/lldb/packages/Python/lldbsuite/test/functionalities/attach_resume/TestAttachResume.py
index 9b3bbae1646..54463c56827 100644
--- a/lldb/packages/Python/lldbsuite/test/functionalities/attach_resume/TestAttachResume.py
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/attach_resume/TestAttachResume.py
@@ -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])
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/thread/state/TestThreadStates.py b/lldb/packages/Python/lldbsuite/test/functionalities/thread/state/TestThreadStates.py
index a6a33d7af61..160a3eff784 100644
--- a/lldb/packages/Python/lldbsuite/test/functionalities/thread/state/TestThreadStates.py
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/thread/state/TestThreadStates.py
@@ -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.")
diff --git a/lldb/packages/Python/lldbsuite/test/lldbutil.py b/lldb/packages/Python/lldbsuite/test/lldbutil.py
index 021ae2db8f4..45e9bb407d1 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbutil.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbutil.py
@@ -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
OpenPOWER on IntegriCloud