diff options
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/functionalities')
5 files changed, 27 insertions, 98 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/consecutive_breakpoins/TestConsecutiveBreakpoints.py b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/consecutive_breakpoins/TestConsecutiveBreakpoints.py index af6df376482..1a3b26f4548 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/consecutive_breakpoins/TestConsecutiveBreakpoints.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/consecutive_breakpoins/TestConsecutiveBreakpoints.py @@ -27,7 +27,7 @@ class ConsecutiveBreakpoitsTestCase(TestBase): target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) - breakpoint = target.BreakpointCreateBySourceRegex("Set breakpoint here", lldb.SBFileSpec("main.cpp")) + breakpoint1 = target.BreakpointCreateBySourceRegex("Set breakpoint here", lldb.SBFileSpec("main.cpp")) self.assertTrue(breakpoint and breakpoint.GetNumLocations() == 1, VALID_BREAKPOINT) @@ -37,8 +37,8 @@ class ConsecutiveBreakpoitsTestCase(TestBase): self.assertTrue(process, PROCESS_IS_VALID) # We should be stopped at the first breakpoint - thread = process.GetThreadAtIndex(0) - self.assertEqual(thread.GetStopReason(), lldb.eStopReasonBreakpoint) + thread = lldbutil.get_one_thread_stopped_at_breakpoint(process, breakpoint1) + self.assertIsNotNone(thread, "Expected one thread to be stopped at breakpoint 1") # Set breakpoint to the next instruction frame = thread.GetFrameAtIndex(0) @@ -48,12 +48,12 @@ class ConsecutiveBreakpoitsTestCase(TestBase): self.assertTrue(len(instructions) == 2) address = instructions[1].GetAddress() - target.BreakpointCreateByAddress(address.GetLoadAddress(target)) + breakpoint2 = target.BreakpointCreateByAddress(address.GetLoadAddress(target)) process.Continue() # We should be stopped at the second breakpoint - thread = process.GetThreadAtIndex(0) - self.assertEqual(thread.GetStopReason(), lldb.eStopReasonBreakpoint) + thread = lldbutil.get_one_thread_stopped_at_breakpoint(process, breakpoint2) + self.assertIsNotNone(thread, "Expected one thread to be stopped at breakpoint 2") # Run the process until termination process.Continue() diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/conditional_break/TestConditionalBreak.py b/lldb/packages/Python/lldbsuite/test/functionalities/conditional_break/TestConditionalBreak.py index 3ae7a20b4c7..cfd20f07323 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/conditional_break/TestConditionalBreak.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/conditional_break/TestConditionalBreak.py @@ -64,7 +64,8 @@ class ConditionalBreakTestCase(TestBase): for j in range(10): if self.TraceOn(): print("j is: ", j) - thread = process.GetThreadAtIndex(0) + thread = lldbutil.get_one_thread_stopped_at_breakpoint(process, breakpoint) + self.assertIsNotNone(thread, "Expected one thread to be stopped at the breakpoint") if thread.GetNumFrames() >= 2: frame0 = thread.GetFrameAtIndex(0) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/thread/crash_during_step/TestCrashDuringStep.py b/lldb/packages/Python/lldbsuite/test/functionalities/thread/crash_during_step/TestCrashDuringStep.py index 24b5bf0dad3..7bb1564e082 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/thread/crash_during_step/TestCrashDuringStep.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/thread/crash_during_step/TestCrashDuringStep.py @@ -38,11 +38,8 @@ class CreateDuringStepTestCase(TestBase): # The stop reason should be breakpoint. self.assertEqual(process.GetState(), lldb.eStateStopped, PROCESS_STOPPED) - self.assertEqual(lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint).IsValid(), 1, - STOPPED_DUE_TO_BREAKPOINT) - - thread = process.GetThreadAtIndex(0) - self.assertTrue(thread and thread.IsValid(), "Thread is valid") + thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) + self.assertTrue(thread.IsValid(), STOPPED_DUE_TO_BREAKPOINT) # Keep stepping until the inferior crashes while process.GetState() == lldb.eStateStopped and not lldbutil.is_thread_crashed(self, thread): diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/thread/multi_break/TestMultipleBreakpoints.py b/lldb/packages/Python/lldbsuite/test/functionalities/thread/multi_break/TestMultipleBreakpoints.py index 9dd21241221..65d9bfdb5ca 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/thread/multi_break/TestMultipleBreakpoints.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/thread/multi_break/TestMultipleBreakpoints.py @@ -55,7 +55,7 @@ class MultipleBreakpointTestCase(TestBase): num_threads = process.GetNumThreads() # Make sure we see all three threads - self.assertTrue(num_threads == 3, 'Number of expected threads and actual threads do not match.') + self.assertTrue(num_threads >= 3, 'Number of expected threads and actual threads do not match.') # Get the thread objects thread1 = process.GetThreadAtIndex(0) 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 4938ec50453..11912c67be4 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/thread/state/TestThreadStates.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/thread/state/TestThreadStates.py @@ -69,28 +69,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.") @@ -117,23 +106,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) # Continue, the inferior will go into an infinite loop waiting for 'g_test' to change. self.dbg.SetAsync(True) @@ -162,23 +140,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,20 +169,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.') + 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) @@ -228,11 +187,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 +207,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.") @@ -289,11 +232,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 +245,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 +260,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) |