[Lldb-commits] [lldb] 55ee541 - [lldb/test] Clean up TestThreadSpecificBpPlusCondition inferior

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Wed Apr 21 08:37:38 PDT 2021


Author: Pavel Labath
Date: 2021-04-21T17:37:30+02:00
New Revision: 55ee541653a817c77a6b5b837c4b8cc50ed3ae0e

URL: https://github.com/llvm/llvm-project/commit/55ee541653a817c77a6b5b837c4b8cc50ed3ae0e
DIFF: https://github.com/llvm/llvm-project/commit/55ee541653a817c77a6b5b837c4b8cc50ed3ae0e.diff

LOG: [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.

Added: 
    

Modified: 
    lldb/test/API/functionalities/thread/thread_specific_break_plus_condition/TestThreadSpecificBpPlusCondition.py
    lldb/test/API/functionalities/thread/thread_specific_break_plus_condition/main.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/test/API/functionalities/thread/thread_specific_break_plus_condition/TestThreadSpecificBpPlusCondition.py b/lldb/test/API/functionalities/thread/thread_specific_break_plus_condition/TestThreadSpecificBpPlusCondition.py
index 325252f9ae00..95499883aa7a 100644
--- a/lldb/test/API/functionalities/thread/thread_specific_break_plus_condition/TestThreadSpecificBpPlusCondition.py
+++ b/lldb/test/API/functionalities/thread/thread_specific_break_plus_condition/TestThreadSpecificBpPlusCondition.py
@@ -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."""

diff  --git a/lldb/test/API/functionalities/thread/thread_specific_break_plus_condition/main.cpp b/lldb/test/API/functionalities/thread/thread_specific_break_plus_condition/main.cpp
index af8ab84157fd..beceb09e5b9c 100644
--- a/lldb/test/API/functionalities/thread/thread_specific_break_plus_condition/main.cpp
+++ b/lldb/test/API/functionalities/thread/thread_specific_break_plus_condition/main.cpp
@@ -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;
-
-    int thread_value = 0;
-    int i;
-
-    for (i = 0; i < 10; i++)
-    {
-        thread_value += 1;
-        threads.push_back(std::thread(thread_function, &thread_value));
-    }
+  for (int i = 0; i < 10; i++)
+    threads.push_back(std::thread(thread_function, threads.size() + 1));
 
-    for (i = 0; i < 10; i++)
-        threads[i].join();
+  for (std::thread &t : threads)
+    t.join();
 
-    return 0;
+  return 0;
 }


        


More information about the lldb-commits mailing list