Skip to content

Commit 55ee541

Browse files
committed
[lldb/test] Clean up TestThreadSpecificBpPlusCondition inferior
The test had a race that could cause two threads to end up with the same "thread local" value. I believe this would not cause the test to fail, but it could cause it to succeed even when the functionality is broken. The new implementation removes this uncertainty, and removes a lot of cruft left over from the time this test was written using pthreads.
1 parent f9d0d0d commit 55ee541

File tree

2 files changed

+13
-30
lines changed

2 files changed

+13
-30
lines changed

lldb/test/API/functionalities/thread/thread_specific_break_plus_condition/TestThreadSpecificBpPlusCondition.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ class ThreadSpecificBreakPlusConditionTestCase(TestBase):
1919
@skipIfDarwin
2020
# hits break in another thread in testrun
2121
@add_test_categories(['pyapi'])
22-
@expectedFailureAll(oslist=['ios', 'watchos', 'tvos', 'bridgeos'], archs=['armv7', 'armv7k'], bugnumber='rdar://problem/34563348') # Two threads seem to end up with the same my_value when built for armv7.
2322
@expectedFlakeyNetBSD
2423
def test_python(self):
2524
"""Test that we obey thread conditioned breakpoints."""

lldb/test/API/functionalities/thread/thread_specific_break_plus_condition/main.cpp

Lines changed: 13 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,22 @@
22
#include <thread>
33
#include <vector>
44

5-
void *
6-
thread_function (void *thread_marker)
7-
{
8-
int keep_going = 1;
9-
int my_value = *((int *)thread_marker);
10-
int counter = 0;
11-
12-
while (counter < 20)
13-
{
14-
counter++; // Break here in thread body.
15-
std::this_thread::sleep_for(std::chrono::microseconds(10));
16-
}
17-
return NULL;
5+
void thread_function(int my_value) {
6+
int counter = 0;
7+
while (counter < 20) {
8+
counter++; // Break here in thread body.
9+
std::this_thread::sleep_for(std::chrono::microseconds(10));
10+
}
1811
}
1912

13+
int main() {
14+
std::vector<std::thread> threads;
2015

21-
int
22-
main ()
23-
{
24-
std::vector<std::thread> threads;
25-
26-
int thread_value = 0;
27-
int i;
28-
29-
for (i = 0; i < 10; i++)
30-
{
31-
thread_value += 1;
32-
threads.push_back(std::thread(thread_function, &thread_value));
33-
}
16+
for (int i = 0; i < 10; i++)
17+
threads.push_back(std::thread(thread_function, threads.size() + 1));
3418

35-
for (i = 0; i < 10; i++)
36-
threads[i].join();
19+
for (std::thread &t : threads)
20+
t.join();
3721

38-
return 0;
22+
return 0;
3923
}

0 commit comments

Comments
 (0)