[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.
This commit is contained in:
Pavel Labath 2021-04-21 17:31:41 +02:00
parent f9d0d0d7e0
commit 55ee541653
2 changed files with 13 additions and 30 deletions

View File

@ -19,7 +19,6 @@ class ThreadSpecificBreakPlusConditionTestCase(TestBase):
@skipIfDarwin
# hits break in another thread in testrun
@add_test_categories(['pyapi'])
@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.
@expectedFlakeyNetBSD
def test_python(self):
"""Test that we obey thread conditioned breakpoints."""

View File

@ -2,38 +2,22 @@
#include <thread>
#include <vector>
void *
thread_function (void *thread_marker)
{
int keep_going = 1;
int my_value = *((int *)thread_marker);
int counter = 0;
while (counter < 20)
{
counter++; // Break here in thread body.
std::this_thread::sleep_for(std::chrono::microseconds(10));
}
return NULL;
void thread_function(int my_value) {
int counter = 0;
while (counter < 20) {
counter++; // Break here in thread body.
std::this_thread::sleep_for(std::chrono::microseconds(10));
}
}
int main() {
std::vector<std::thread> threads;
int
main ()
{
std::vector<std::thread> threads;
for (int i = 0; i < 10; i++)
threads.push_back(std::thread(thread_function, threads.size() + 1));
int thread_value = 0;
int i;
for (std::thread &t : threads)
t.join();
for (i = 0; i < 10; i++)
{
thread_value += 1;
threads.push_back(std::thread(thread_function, &thread_value));
}
for (i = 0; i < 10; i++)
threads[i].join();
return 0;
return 0;
}