This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH 08/11] libstdc++ testsuite: Also test shared_timed_mutex with steady_clock
* testsuite/30_threads/shared_timed_mutex/try_lock/3.cc: Convert
existing test to templated function so that it can be called with
both system_clock and steady_clock.
---
libstdc++-v3/testsuite/30_threads/shared_timed_mutex/try_lock/3.cc | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/libstdc++-v3/testsuite/30_threads/shared_timed_mutex/try_lock/3.cc b/libstdc++-v3/testsuite/30_threads/shared_timed_mutex/try_lock/3.cc
index fd21033..1cf191c 100644
--- a/libstdc++-v3/testsuite/30_threads/shared_timed_mutex/try_lock/3.cc
+++ b/libstdc++-v3/testsuite/30_threads/shared_timed_mutex/try_lock/3.cc
@@ -27,7 +27,8 @@
#include <system_error>
#include <testsuite_hooks.h>
-int main()
+template <typename clock_type>
+void test()
{
typedef std::shared_timed_mutex mutex_type;
@@ -42,15 +43,15 @@ int main()
{
using namespace std::chrono;
auto timeout = 100ms;
- auto start = system_clock::now();
+ auto start = clock_type::now();
b = m.try_lock_for(timeout);
- auto t = system_clock::now() - start;
+ auto t = clock_type::now() - start;
VERIFY( !b );
VERIFY( t >= timeout );
- start = system_clock::now();
+ start = clock_type::now();
b = m.try_lock_until(start + timeout);
- t = system_clock::now() - start;
+ t = clock_type::now() - start;
VERIFY( !b );
VERIFY( t >= timeout );
}
@@ -71,3 +72,9 @@ int main()
VERIFY( false );
}
}
+
+int main()
+{
+ test<std::chrono::system_clock>();
+ test<std::chrono::steady_clock>();
+}
--
git-series 0.9.1