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 | |
parent | 2fc5d2d1dfaf623ce4e24cd8590565902f8c557c (diff) |
Notes
Diffstat (limited to 'packages/Python/lldbsuite/test/functionalities/thread')
23 files changed, 182 insertions, 359 deletions
diff --git a/packages/Python/lldbsuite/test/functionalities/thread/backtrace_all/TestBacktraceAll.py b/packages/Python/lldbsuite/test/functionalities/thread/backtrace_all/TestBacktraceAll.py index 91bc68577a43c..902adacb2abd4 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/backtrace_all/TestBacktraceAll.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/backtrace_all/TestBacktraceAll.py @@ -5,8 +5,9 @@ Test regression for Bug 25251. import os, time import unittest2 import lldb +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil class BreakpointAfterJoinTestCase(TestBase): diff --git a/packages/Python/lldbsuite/test/functionalities/thread/break_after_join/TestBreakAfterJoin.py b/packages/Python/lldbsuite/test/functionalities/thread/break_after_join/TestBreakAfterJoin.py index 43397a1223914..8ef0fb0a000d7 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/break_after_join/TestBreakAfterJoin.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/break_after_join/TestBreakAfterJoin.py @@ -8,8 +8,9 @@ from __future__ import print_function 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 BreakpointAfterJoinTestCase(TestBase): @@ -21,9 +22,9 @@ class BreakpointAfterJoinTestCase(TestBase): # Find the line number for our breakpoint. self.breakpoint = line_number('main.cpp', '// Set breakpoint here') - @expectedFailureDarwin("llvm.org/pr15824") # thread states not properly maintained - @expectedFailureFreeBSD("llvm.org/pr18190") # thread states not properly maintained - @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(self): """Test breakpoint handling after a thread join.""" self.build(dictionary=self.getBuildFlags()) diff --git a/packages/Python/lldbsuite/test/functionalities/thread/break_after_join/main.cpp b/packages/Python/lldbsuite/test/functionalities/thread/break_after_join/main.cpp index a63079524ee21..f9f33fda82bb6 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/break_after_join/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/thread/break_after_join/main.cpp @@ -19,24 +19,12 @@ volatile int g_test = 0; -// Note that although hogging the CPU while waiting for a variable to change -// would be terrible in production code, it's great for testing since it -// avoids a lot of messy context switching to get multiple threads synchronized. -#define do_nothing() - -#define pseudo_barrier_wait(bar) \ - --bar; \ - while (bar > 0) \ - do_nothing(); - -#define pseudo_barrier_init(bar, count) (bar = count) - // A barrier to synchronize all the threads. -std::atomic_int g_barrier1; +pseudo_barrier_t g_barrier1; // A barrier to keep the threads from exiting until after the breakpoint has // been passed. -std::atomic_int g_barrier2; +pseudo_barrier_t g_barrier2; void * break_thread_func () diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentEvents.py b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentEvents.py index 9eb25b68765ac..30adcccd203fa 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentEvents.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentEvents.py @@ -17,11 +17,11 @@ 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 @skipIfWindows -@expectedFailureAll(archs=['mips64', 'mips64el']) # Atomic sequences are not supported yet for MIPS in LLDB. class ConcurrentEventsTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -30,24 +30,28 @@ class ConcurrentEventsTestCase(TestBase): ## Tests for multiple threads that generate a single event. # @unittest2.skipIf(TestBase.skipLongRunningTest(), "Skip this long running test") + @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB. def test_many_breakpoints(self): """Test 100 breakpoints from 100 threads.""" self.build(dictionary=self.getBuildFlags()) self.do_thread_actions(num_breakpoint_threads=100) @unittest2.skipIf(TestBase.skipLongRunningTest(), "Skip this long running test") + @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB. def test_many_watchpoints(self): """Test 100 watchpoints from 100 threads.""" self.build(dictionary=self.getBuildFlags()) self.do_thread_actions(num_watchpoint_threads=100) @unittest2.skipIf(TestBase.skipLongRunningTest(), "Skip this long running test") + @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB. def test_many_signals(self): """Test 100 signals from 100 threads.""" self.build(dictionary=self.getBuildFlags()) self.do_thread_actions(num_signal_threads=100) @unittest2.skipIf(TestBase.skipLongRunningTest(), "Skip this long running test") + @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB. def test_many_crash(self): """Test 100 threads that cause a segfault.""" self.build(dictionary=self.getBuildFlags()) @@ -58,18 +62,21 @@ class ConcurrentEventsTestCase(TestBase): ## Tests for concurrent signal and breakpoint # @skipIfFreeBSD # timing out on buildbot + @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB. def test_signal_break(self): """Test signal and a breakpoint in multiple threads.""" self.build(dictionary=self.getBuildFlags()) self.do_thread_actions(num_breakpoint_threads=1, num_signal_threads=1) @skipIfFreeBSD # timing out on buildbot + @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB. def test_delay_signal_break(self): """Test (1-second delay) signal and a breakpoint in multiple threads.""" self.build(dictionary=self.getBuildFlags()) self.do_thread_actions(num_breakpoint_threads=1, num_delay_signal_threads=1) @skipIfFreeBSD # timing out on buildbot + @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB. def test_signal_delay_break(self): """Test signal and a (1 second delay) breakpoint in multiple threads.""" self.build(dictionary=self.getBuildFlags()) @@ -81,6 +88,7 @@ class ConcurrentEventsTestCase(TestBase): # @skipIfFreeBSD # timing out on buildbot @skipIfRemoteDueToDeadlock + @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB. def test_watch_break(self): """Test watchpoint and a breakpoint in multiple threads.""" self.build(dictionary=self.getBuildFlags()) @@ -88,6 +96,7 @@ class ConcurrentEventsTestCase(TestBase): @skipIfFreeBSD # timing out on buildbot @skipIfRemoteDueToDeadlock + @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB. def test_delay_watch_break(self): """Test (1-second delay) watchpoint and a breakpoint in multiple threads.""" self.build(dictionary=self.getBuildFlags()) @@ -95,6 +104,7 @@ class ConcurrentEventsTestCase(TestBase): @skipIfFreeBSD # timing out on buildbot @skipIfRemoteDueToDeadlock + @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB. def test_watch_break_delay(self): """Test watchpoint and a (1 second delay) breakpoint in multiple threads.""" self.build(dictionary=self.getBuildFlags()) @@ -105,6 +115,7 @@ class ConcurrentEventsTestCase(TestBase): # @skipIfFreeBSD # timing out on buildbot @skipIfRemoteDueToDeadlock + @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB. def test_signal_watch(self): """Test a watchpoint and a signal in multiple threads.""" self.build(dictionary=self.getBuildFlags()) @@ -112,6 +123,7 @@ class ConcurrentEventsTestCase(TestBase): @skipIfFreeBSD # timing out on buildbot @skipIfRemoteDueToDeadlock + @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB. def test_delay_signal_watch(self): """Test a watchpoint and a (1 second delay) signal in multiple threads.""" self.build(dictionary=self.getBuildFlags()) @@ -119,7 +131,7 @@ class ConcurrentEventsTestCase(TestBase): @skipIfFreeBSD # timing out on buildbot @skipIfRemoteDueToDeadlock - @expectedFailureAll("llvm.org/pr16714", oslist=["linux"], archs=["i386"]) + @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB. def test_signal_delay_watch(self): """Test a (1 second delay) watchpoint and a signal in multiple threads.""" self.build(dictionary=self.getBuildFlags()) @@ -130,12 +142,14 @@ class ConcurrentEventsTestCase(TestBase): ## Tests for multiple breakpoint threads # @skipIfFreeBSD # timing out on buildbot + @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB. def test_two_breakpoint_threads(self): """Test two threads that trigger a breakpoint. """ self.build(dictionary=self.getBuildFlags()) self.do_thread_actions(num_breakpoint_threads=2) @skipIfFreeBSD # timing out on buildbot + @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB. def test_breakpoint_one_delay_breakpoint_threads(self): """Test threads that trigger a breakpoint where one thread has a 1 second delay. """ self.build(dictionary=self.getBuildFlags()) @@ -143,12 +157,14 @@ class ConcurrentEventsTestCase(TestBase): num_delay_breakpoint_threads=1) @skipIfFreeBSD # timing out on buildbot + @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB. def test_two_breakpoints_one_signal(self): """Test two threads that trigger a breakpoint and one signal thread. """ self.build(dictionary=self.getBuildFlags()) self.do_thread_actions(num_breakpoint_threads=2, num_signal_threads=1) @skipIfFreeBSD # timing out on buildbot + @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB. def test_breakpoint_delay_breakpoint_one_signal(self): """Test two threads that trigger a breakpoint (one with a 1 second delay) and one signal thread. """ self.build(dictionary=self.getBuildFlags()) @@ -157,6 +173,7 @@ class ConcurrentEventsTestCase(TestBase): num_signal_threads=1) @skipIfFreeBSD # timing out on buildbot + @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB. def test_two_breakpoints_one_delay_signal(self): """Test two threads that trigger a breakpoint and one (1 second delay) signal thread. """ self.build(dictionary=self.getBuildFlags()) @@ -164,6 +181,7 @@ class ConcurrentEventsTestCase(TestBase): @skipIfFreeBSD # timing out on buildbot @skipIfRemoteDueToDeadlock + @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB. def test_two_breakpoints_one_watchpoint(self): """Test two threads that trigger a breakpoint and one watchpoint thread. """ self.build(dictionary=self.getBuildFlags()) @@ -171,6 +189,7 @@ class ConcurrentEventsTestCase(TestBase): @skipIfFreeBSD # timing out on buildbot @skipIfRemoteDueToDeadlock + @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB. def test_breakpoints_delayed_breakpoint_one_watchpoint(self): """Test a breakpoint, a delayed breakpoint, and one watchpoint thread. """ self.build(dictionary=self.getBuildFlags()) @@ -183,6 +202,7 @@ class ConcurrentEventsTestCase(TestBase): # @skipIfFreeBSD # timing out on buildbot @skipIfRemoteDueToDeadlock + @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB. def test_two_watchpoint_threads(self): """Test two threads that trigger a watchpoint. """ self.build(dictionary=self.getBuildFlags()) @@ -190,6 +210,7 @@ class ConcurrentEventsTestCase(TestBase): @skipIfFreeBSD # timing out on buildbot @skipIfRemoteDueToDeadlock + @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB. def test_watchpoint_with_delay_watchpoint_threads(self): """Test two threads that trigger a watchpoint where one thread has a 1 second delay. """ self.build(dictionary=self.getBuildFlags()) @@ -198,6 +219,7 @@ class ConcurrentEventsTestCase(TestBase): @skipIfFreeBSD # timing out on buildbot @skipIfRemoteDueToDeadlock + @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB. def test_two_watchpoints_one_breakpoint(self): """Test two threads that trigger a watchpoint and one breakpoint thread. """ self.build(dictionary=self.getBuildFlags()) @@ -205,6 +227,7 @@ class ConcurrentEventsTestCase(TestBase): @skipIfFreeBSD # timing out on buildbot @skipIfRemoteDueToDeadlock + @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB. def test_two_watchpoints_one_delay_breakpoint(self): """Test two threads that trigger a watchpoint and one (1 second delay) breakpoint thread. """ self.build(dictionary=self.getBuildFlags()) @@ -212,6 +235,7 @@ class ConcurrentEventsTestCase(TestBase): @skipIfFreeBSD # timing out on buildbot @skipIfRemoteDueToDeadlock + @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB. def test_watchpoint_delay_watchpoint_one_breakpoint(self): """Test two threads that trigger a watchpoint (one with a 1 second delay) and one breakpoint thread. """ self.build(dictionary=self.getBuildFlags()) @@ -221,6 +245,7 @@ class ConcurrentEventsTestCase(TestBase): @skipIfFreeBSD # timing out on buildbot @skipIfRemoteDueToDeadlock + @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB. def test_two_watchpoints_one_signal(self): """Test two threads that trigger a watchpoint and one signal thread. """ self.build(dictionary=self.getBuildFlags()) @@ -231,6 +256,7 @@ class ConcurrentEventsTestCase(TestBase): # @skipIfFreeBSD # timing out on buildbot @skipIfRemoteDueToDeadlock + @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB. def test_signal_watch_break(self): """Test a signal/watchpoint/breakpoint in multiple threads.""" self.build(dictionary=self.getBuildFlags()) @@ -240,6 +266,7 @@ class ConcurrentEventsTestCase(TestBase): @skipIfFreeBSD # timing out on buildbot @skipIfRemoteDueToDeadlock + @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB. def test_signal_watch_break(self): """Test one signal thread with 5 watchpoint and breakpoint threads.""" self.build(dictionary=self.getBuildFlags()) @@ -249,6 +276,7 @@ class ConcurrentEventsTestCase(TestBase): @skipIfFreeBSD # timing out on buildbot @skipIfRemoteDueToDeadlock + @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB. def test_signal_watch_break(self): """Test with 5 watchpoint and breakpoint threads.""" self.build(dictionary=self.getBuildFlags()) @@ -260,6 +288,7 @@ class ConcurrentEventsTestCase(TestBase): ## Test for crashing threads happening concurrently with other events # @skipIfFreeBSD # timing out on buildbot + @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB. def test_crash_with_break(self): """ Test a thread that crashes while another thread hits a breakpoint.""" self.build(dictionary=self.getBuildFlags()) @@ -267,12 +296,14 @@ class ConcurrentEventsTestCase(TestBase): @skipIfFreeBSD # timing out on buildbot @skipIfRemoteDueToDeadlock + @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB. def test_crash_with_watchpoint(self): """ Test a thread that crashes while another thread hits a watchpoint.""" self.build(dictionary=self.getBuildFlags()) self.do_thread_actions(num_crash_threads=1, num_watchpoint_threads=1) @skipIfFreeBSD # timing out on buildbot + @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB. def test_crash_with_signal(self): """ Test a thread that crashes while another thread generates a signal.""" self.build(dictionary=self.getBuildFlags()) @@ -280,6 +311,7 @@ class ConcurrentEventsTestCase(TestBase): @skipIfFreeBSD # timing out on buildbot @skipIfRemoteDueToDeadlock + @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB. def test_crash_with_watchpoint_breakpoint_signal(self): """ Test a thread that crashes while other threads generate a signal and hit a watchpoint and breakpoint. """ self.build(dictionary=self.getBuildFlags()) @@ -290,6 +322,7 @@ class ConcurrentEventsTestCase(TestBase): @skipIfFreeBSD # timing out on buildbot @skipIfRemoteDueToDeadlock + @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB. def test_delayed_crash_with_breakpoint_watchpoint(self): """ Test a thread with a delayed crash while other threads hit a watchpoint and a breakpoint. """ self.build(dictionary=self.getBuildFlags()) @@ -298,6 +331,7 @@ class ConcurrentEventsTestCase(TestBase): num_watchpoint_threads=1) @skipIfFreeBSD # timing out on buildbot + @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB. def test_delayed_crash_with_breakpoint_signal(self): """ Test a thread with a delayed crash while other threads generate a signal and hit a breakpoint. """ self.build(dictionary=self.getBuildFlags()) diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/main.cpp b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/main.cpp index ac2535cd2bffa..10b55bff3ba44 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/main.cpp @@ -23,22 +23,10 @@ using namespace std; #include <sys/types.h> #include <unistd.h> -// Note that although hogging the CPU while waiting for a variable to change -// would be terrible in production code, it's great for testing since it -// avoids a lot of messy context switching to get multiple threads synchronized. -#define do_nothing() - -#define pseudo_barrier_wait(bar) \ - --bar; \ - while (bar > 0) \ - do_nothing(); - -#define pseudo_barrier_init(bar, count) (bar = count) - typedef std::vector<std::pair<unsigned, void*(*)(void*)> > action_counts; typedef std::vector<pthread_t> thread_vector; -std::atomic_int g_barrier; +pseudo_barrier_t g_barrier; int g_breakpoint = 0; int g_sigusr1_count = 0; std::atomic_int g_watchme; diff --git a/packages/Python/lldbsuite/test/functionalities/thread/crash_during_step/TestCrashDuringStep.py b/packages/Python/lldbsuite/test/functionalities/thread/crash_during_step/TestCrashDuringStep.py index 24b5bf0dad364..edd1e885ca9e2 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/crash_during_step/TestCrashDuringStep.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/crash_during_step/TestCrashDuringStep.py @@ -8,8 +8,9 @@ from __future__ import print_function import os import lldb +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil class CreateDuringStepTestCase(TestBase): @@ -19,9 +20,10 @@ class CreateDuringStepTestCase(TestBase): TestBase.setUp(self) self.breakpoint = line_number('main.cpp', '// Set breakpoint here') - @expectedFailureWindows("llvm.org/pr24778") + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778") @expectedFailureAndroid("llvm.org/pr24497", archs=['arm', 'aarch64']) - @expectedFailureAll(archs=['mips', 'mipsel', 'mips64', 'mips64el']) # IO error due to breakpoint at invalid address + @expectedFailureAll(oslist=["linux"], archs=["arm"], bugnumber="llvm.org/pr24497") + @expectedFailureAll(triple = re.compile('^mips')) # IO error due to breakpoint at invalid address def test_step_inst_with(self): """Test thread creation during step-inst handling.""" self.build(dictionary=self.getBuildFlags()) @@ -38,11 +40,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/packages/Python/lldbsuite/test/functionalities/thread/create_after_attach/TestCreateAfterAttach.py b/packages/Python/lldbsuite/test/functionalities/thread/create_after_attach/TestCreateAfterAttach.py index 977254343aa00..1cb97355395fa 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/create_after_attach/TestCreateAfterAttach.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/create_after_attach/TestCreateAfterAttach.py @@ -8,8 +8,9 @@ from __future__ import print_function 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 CreateAfterAttachTestCase(TestBase): @@ -29,7 +30,6 @@ class CreateAfterAttachTestCase(TestBase): # for FreeBSD. @skipIfRemote @skipIfWindows # Windows doesn't have fork. - @expectedFlakeyLinux("llvm.org/pr16229") # 1/100 dosep, build 3546, clang-3.5 x84_64 @skipIfiOSSimulator def test_create_after_attach_with_fork(self): """Test thread creation after process attach.""" diff --git a/packages/Python/lldbsuite/test/functionalities/thread/create_during_step/TestCreateDuringStep.py b/packages/Python/lldbsuite/test/functionalities/thread/create_during_step/TestCreateDuringStep.py index 046a86509c0f3..9401826e304e8 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/create_during_step/TestCreateDuringStep.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/create_during_step/TestCreateDuringStep.py @@ -8,35 +8,36 @@ from __future__ import print_function 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 CreateDuringStepTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @expectedFailureDarwin("llvm.org/pr15824") # thread states not properly maintained - @expectedFailureFreeBSD("llvm.org/pr18190") # thread states not properly maintained - @expectedFailureLinux("llvm.org/pr15824") # thread states not properly maintained - @expectedFailureWindows("llvm.org/pr24668") # Breakpoints not resolved correctly + @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") + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24668: Breakpoints not resolved correctly") def test_step_inst(self): """Test thread creation during step-inst handling.""" self.build(dictionary=self.getBuildFlags()) self.create_during_step_base("thread step-inst -m all-threads", 'stop reason = instruction step') - @expectedFailureDarwin("llvm.org/pr15824") # thread states not properly maintained - @expectedFailureFreeBSD("llvm.org/pr18190") # thread states not properly maintained - @expectedFailureLinux("llvm.org/pr15824") # thread states not properly maintained - @expectedFailureWindows("llvm.org/pr24668") # Breakpoints not resolved correctly + @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") + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24668: Breakpoints not resolved correctly") def test_step_over(self): """Test thread creation during step-over handling.""" self.build(dictionary=self.getBuildFlags()) self.create_during_step_base("thread step-over -m all-threads", 'stop reason = step over') - @expectedFailureDarwin("llvm.org/pr15824") # thread states not properly maintained - @expectedFailureFreeBSD("llvm.org/pr18190") # thread states not properly maintained - @expectedFailureLinux("llvm.org/pr15824") # thread states not properly maintained - @expectedFailureWindows("llvm.org/pr24668") # Breakpoints not resolved correctly + @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") + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24668: Breakpoints not resolved correctly") def test_step_in(self): """Test thread creation during step-in handling.""" self.build(dictionary=self.getBuildFlags()) diff --git a/packages/Python/lldbsuite/test/functionalities/thread/create_during_step/main.cpp b/packages/Python/lldbsuite/test/functionalities/thread/create_during_step/main.cpp index 3a00248c022a2..70681fd11603b 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/create_during_step/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/thread/create_during_step/main.cpp @@ -13,19 +13,9 @@ #include <atomic> #include <thread> -// Note that although hogging the CPU while waiting for a variable to change -// would be terrible in production code, it's great for testing since it -// avoids a lot of messy context switching to get multiple threads synchronized. #define do_nothing() -#define pseudo_barrier_wait(bar) \ - --bar; \ - while (bar > 0) \ - do_nothing(); - -#define pseudo_barrier_init(bar, count) (bar = count) - -std::atomic_int g_barrier; +pseudo_barrier_t g_barrier; volatile int g_thread_created = 0; volatile int g_test = 0; diff --git a/packages/Python/lldbsuite/test/functionalities/thread/exit_during_break/TestExitDuringBreak.py b/packages/Python/lldbsuite/test/functionalities/thread/exit_during_break/TestExitDuringBreak.py index f999ffe108f37..2c394263d36e1 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/exit_during_break/TestExitDuringBreak.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/exit_during_break/TestExitDuringBreak.py @@ -8,8 +8,9 @@ from __future__ import print_function 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 ExitDuringBreakpointTestCase(TestBase): @@ -21,10 +22,10 @@ class ExitDuringBreakpointTestCase(TestBase): # Find the line number for our breakpoint. self.breakpoint = line_number('main.cpp', '// Set breakpoint here') - @expectedFailureDarwin("llvm.org/pr15824") # thread states not properly maintained - @expectedFailureFreeBSD("llvm.org/pr18190") # thread states not properly maintained - @expectedFailureLinux("llvm.org/pr15824") # thread states not properly maintained - @expectedFailureWindows("llvm.org/pr24668") # Breakpoints not resolved correctly + @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") + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24668: Breakpoints not resolved correctly") def test(self): """Test thread exit during breakpoint handling.""" self.build(dictionary=self.getBuildFlags()) diff --git a/packages/Python/lldbsuite/test/functionalities/thread/exit_during_break/main.cpp b/packages/Python/lldbsuite/test/functionalities/thread/exit_during_break/main.cpp index 3570637207d2d..a032da835ea6a 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/exit_during_break/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/thread/exit_during_break/main.cpp @@ -19,27 +19,15 @@ volatile int g_test = 0; -// Note that although hogging the CPU while waiting for a variable to change -// would be terrible in production code, it's great for testing since it -// avoids a lot of messy context switching to get multiple threads synchronized. -#define do_nothing() - -#define pseudo_barrier_wait(bar) \ - --bar; \ - while (bar > 0) \ - do_nothing(); - -#define pseudo_barrier_init(bar, count) (bar = count) - // A barrier to synchronize all the threads except the one that will exit. -std::atomic_int g_barrier1; +pseudo_barrier_t g_barrier1; // A barrier to synchronize all the threads including the one that will exit. -std::atomic_int g_barrier2; +pseudo_barrier_t g_barrier2; // A barrier to keep the first group of threads from exiting until after the // breakpoint has been passed. -std::atomic_int g_barrier3; +pseudo_barrier_t g_barrier3; void * break_thread_func () diff --git a/packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/TestExitDuringStep.py b/packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/TestExitDuringStep.py index 67d1c96fd3424..af4a022ed0c15 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/TestExitDuringStep.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/TestExitDuringStep.py @@ -8,42 +8,31 @@ from __future__ import print_function 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 ExitDuringStepTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @expectedFailureDarwin("llvm.org/pr15824") # thread states not properly maintained - @expectedFailureFreeBSD("llvm.org/pr18190") # thread states not properly maintained - @expectedFailureLinux("llvm.org/pr15824") # thread states not properly maintained - @expectedFailureWindows("llvm.org/pr24681") - def test_thread_state_is_stopped(self): - """Test thread exit during step handling.""" - self.build(dictionary=self.getBuildFlags()) - self.exit_during_step_base("thread step-in -m all-threads", 'stop reason = step in', True) - @skipIfFreeBSD # llvm.org/pr21411: test is hanging - @expectedFailureWindows("llvm.org/pr24681") def test(self): """Test thread exit during step handling.""" self.build(dictionary=self.getBuildFlags()) - self.exit_during_step_base("thread step-inst -m all-threads", 'stop reason = instruction step', False) + self.exit_during_step_base("thread step-inst -m all-threads", 'stop reason = instruction step') @skipIfFreeBSD # llvm.org/pr21411: test is hanging - @expectedFailureWindows("llvm.org/pr24681") def test_step_over(self): """Test thread exit during step-over handling.""" self.build(dictionary=self.getBuildFlags()) - self.exit_during_step_base("thread step-over -m all-threads", 'stop reason = step over', False) + self.exit_during_step_base("thread step-over -m all-threads", 'stop reason = step over') @skipIfFreeBSD # llvm.org/pr21411: test is hanging - @expectedFailureWindows("llvm.org/pr24681") def test_step_in(self): """Test thread exit during step-in handling.""" self.build(dictionary=self.getBuildFlags()) - self.exit_during_step_base("thread step-in -m all-threads", 'stop reason = step in', False) + self.exit_during_step_base("thread step-in -m all-threads", 'stop reason = step in') def setUp(self): # Call super's setUp(). @@ -52,7 +41,7 @@ class ExitDuringStepTestCase(TestBase): self.breakpoint = line_number('main.cpp', '// Set breakpoint here') self.continuepoint = line_number('main.cpp', '// Continue from here') - def exit_during_step_base(self, step_cmd, step_stop_reason, test_thread_state): + def exit_during_step_base(self, step_cmd, step_stop_reason): """Test thread exit during step handling.""" exe = os.path.join(os.getcwd(), "a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) @@ -76,37 +65,16 @@ class ExitDuringStepTestCase(TestBase): target = self.dbg.GetSelectedTarget() process = target.GetProcess() - # Get the number of threads 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.') - - # Get the thread objects - thread1 = process.GetThreadAtIndex(0) - thread2 = process.GetThreadAtIndex(1) - thread3 = process.GetThreadAtIndex(2) - - # Make sure all threads are stopped - if test_thread_state: - self.assertTrue(thread1.IsStopped(), "Thread 1 didn't stop during breakpoint") - self.assertTrue(thread2.IsStopped(), "Thread 2 didn't stop during breakpoint") - self.assertTrue(thread3.IsStopped(), "Thread 3 didn't stop during breakpoint") - return - - # Find the thread that is stopped at the breakpoint - stepping_thread = None - for thread in process: - expected_bp_desc = "breakpoint %s." % self.bp_num - stop_desc = thread.GetStopDescription(100) - if stop_desc and (expected_bp_desc in stop_desc): - stepping_thread = thread - break - self.assertTrue(stepping_thread != None, "unable to find thread stopped at %s" % expected_bp_desc) + self.assertGreaterEqual(num_threads, 3, 'Number of expected threads and actual threads do not match.') + + stepping_thread = lldbutil.get_one_thread_stopped_at_breakpoint_id(process, self.bp_num) + self.assertIsNotNone(stepping_thread, "Could not find a thread stopped at the breakpoint") current_line = self.breakpoint stepping_frame = stepping_thread.GetFrameAtIndex(0) - self.assertTrue(current_line == stepping_frame.GetLineEntry().GetLine(), "Starting line for stepping doesn't match breakpoint line.") + self.assertEqual(current_line, stepping_frame.GetLineEntry().GetLine(), "Starting line for stepping doesn't match breakpoint line.") # Keep stepping until we've reached our designated continue point while current_line != self.continuepoint: @@ -122,16 +90,16 @@ class ExitDuringStepTestCase(TestBase): current_line = frame.GetLineEntry().GetLine() - self.assertTrue(current_line >= self.breakpoint, "Stepped to unexpected line, " + str(current_line)) - self.assertTrue(current_line <= self.continuepoint, "Stepped to unexpected line, " + str(current_line)) + self.assertGreaterEqual(current_line, self.breakpoint, "Stepped to unexpected line, " + str(current_line)) + self.assertLessEqual(current_line, self.continuepoint, "Stepped to unexpected line, " + str(current_line)) self.runCmd("thread list") # Update the number of threads - num_threads = process.GetNumThreads() + new_num_threads = process.GetNumThreads() # Check to see that we reduced the number of threads as expected - self.assertTrue(num_threads == 2, 'Number of expected threads and actual threads do not match after thread exit.') + self.assertEqual(new_num_threads, num_threads-1, 'Number of threads did not reduce by 1 after thread exit.') self.expect("thread list", 'Process state is stopped due to step', substrs = ['stopped', @@ -141,4 +109,4 @@ class ExitDuringStepTestCase(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) diff --git a/packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/main.cpp b/packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/main.cpp index d1b364b8baa2f..45adf28ce8130 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/main.cpp @@ -12,20 +12,10 @@ #include <thread> -// Note that although hogging the CPU while waiting for a variable to change -// would be terrible in production code, it's great for testing since it -// avoids a lot of messy context switching to get multiple threads synchronized. #define do_nothing() -#define pseudo_barrier_wait(bar) \ - --bar; \ - while (bar > 0) \ - do_nothing(); - -#define pseudo_barrier_init(bar, count) (bar = count) - // A barrier to synchronize thread start. -volatile int g_barrier; +pseudo_barrier_t g_barrier; volatile int g_thread_exited = 0; diff --git a/packages/Python/lldbsuite/test/functionalities/thread/jump/TestThreadJump.py b/packages/Python/lldbsuite/test/functionalities/thread/jump/TestThreadJump.py index 768e2fe4f87a8..4c55bcd982a74 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/jump/TestThreadJump.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/jump/TestThreadJump.py @@ -8,8 +8,9 @@ from __future__ import print_function 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 ThreadJumpTestCase(TestBase): diff --git a/packages/Python/lldbsuite/test/functionalities/thread/multi_break/TestMultipleBreakpoints.py b/packages/Python/lldbsuite/test/functionalities/thread/multi_break/TestMultipleBreakpoints.py index 9dd2124122160..d4b1eb32a9ae6 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/multi_break/TestMultipleBreakpoints.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/multi_break/TestMultipleBreakpoints.py @@ -8,8 +8,9 @@ from __future__ import print_function 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 MultipleBreakpointTestCase(TestBase): @@ -21,10 +22,10 @@ class MultipleBreakpointTestCase(TestBase): # Find the line number for our breakpoint. self.breakpoint = line_number('main.cpp', '// Set breakpoint here') - @expectedFailureDarwin("llvm.org/pr15824") # thread states not properly maintained - @expectedFailureFreeBSD("llvm.org/pr18190") # thread states not properly maintained - @expectedFailureLinux("llvm.org/pr15824") # thread states not properly maintained - @expectedFailureWindows("llvm.org/pr24668") # Breakpoints not resolved correctly + @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") + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24668: Breakpoints not resolved correctly") def test(self): """Test simultaneous breakpoints in multiple threads.""" self.build(dictionary=self.getBuildFlags()) @@ -55,7 +56,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/packages/Python/lldbsuite/test/functionalities/thread/multi_break/main.cpp b/packages/Python/lldbsuite/test/functionalities/thread/multi_break/main.cpp index 01f4b8f98ea76..c3d695dbc7453 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/multi_break/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/thread/multi_break/main.cpp @@ -15,19 +15,7 @@ #include <atomic> #include <thread> -// Note that although hogging the CPU while waiting for a variable to change -// would be terrible in production code, it's great for testing since it -// avoids a lot of messy context switching to get multiple threads synchronized. -#define do_nothing() - -#define pseudo_barrier_wait(bar) \ - --bar; \ - while (bar > 0) \ - do_nothing(); - -#define pseudo_barrier_init(bar, count) (bar = count) - -std::atomic_int g_barrier; +pseudo_barrier_t g_barrier; volatile int g_test = 0; diff --git a/packages/Python/lldbsuite/test/functionalities/thread/state/TestThreadStates.py b/packages/Python/lldbsuite/test/functionalities/thread/state/TestThreadStates.py index 4938ec50453e0..5afb57bf4ba89 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) diff --git a/packages/Python/lldbsuite/test/functionalities/thread/step_out/TestThreadStepOut.py b/packages/Python/lldbsuite/test/functionalities/thread/step_out/TestThreadStepOut.py index b2d966c4c0f3d..735ee80d624e3 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/step_out/TestThreadStepOut.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/step_out/TestThreadStepOut.py @@ -8,35 +8,36 @@ from __future__ import print_function 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 ThreadStepOutTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @skipIfLinux # Test occasionally times out on the Linux build bot - @expectedFailureLinux("llvm.org/pr23477") # Test occasionally times out on the Linux build bot - @expectedFailureFreeBSD("llvm.org/pr18066") # inferior does not exit - @expectedFailureWindows # Test crashes + @expectedFailureAll(oslist=["linux"], bugnumber="llvm.org/pr23477 Test occasionally times out on the Linux build bot") + @expectedFailureAll(oslist=["freebsd"], bugnumber="llvm.org/pr18066 inferior does not exit") + @expectedFailureAll(oslist=["windows"]) def test_step_single_thread(self): """Test thread step out on one thread via command interpreter. """ self.build(dictionary=self.getBuildFlags()) self.step_out_test(self.step_out_single_thread_with_cmd) @skipIfLinux # Test occasionally times out on the Linux build bot - @expectedFailureLinux("llvm.org/pr23477") # Test occasionally times out on the Linux build bot - @expectedFailureFreeBSD("llvm.org/pr19347") # 2nd thread stops at breakpoint - @expectedFailureWindows # Test crashes + @expectedFailureAll(oslist=["linux"], bugnumber="llvm.org/pr23477 Test occasionally times out on the Linux build bot") + @expectedFailureAll(oslist=["freebsd"], bugnumber="llvm.org/pr19347 2nd thread stops at breakpoint") + @expectedFailureAll(oslist=["windows"]) def test_step_all_threads(self): """Test thread step out on all threads via command interpreter. """ self.build(dictionary=self.getBuildFlags()) self.step_out_test(self.step_out_all_threads_with_cmd) @skipIfLinux # Test occasionally times out on the Linux build bot - @expectedFailureLinux("llvm.org/pr23477") # Test occasionally times out on the Linux build bot - @expectedFailureFreeBSD("llvm.org/pr19347") - @expectedFailureWindows("llvm.org/pr24681") + @expectedFailureAll(oslist=["linux"], bugnumber="llvm.org/pr23477 Test occasionally times out on the Linux build bot") + @expectedFailureAll(oslist=["freebsd"], bugnumber="llvm.org/pr19347 2nd thread stops at breakpoint") + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24681") def test_python(self): """Test thread step out on one thread via Python API (dwarf).""" self.build(dictionary=self.getBuildFlags()) diff --git a/packages/Python/lldbsuite/test/functionalities/thread/step_out/main.cpp b/packages/Python/lldbsuite/test/functionalities/thread/step_out/main.cpp index b4c6216d6bfe0..31f9a1576b929 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/step_out/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/thread/step_out/main.cpp @@ -13,19 +13,7 @@ #include <atomic> #include <thread> -// Note that although hogging the CPU while waiting for a variable to change -// would be terrible in production code, it's great for testing since it -// avoids a lot of messy context switching to get multiple threads synchronized. -#define do_nothing() - -#define pseudo_barrier_wait(bar) \ - --bar; \ - while (bar > 0) \ - do_nothing(); - -#define pseudo_barrier_init(bar, count) (bar = count) - -std::atomic_int g_barrier; +pseudo_barrier_t g_barrier; volatile int g_test = 0; diff --git a/packages/Python/lldbsuite/test/functionalities/thread/thread_exit/TestThreadExit.py b/packages/Python/lldbsuite/test/functionalities/thread/thread_exit/TestThreadExit.py index f785401277a47..2ba6f2e57f2b5 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/thread_exit/TestThreadExit.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/thread_exit/TestThreadExit.py @@ -24,7 +24,6 @@ class ThreadExitTestCase(TestBase): self.break_3 = line_number('main.cpp', '// Set third breakpoint here') self.break_4 = line_number('main.cpp', '// Set fourth breakpoint here') - @expectedFailureWindows("llvm.org/pr24681") def test(self): """Test thread exit handling.""" self.build(dictionary=self.getBuildFlags()) @@ -32,10 +31,10 @@ class ThreadExitTestCase(TestBase): self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # This should create a breakpoint with 1 location. - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.break_1, num_expected_locations=1) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.break_2, num_expected_locations=1) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.break_3, num_expected_locations=1) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.break_4, num_expected_locations=1) + bp1_id = lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.break_1, num_expected_locations=1) + bp2_id = lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.break_2, num_expected_locations=1) + bp3_id = lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.break_3, num_expected_locations=1) + bp4_id = lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.break_4, num_expected_locations=1) # The breakpoint list should show 1 locations. self.expect("breakpoint list -f", "Breakpoint location shown correctly", @@ -46,71 +45,46 @@ class ThreadExitTestCase(TestBase): # Run the program. self.runCmd("run", RUN_SUCCEEDED) - - # The stop reason of the thread should be breakpoint 1. - self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT + " 1", - substrs = ['stopped', - '* thread #1', - 'stop reason = breakpoint 1', - 'thread #2']) - # Get the target process target = self.dbg.GetSelectedTarget() process = target.GetProcess() + stopped_thread = lldbutil.get_one_thread_stopped_at_breakpoint_id(process, bp1_id) + self.assertIsNotNone(stopped_thread, "Process is not stopped at breakpoint 1") + # Get the number of threads num_threads = process.GetNumThreads() - - self.assertTrue(num_threads == 2, 'Number of expected threads and actual threads do not match at breakpoint 1.') + self.assertGreaterEqual(num_threads, 2, 'Number of expected threads and actual threads do not match at breakpoint 1.') # Run to the second breakpoint self.runCmd("continue") - - # The stop reason of the thread should be breakpoint 1. - self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT + " 2", - substrs = ['stopped', - 'thread #1', - 'thread #2', - 'stop reason = breakpoint 2', - 'thread #3']) + stopped_thread = lldbutil.get_one_thread_stopped_at_breakpoint_id(process, bp2_id) + self.assertIsNotNone(stopped_thread, "Process is not stopped at breakpoint 2") # Update the number of threads - num_threads = process.GetNumThreads() - - self.assertTrue(num_threads == 3, 'Number of expected threads and actual threads do not match at breakpoint 2.') + new_num_threads = process.GetNumThreads() + self.assertEqual(new_num_threads, num_threads+1, 'Number of expected threads did not increase by 1 at bp 2.') # Run to the third breakpoint self.runCmd("continue") - - # The stop reason of the thread should be breakpoint 3. - self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT + " 3", - substrs = ['stopped', - 'thread #1', - 'stop reason = breakpoint 3', - 'thread #3', - ]) + stopped_thread = lldbutil.get_one_thread_stopped_at_breakpoint_id(process, bp3_id) + self.assertIsNotNone(stopped_thread, "Process is not stopped at breakpoint 3") # Update the number of threads - num_threads = process.GetNumThreads() - - self.assertTrue(num_threads == 2, 'Number of expected threads and actual threads do not match at breakpoint 3.') + new_num_threads = process.GetNumThreads() + self.assertEqual(new_num_threads, num_threads, 'Number of expected threads is not equal to original number of threads at bp 3.') # Run to the fourth breakpoint self.runCmd("continue") - - # The stop reason of the thread should be breakpoint 4. - self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT + " 4", - substrs = ['stopped', - 'thread #1', - 'stop reason = breakpoint 4']) + stopped_thread = lldbutil.get_one_thread_stopped_at_breakpoint_id(process, bp4_id) + self.assertIsNotNone(stopped_thread, "Process is not stopped at breakpoint 4") # Update the number of threads - num_threads = process.GetNumThreads() - - self.assertTrue(num_threads == 1, 'Number of expected threads and actual threads do not match at breakpoint 4.') + new_num_threads = process.GetNumThreads() + self.assertEqual(new_num_threads, num_threads-1, 'Number of expected threads did not decrease by 1 at bp 4.') # Run to completion 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) diff --git a/packages/Python/lldbsuite/test/functionalities/thread/thread_exit/main.cpp b/packages/Python/lldbsuite/test/functionalities/thread/thread_exit/main.cpp index e498db7895d2b..c57db9f485277 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/thread_exit/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/thread/thread_exit/main.cpp @@ -12,21 +12,9 @@ #include <atomic> #include <thread> -// Note that although hogging the CPU while waiting for a variable to change -// would be terrible in production code, it's great for testing since it -// avoids a lot of messy context switching to get multiple threads synchronized. -#define do_nothing() - -#define pseudo_barrier_wait(bar) \ - --bar; \ - while (bar > 0) \ - do_nothing(); - -#define pseudo_barrier_init(bar, count) (bar = count) - -std::atomic_int g_barrier1; -std::atomic_int g_barrier2; -std::atomic_int g_barrier3; +pseudo_barrier_t g_barrier1; +pseudo_barrier_t g_barrier2; +pseudo_barrier_t g_barrier3; void * thread1 () diff --git a/packages/Python/lldbsuite/test/functionalities/thread/thread_specific_break/TestThreadSpecificBreakpoint.py b/packages/Python/lldbsuite/test/functionalities/thread/thread_specific_break/TestThreadSpecificBreakpoint.py index 3c69b6667f7da..12bacabd0d789 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/thread_specific_break/TestThreadSpecificBreakpoint.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/thread_specific_break/TestThreadSpecificBreakpoint.py @@ -9,15 +9,16 @@ from __future__ import print_function import os, time import re import lldb -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil class ThreadSpecificBreakTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @add_test_categories(['pyapi']) - @expectedFailureWindows # Thread specific breakpoints cause the inferior to crash + @expectedFailureAll(oslist=["windows"]) def test_python(self): """Test that we obey thread conditioned breakpoints.""" self.build() diff --git a/packages/Python/lldbsuite/test/functionalities/thread/thread_specific_break_plus_condition/TestThreadSpecificBpPlusCondition.py b/packages/Python/lldbsuite/test/functionalities/thread/thread_specific_break_plus_condition/TestThreadSpecificBpPlusCondition.py index 68c96a0fba756..ccb58c965b3fb 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/thread_specific_break_plus_condition/TestThreadSpecificBpPlusCondition.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/thread_specific_break_plus_condition/TestThreadSpecificBpPlusCondition.py @@ -10,17 +10,17 @@ from __future__ import print_function import os, time import re import lldb -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil class ThreadSpecificBreakPlusConditionTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @skipIfFreeBSD # test frequently times out or hangs - @expectedFailureFreeBSD('llvm.org/pr18522') # hits break in another thread in testrun + @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr18522') # hits break in another thread in testrun @add_test_categories(['pyapi']) - @expectedFlakeyLinux # this test fails 6/100 dosep runs def test_python(self): """Test that we obey thread conditioned breakpoints.""" self.build() |