[v2,04/11] libstdc++ testsuite: Also test unique_lock::try_lock_until with steady_clock

Message ID cc3c1b5c576055480f406d2192c407f696bfc72a.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/unique_lock/locking/4.cc: Template test
            functions so they can be used to test both steady_clock and
            system_clock.
---
 libstdc++-v3/testsuite/30_threads/unique_lock/locking/4.cc | 12 +++++--
 1 file changed, 9 insertions(+), 3 deletions(-)

-- 
git-series 0.9.1

Patch

diff --git a/libstdc++-v3/testsuite/30_threads/unique_lock/locking/4.cc b/libstdc++-v3/testsuite/30_threads/unique_lock/locking/4.cc
index f10cd3f..1c544be 100644
--- a/libstdc++-v3/testsuite/30_threads/unique_lock/locking/4.cc
+++ b/libstdc++-v3/testsuite/30_threads/unique_lock/locking/4.cc
@@ -26,17 +26,18 @@ 
 #include <system_error>
 #include <testsuite_hooks.h>
 
-int main()
+template <typename clock_type>
+void test()
 {
   typedef std::timed_mutex mutex_type;
   typedef std::unique_lock<mutex_type> lock_type;
-  typedef std::chrono::system_clock clock_type;
 
   try 
     {
       mutex_type m;
       lock_type l(m, std::defer_lock);
-      clock_type::time_point t = clock_type::now() + std::chrono::seconds(1);
+      const typename clock_type::time_point t = clock_type::now()
+        + std::chrono::seconds(1);
 
       try
 	{
@@ -61,6 +62,11 @@  int main()
     {
       VERIFY( false );
     }
+}
 
+int main()
+{
+  test<std::chrono::system_clock>();
+  test<std::chrono::steady_clock>();
   return 0;
 }