diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2016-07-23 20:50:09 +0000 | 
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2016-07-23 20:50:09 +0000 | 
| commit | f3fbd1c0586ff6ec7895991e6c28f61a503c36a8 (patch) | |
| tree | 48d008fd3df8c0e73271a4b18474e0aac6dbfe33 /packages/Python/lldbsuite/test/functionalities/thread/state | |
| parent | 2fc5d2d1dfaf623ce4e24cd8590565902f8c557c (diff) | |
Notes
Diffstat (limited to 'packages/Python/lldbsuite/test/functionalities/thread/state')
| -rw-r--r-- | packages/Python/lldbsuite/test/functionalities/thread/state/TestThreadStates.py | 134 | 
1 files changed, 33 insertions, 101 deletions
| diff --git a/packages/Python/lldbsuite/test/functionalities/thread/state/TestThreadStates.py b/packages/Python/lldbsuite/test/functionalities/thread/state/TestThreadStates.py index 4938ec50453e..5afb57bf4ba8 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/state/TestThreadStates.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/state/TestThreadStates.py @@ -9,25 +9,26 @@ from __future__ import print_function  import unittest2  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class ThreadStateTestCase(TestBase):      mydir = TestBase.compute_mydir(__file__) -    @expectedFailureDarwin("rdar://15367566") -    @expectedFailureFreeBSD('llvm.org/pr15824') -    @expectedFailureLinux("llvm.org/pr15824") # thread states not properly maintained +    @expectedFailureAll(oslist=["linux"], bugnumber="llvm.org/pr15824 thread states not properly maintained") +    @expectedFailureAll(oslist=lldbplatformutil.getDarwinOSTriples(), bugnumber="llvm.org/pr15824 thread states not properly maintained") +    @expectedFailureAll(oslist=["freebsd"], bugnumber="llvm.org/pr18190 thread states not properly maintained")      def test_state_after_breakpoint(self):          """Test thread state after breakpoint."""          self.build(dictionary=self.getBuildFlags(use_cpp11=False))          self.thread_state_after_breakpoint_test()      @skipIfDarwin # 'llvm.org/pr23669', cause Python crash randomly -    @expectedFailureDarwin('llvm.org/pr23669') -    @expectedFailureFreeBSD('llvm.org/pr15824') -    @expectedFailureWindows("llvm.org/pr24660") +    @expectedFailureAll(oslist=lldbplatformutil.getDarwinOSTriples(), bugnumber="llvm.org/pr23669") +    @expectedFailureAll(oslist=["freebsd"], bugnumber="llvm.org/pr15824") +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24660")      def test_state_after_continue(self):          """Test thread state after continue."""          self.build(dictionary=self.getBuildFlags(use_cpp11=False)) @@ -35,7 +36,7 @@ class ThreadStateTestCase(TestBase):      @skipIfDarwin # 'llvm.org/pr23669', cause Python crash randomly      @expectedFailureDarwin('llvm.org/pr23669') -    @expectedFailureWindows("llvm.org/pr24660") +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24660")      @unittest2.expectedFailure("llvm.org/pr16712") # thread states not properly maintained      def test_state_after_expression(self):          """Test thread state after expression.""" @@ -43,14 +44,14 @@ class ThreadStateTestCase(TestBase):          self.thread_state_after_expression_test()      @unittest2.expectedFailure("llvm.org/pr16712") # thread states not properly maintained -    @expectedFailureWindows("llvm.org/pr24668") # Breakpoints not resolved correctly +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24668: Breakpoints not resolved correctly")      def test_process_interrupt(self):          """Test process interrupt."""          self.build(dictionary=self.getBuildFlags(use_cpp11=False))          self.process_interrupt_test()      @unittest2.expectedFailure("llvm.org/pr15824") # thread states not properly maintained -    @expectedFailureWindows("llvm.org/pr24668") # Breakpoints not resolved correctly +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24668: Breakpoints not resolved correctly")      def test_process_state(self):          """Test thread states (comprehensive)."""          self.build(dictionary=self.getBuildFlags(use_cpp11=False)) @@ -69,28 +70,17 @@ class ThreadStateTestCase(TestBase):          self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)          # This should create a breakpoint in the main thread. -        lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.break_1, num_expected_locations=1) +        bp = lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.break_1, num_expected_locations=1)          # Run the program.          self.runCmd("run", RUN_SUCCEEDED) -        # The stop reason of the thread should be breakpoint. -        self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, -            substrs = ['stopped', -                       '* thread #1', -                       'stop reason = breakpoint']) -          # Get the target process          target = self.dbg.GetSelectedTarget()          process = target.GetProcess() -        # Get the number of threads -        num_threads = process.GetNumThreads() - -        self.assertTrue(num_threads == 1, 'Number of expected threads and actual threads do not match.') - -        # Get the thread object -        thread = process.GetThreadAtIndex(0) +        thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) +        self.assertIsNotNone(thread)          # Make sure the thread is in the stopped state.          self.assertTrue(thread.IsStopped(), "Thread state isn't \'stopped\' during breakpoint 1.") @@ -99,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,28 +107,17 @@ class ThreadStateTestCase(TestBase):          # Run the program.          self.runCmd("run", RUN_SUCCEEDED) -        # The stop reason of the thread should be breakpoint. -        self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, -            substrs = ['stopped', -                       '* thread #1', -                       'stop reason = breakpoint']) -          # Get the target process          target = self.dbg.GetSelectedTarget()          process = target.GetProcess() -        # Get the number of threads -        num_threads = process.GetNumThreads() - -        self.assertTrue(num_threads == 1, 'Number of expected threads and actual threads do not match.') - -        # Get the thread object -        thread = process.GetThreadAtIndex(0) +        thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) +        self.assertIsNotNone(thread)          # 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.") @@ -162,23 +141,12 @@ class ThreadStateTestCase(TestBase):          # Run the program.          self.runCmd("run", RUN_SUCCEEDED) -        # The stop reason of the thread should be breakpoint. -        self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, -            substrs = ['stopped', -                       '* thread #1', -                       'stop reason = breakpoint']) -          # Get the target process          target = self.dbg.GetSelectedTarget()          process = target.GetProcess() -        # Get the number of threads -        num_threads = process.GetNumThreads() - -        self.assertTrue(num_threads == 1, 'Number of expected threads and actual threads do not match.') - -        # Get the thread object -        thread = process.GetThreadAtIndex(0) +        thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) +        self.assertIsNotNone(thread)          # Get the inferior out of its loop          self.runCmd("expression g_test = 1") @@ -202,25 +170,17 @@ class ThreadStateTestCase(TestBase):          # Run the program.          self.runCmd("run", RUN_SUCCEEDED) -        # The stop reason of the thread should be breakpoint. -        self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, -            substrs = ['stopped', -                       '* thread #1', -                       'stop reason = breakpoint']) -          # Get the target process          target = self.dbg.GetSelectedTarget()          process = target.GetProcess() -        # Get the number of threads -        num_threads = process.GetNumThreads() - -        self.assertTrue(num_threads == 1, 'Number of expected threads and actual threads do not match.') +        thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) +        self.assertIsNotNone(thread)          # 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)          # Go back to synchronous interactions          self.dbg.SetAsync(False) @@ -228,11 +188,7 @@ class ThreadStateTestCase(TestBase):          # Stop the process          self.runCmd("process interrupt") -        # The stop reason of the thread should be signal. -        self.expect("process status", STOPPED_DUE_TO_SIGNAL, -            substrs = ['stopped', -                       '* thread #1', -                       'stop reason = signal']) +        self.assertEqual(thread.GetStopReason(), lldb.eStopReasonSignal)          # Get the inferior out of its loop          self.runCmd("expression g_test = 1") @@ -252,23 +208,11 @@ class ThreadStateTestCase(TestBase):          # Run the program.          self.runCmd("run", RUN_SUCCEEDED) -        # The stop reason of the thread should be breakpoint. -        self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, -            substrs = ['stopped', -                       '* thread #1', -                       'stop reason = breakpoint']) -          # Get the target process          target = self.dbg.GetSelectedTarget()          process = target.GetProcess() - -        # Get the number of threads -        num_threads = process.GetNumThreads() - -        self.assertTrue(num_threads == 1, 'Number of expected threads and actual threads do not match.') - -        # Get the thread object -        thread = process.GetThreadAtIndex(0) +        thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) +        self.assertIsNotNone(thread)          # Make sure the thread is in the stopped state.          self.assertTrue(thread.IsStopped(), "Thread state isn't \'stopped\' during breakpoint 1.") @@ -277,7 +221,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.") @@ -289,11 +233,7 @@ class ThreadStateTestCase(TestBase):          # Stop the process          self.runCmd("process interrupt") -        # The stop reason of the thread should be signal. -        self.expect("process status", STOPPED_DUE_TO_SIGNAL, -            substrs = ['stopped', -                       '* thread #1', -                       'stop reason = signal']) +        self.assertEqual(thread.GetState(), lldb.eStopReasonSignal)          # Check the thread state          self.assertTrue(thread.IsStopped(), "Thread state isn't \'stopped\' after process stop.") @@ -306,20 +246,12 @@ class ThreadStateTestCase(TestBase):          self.assertTrue(thread.IsStopped(), "Thread state isn't \'stopped\' after expression evaluation.")          self.assertFalse(thread.IsSuspended(), "Thread state is \'suspended\' after expression evaluation.") -        # The stop reason of the thread should be signal. -        self.expect("process status", STOPPED_DUE_TO_SIGNAL, -            substrs = ['stopped', -                       '* thread #1', -                       'stop reason = signal']) +        self.assertEqual(thread.GetState(), lldb.eStopReasonSignal)          # Run to breakpoint 2          self.runCmd("continue") -        # The stop reason of the thread should be breakpoint. -        self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, -            substrs = ['stopped', -                       '* thread #1', -                       'stop reason = breakpoint']) +        self.assertEqual(thread.GetState(), lldb.eStopReasonBreakpoint)          # Make sure both threads are stopped          self.assertTrue(thread.IsStopped(), "Thread state isn't \'stopped\' during breakpoint 2.") @@ -329,4 +261,4 @@ class ThreadStateTestCase(TestBase):          self.runCmd("continue")          # At this point, the inferior process should have exited. -        self.assertTrue(process.GetState() == lldb.eStateExited, PROCESS_EXITED) +        self.assertEqual(process.GetState(), lldb.eStateExited, PROCESS_EXITED) | 
