]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
DRD regtest: try to make timed_mutex more reliable
authorPaul Floyd <pjfloyd@wanadoo.fr>
Fri, 3 Feb 2023 18:27:39 +0000 (19:27 +0100)
committerPaul Floyd <pjfloyd@wanadoo.fr>
Fri, 3 Feb 2023 18:27:39 +0000 (19:27 +0100)
On RHEL 7.6 ARM I see this with the lock returning false
but without the 11 second timeout. Try adding some sleeps.

drd/tests/timed_mutex.cpp

index b1bb61efa630416945caacf7da9d023571216a1c..fa7464ea5b1e53ba0a3f3dfd2b6926ea0d87e30f 100644 (file)
@@ -12,16 +12,19 @@ void f()
     auto now=std::chrono::steady_clock::now();
     test_mutex.try_lock_until(now + std::chrono::seconds(11));
     --global;
+    std::this_thread::sleep_for(std::chrono::seconds(1));
     test_mutex.unlock();
 }
+
+
 int main()
 {
     global = 0;
+    std::thread t(f);
+    std::this_thread::sleep_for(std::chrono::seconds(1));
     auto now=std::chrono::steady_clock::now();
     test_mutex.try_lock_until(now + std::chrono::seconds(11));
     ++global;
-    std::thread t(f);
     test_mutex.unlock();
     t.join();
     assert(global == 0);