[v2,03/11] libstdc++ testsuite: Also test timed_mutex with steady_clock

Message ID 7252cf1c496e74ebb1c91925499c9a8e1d6ceba2.1571162241.git-series.mac@mcrowe.com
State New
Headers show
Series
  • timed_mutex, shared_timed_mutex: Add full steady clock support
Related show

Commit Message

Mike Crowe Oct. 15, 2019, 5:57 p.m.
* testsuite/30_threads/timed_mutex/try_lock_until/57641.cc:
	  Template test functions and use them to test both steady_clock
	  and system_clock.
---
 libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock_until/57641.cc | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

-- 
git-series 0.9.1

Patch

diff --git a/libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock_until/57641.cc b/libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock_until/57641.cc
index 12ee52f..6355d8f 100644
--- a/libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock_until/57641.cc
+++ b/libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock_until/57641.cc
@@ -49,18 +49,26 @@  struct clock
 std::timed_mutex mx;
 bool locked = false;
 
+template <typename ClockType>
 void f()
 {
-  locked = mx.try_lock_until(clock::now() + C::milliseconds(1));
+  locked = mx.try_lock_until(ClockType::now() + C::milliseconds(1));
 }
 
-int main()
+template <typename ClockType>
+void test()
 {
   std::lock_guard<std::timed_mutex> l(mx);
-  auto start = C::system_clock::now();
-  std::thread t(f);
+  auto start = ClockType::now();
+  std::thread t(f<ClockType>);
   t.join();
-  auto stop = C::system_clock::now();
+  auto stop = ClockType::now();
   VERIFY( (stop - start) < C::seconds(9) );
   VERIFY( !locked );
 }
+
+int main()
+{
+  test<C::system_clock>();
+  test<C::steady_clock>();
+}