forked from OSchip/llvm-project
[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:
parent
f9d0d0d7e0
commit
55ee541653
|
@ -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."""
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue