From a73d0926fc08445e9c04fa3670ec8ba5f09bd089 Mon Sep 17 00:00:00 2001 From: Eric Fiselier Date: Sat, 22 Aug 2015 21:24:01 +0000 Subject: [PATCH] Refactor shared_timed_mutex tests. First I removed all of the uses of _LIBCPP_STD_VER and added LIT UNSUPPORTED tags to prevent the tests from being run in older standard dialects. Second I increased the time tolerances used in some tests when testing with Thread Sanitizer because thread sanitizer make these tests take longer. git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@245793 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../thread.lock.shared.cons/default.pass.cpp | 3 +- .../move_assign.pass.cpp | 7 +- .../move_ctor.pass.cpp | 8 +-- .../thread.lock.shared.cons/mutex.pass.cpp | 64 +++++++++++-------- .../mutex_adopt_lock.pass.cpp | 3 +- .../mutex_defer_lock.pass.cpp | 3 +- .../mutex_duration.pass.cpp | 35 ++++++---- .../mutex_time_point.pass.cpp | 35 ++++++---- .../mutex_try_to_lock.pass.cpp | 7 +- .../thread.lock.shared.locking/lock.pass.cpp | 25 +++++--- .../try_lock.pass.cpp | 8 +-- .../try_lock_for.pass.cpp | 7 +- .../try_lock_until.pass.cpp | 7 +- .../unlock.pass.cpp | 7 +- .../member_swap.pass.cpp | 7 +- .../nonmember_swap.pass.cpp | 7 +- .../thread.lock.shared.mod/release.pass.cpp | 7 +- .../thread.lock.shared.obs/mutex.pass.cpp | 7 +- .../thread.lock.shared.obs/op_bool.pass.cpp | 7 +- .../thread.lock.shared.obs/owns_lock.pass.cpp | 7 +- .../thread.lock.shared/types.pass.cpp | 4 +- 21 files changed, 119 insertions(+), 146 deletions(-) diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/default.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/default.pass.cpp index 2c1c665f..f7cf49c8 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/default.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/default.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03, c++11 // @@ -20,9 +21,7 @@ int main() { -#if _LIBCPP_STD_VER > 11 std::shared_lock ul; assert(!ul.owns_lock()); assert(ul.mutex() == nullptr); -#endif // _LIBCPP_STD_VER > 11 } diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/move_assign.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/move_assign.pass.cpp index 8676f2ca..15c193c6 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/move_assign.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/move_assign.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03, c++11 // @@ -18,16 +19,11 @@ #include #include -#if _LIBCPP_STD_VER > 11 - std::shared_timed_mutex m0; std::shared_timed_mutex m1; -#endif // _LIBCPP_STD_VER > 11 - int main() { -#if _LIBCPP_STD_VER > 11 std::shared_lock lk0(m0); std::shared_lock lk1(m1); lk1 = std::move(lk0); @@ -35,5 +31,4 @@ int main() assert(lk1.owns_lock() == true); assert(lk0.mutex() == nullptr); assert(lk0.owns_lock() == false); -#endif // _LIBCPP_STD_VER > 11 } diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/move_ctor.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/move_ctor.pass.cpp index f59d2e82..4f4f6a5e 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/move_ctor.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/move_ctor.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03, c++11 // @@ -18,18 +19,13 @@ #include #include -#if _LIBCPP_STD_VER > 11 -std::shared_timed_mutex m; -#endif // _LIBCPP_STD_VER > 11 - int main() { -#if _LIBCPP_STD_VER > 11 + std::shared_timed_mutex m; std::shared_lock lk0(m); std::shared_lock lk = std::move(lk0); assert(lk.mutex() == &m); assert(lk.owns_lock() == true); assert(lk0.mutex() == nullptr); assert(lk0.owns_lock() == false); -#endif // _LIBCPP_STD_VER > 11 } diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex.pass.cpp index c8a02873..a61531f2 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03, c++11 // @@ -21,9 +22,7 @@ #include #include -#if _LIBCPP_STD_VER > 11 - -std::shared_timed_mutex m; +#include "test_macros.h" typedef std::chrono::system_clock Clock; typedef Clock::time_point time_point; @@ -31,6 +30,19 @@ typedef Clock::duration duration; typedef std::chrono::milliseconds ms; typedef std::chrono::nanoseconds ns; +ms WaitTime = ms(250); + +// Thread sanitizer causes more overhead and will sometimes cause this test +// to fail. To prevent this we give Thread sanitizer more time to complete the +// test. +#if !TEST_HAS_FEATURE(thread_sanitizer) +ms Tolerance = ms(50); +#else +ms Tolerance = ms(100); +#endif + +std::shared_timed_mutex m; + void f() { time_point t0 = Clock::now(); @@ -39,8 +51,8 @@ void f() std::shared_lock ul(m); t1 = Clock::now(); } - ns d = t1 - t0 - ms(250); - assert(d < ms(50)); // within 50ms + ns d = t1 - t0 - WaitTime; + assert(d < Tolerance); // within tolerance } void g() @@ -52,30 +64,30 @@ void g() t1 = Clock::now(); } ns d = t1 - t0; - assert(d < ms(50)); // within 50ms + assert(d < Tolerance); // within tolerance } -#endif // _LIBCPP_STD_VER > 11 - int main() { -#if _LIBCPP_STD_VER > 11 - m.lock(); std::vector v; - for (int i = 0; i < 5; ++i) - v.push_back(std::thread(f)); - std::this_thread::sleep_for(ms(250)); - m.unlock(); - for (auto& t : v) - t.join(); - m.lock_shared(); - for (auto& t : v) - t = std::thread(g); - std::thread q(f); - std::this_thread::sleep_for(ms(250)); - m.unlock_shared(); - for (auto& t : v) - t.join(); - q.join(); -#endif // _LIBCPP_STD_VER > 11 + { + m.lock(); + for (int i = 0; i < 5; ++i) + v.push_back(std::thread(f)); + std::this_thread::sleep_for(WaitTime); + m.unlock(); + for (auto& t : v) + t.join(); + } + { + m.lock_shared(); + for (auto& t : v) + t = std::thread(g); + std::thread q(f); + std::this_thread::sleep_for(WaitTime); + m.unlock_shared(); + for (auto& t : v) + t.join(); + q.join(); + } } diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_adopt_lock.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_adopt_lock.pass.cpp index 3b49b302..99521022 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_adopt_lock.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_adopt_lock.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03, c++11 // @@ -20,11 +21,9 @@ int main() { -#if _LIBCPP_STD_VER > 11 std::shared_timed_mutex m; m.lock_shared(); std::shared_lock lk(m, std::adopt_lock); assert(lk.mutex() == &m); assert(lk.owns_lock() == true); -#endif // _LIBCPP_STD_VER > 11 } diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_defer_lock.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_defer_lock.pass.cpp index bbc38fca..d81796b9 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_defer_lock.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_defer_lock.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03, c++11 // @@ -20,10 +21,8 @@ int main() { -#if _LIBCPP_STD_VER > 11 std::shared_timed_mutex m; std::shared_lock lk(m, std::defer_lock); assert(lk.mutex() == &m); assert(lk.owns_lock() == false); -#endif // _LIBCPP_STD_VER > 11 } diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_duration.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_duration.pass.cpp index 9816e57f..cf51cb61 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_duration.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_duration.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03, c++11 // @@ -22,7 +23,7 @@ #include #include -#if _LIBCPP_STD_VER > 11 +#include "test_macros.h" std::shared_timed_mutex m; @@ -32,37 +33,46 @@ typedef Clock::duration duration; typedef std::chrono::milliseconds ms; typedef std::chrono::nanoseconds ns; +ms WaitTime = ms(250); + +// Thread sanitizer causes more overhead and will sometimes cause this test +// to fail. To prevent this we give Thread sanitizer more time to complete the +// test. +#if !TEST_HAS_FEATURE(thread_sanitizer) +ms Tolerance = ms(50); +#else +ms Tolerance = ms(100); +#endif + + void f1() { time_point t0 = Clock::now(); - std::shared_lock lk(m, ms(300)); + std::shared_lock lk(m, WaitTime + Tolerance); assert(lk.owns_lock() == true); time_point t1 = Clock::now(); - ns d = t1 - t0 - ms(250); - assert(d < ms(50)); // within 50ms + ns d = t1 - t0 - WaitTime; + assert(d < Tolerance); // within 50ms } void f2() { time_point t0 = Clock::now(); - std::shared_lock lk(m, ms(250)); + std::shared_lock lk(m, WaitTime); assert(lk.owns_lock() == false); time_point t1 = Clock::now(); - ns d = t1 - t0 - ms(250); - assert(d < ms(50)); // within 50ms + ns d = t1 - t0 - WaitTime; + assert(d < Tolerance); // within 50ms } -#endif // _LIBCPP_STD_VER > 11 - int main() { -#if _LIBCPP_STD_VER > 11 { m.lock(); std::vector v; for (int i = 0; i < 5; ++i) v.push_back(std::thread(f1)); - std::this_thread::sleep_for(ms(250)); + std::this_thread::sleep_for(WaitTime); m.unlock(); for (auto& t : v) t.join(); @@ -72,10 +82,9 @@ int main() std::vector v; for (int i = 0; i < 5; ++i) v.push_back(std::thread(f2)); - std::this_thread::sleep_for(ms(300)); + std::this_thread::sleep_for(WaitTime + Tolerance); m.unlock(); for (auto& t : v) t.join(); } -#endif // _LIBCPP_STD_VER > 11 } diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_time_point.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_time_point.pass.cpp index 5d188ab0..ea3ab54b 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_time_point.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_time_point.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03, c++11 // @@ -22,7 +23,7 @@ #include #include -#if _LIBCPP_STD_VER > 11 +#include "test_macros.h" std::shared_timed_mutex m; @@ -32,37 +33,46 @@ typedef Clock::duration duration; typedef std::chrono::milliseconds ms; typedef std::chrono::nanoseconds ns; +ms WaitTime = ms(250); + +// Thread sanitizer causes more overhead and will sometimes cause this test +// to fail. To prevent this we give Thread sanitizer more time to complete the +// test. +#if !TEST_HAS_FEATURE(thread_sanitizer) +ms Tolerance = ms(50); +#else +ms Tolerance = ms(100); +#endif + + void f1() { time_point t0 = Clock::now(); - std::shared_lock lk(m, Clock::now() + ms(300)); + std::shared_lock lk(m, Clock::now() + WaitTime + Tolerance); assert(lk.owns_lock() == true); time_point t1 = Clock::now(); - ns d = t1 - t0 - ms(250); - assert(d < ns(50000000)); // within 50ms + ns d = t1 - t0 - WaitTime; + assert(d < Tolerance); // within 50ms } void f2() { time_point t0 = Clock::now(); - std::shared_lock lk(m, Clock::now() + ms(250)); + std::shared_lock lk(m, Clock::now() + WaitTime); assert(lk.owns_lock() == false); time_point t1 = Clock::now(); - ns d = t1 - t0 - ms(250); - assert(d < ms(50)); // within 50ms + ns d = t1 - t0 - WaitTime; + assert(d < Tolerance); // within 50ms } -#endif // _LIBCPP_STD_VER > 11 - int main() { -#if _LIBCPP_STD_VER > 11 { m.lock(); std::vector v; for (int i = 0; i < 5; ++i) v.push_back(std::thread(f1)); - std::this_thread::sleep_for(ms(250)); + std::this_thread::sleep_for(WaitTime); m.unlock(); for (auto& t : v) t.join(); @@ -72,10 +82,9 @@ int main() std::vector v; for (int i = 0; i < 5; ++i) v.push_back(std::thread(f2)); - std::this_thread::sleep_for(ms(300)); + std::this_thread::sleep_for(WaitTime + Tolerance); m.unlock(); for (auto& t : v) t.join(); } -#endif // _LIBCPP_STD_VER > 11 } diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_try_to_lock.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_try_to_lock.pass.cpp index f2d4e0de..7f89f0af 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_try_to_lock.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_try_to_lock.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03, c++11 // @@ -21,8 +22,6 @@ #include #include -#if _LIBCPP_STD_VER > 11 - std::shared_timed_mutex m; typedef std::chrono::system_clock Clock; @@ -57,11 +56,8 @@ void f() assert(d < ms(200)); // within 200ms } -#endif // _LIBCPP_STD_VER > 11 - int main() { -#if _LIBCPP_STD_VER > 11 m.lock(); std::vector v; for (int i = 0; i < 5; ++i) @@ -70,5 +66,4 @@ int main() m.unlock(); for (auto& t : v) t.join(); -#endif // _LIBCPP_STD_VER > 11 } diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/lock.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/lock.pass.cpp index f1500652..a11ea344 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/lock.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/lock.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03, c++11 // @@ -21,7 +22,7 @@ #include #include -#if _LIBCPP_STD_VER > 11 +#include "test_macros.h" std::shared_timed_mutex m; @@ -31,6 +32,18 @@ typedef Clock::duration duration; typedef std::chrono::milliseconds ms; typedef std::chrono::nanoseconds ns; +ms WaitTime = ms(250); + +// Thread sanitizer causes more overhead and will sometimes cause this test +// to fail. To prevent this we give Thread sanitizer more time to complete the +// test. +#if !TEST_HAS_FEATURE(thread_sanitizer) +ms Tolerance = ms(25); +#else +ms Tolerance = ms(75); +#endif + + void f() { std::shared_lock lk(m, std::defer_lock); @@ -38,8 +51,8 @@ void f() lk.lock(); time_point t1 = Clock::now(); assert(lk.owns_lock() == true); - ns d = t1 - t0 - ms(250); - assert(d < ms(25)); // within 25ms + ns d = t1 - t0 - WaitTime; + assert(d < Tolerance); // within tolerance try { lk.lock(); @@ -62,18 +75,14 @@ void f() } } -#endif // _LIBCPP_STD_VER > 11 - int main() { -#if _LIBCPP_STD_VER > 11 m.lock(); std::vector v; for (int i = 0; i < 5; ++i) v.push_back(std::thread(f)); - std::this_thread::sleep_for(ms(250)); + std::this_thread::sleep_for(WaitTime); m.unlock(); for (auto& t : v) t.join(); -#endif // _LIBCPP_STD_VER > 11 } diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock.pass.cpp index 82b1ff86..8e062171 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03, c++11 // @@ -18,8 +19,6 @@ #include #include -#if _LIBCPP_STD_VER > 11 - bool try_lock_called = false; struct mutex @@ -34,11 +33,9 @@ struct mutex mutex m; -#endif // _LIBCPP_STD_VER > 11 - int main() { -#if _LIBCPP_STD_VER > 11 + std::shared_lock lk(m, std::defer_lock); assert(lk.try_lock() == true); assert(try_lock_called == true); @@ -66,5 +63,4 @@ int main() { assert(e.code().value() == EPERM); } -#endif // _LIBCPP_STD_VER > 11 } diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_for.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_for.pass.cpp index 5867465a..f847d768 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_for.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_for.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03, c++11 // @@ -19,8 +20,6 @@ #include #include -#if _LIBCPP_STD_VER > 11 - bool try_lock_for_called = false; typedef std::chrono::milliseconds ms; @@ -39,11 +38,8 @@ struct mutex mutex m; -#endif // _LIBCPP_STD_VER > 11 - int main() { -#if _LIBCPP_STD_VER > 11 std::shared_lock lk(m, std::defer_lock); assert(lk.try_lock_for(ms(5)) == true); assert(try_lock_for_called == true); @@ -71,5 +67,4 @@ int main() { assert(e.code().value() == EPERM); } -#endif // _LIBCPP_STD_VER > 11 } diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_until.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_until.pass.cpp index 9d38983b..2ffd542c 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_until.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_until.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03, c++11 // @@ -19,8 +20,6 @@ #include #include -#if _LIBCPP_STD_VER > 11 - bool try_lock_until_called = false; struct mutex @@ -38,11 +37,8 @@ struct mutex mutex m; -#endif // _LIBCPP_STD_VER > 11 - int main() { -#if _LIBCPP_STD_VER > 11 typedef std::chrono::steady_clock Clock; std::shared_lock lk(m, std::defer_lock); assert(lk.try_lock_until(Clock::now()) == true); @@ -71,5 +67,4 @@ int main() { assert(e.code().value() == EPERM); } -#endif // _LIBCPP_STD_VER > 11 } diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/unlock.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/unlock.pass.cpp index eb08a45c..3a7ed177 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/unlock.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/unlock.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03, c++11 // @@ -18,8 +19,6 @@ #include #include -#if _LIBCPP_STD_VER > 11 - bool unlock_called = false; struct mutex @@ -30,11 +29,8 @@ struct mutex mutex m; -#endif // _LIBCPP_STD_VER > 11 - int main() { -#if _LIBCPP_STD_VER > 11 std::shared_lock lk(m); lk.unlock(); assert(unlock_called == true); @@ -58,5 +54,4 @@ int main() { assert(e.code().value() == EPERM); } -#endif // _LIBCPP_STD_VER > 11 } diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/member_swap.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/member_swap.pass.cpp index 8505763e..23a0c703 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/member_swap.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/member_swap.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03, c++11 // @@ -18,8 +19,6 @@ #include #include -#if _LIBCPP_STD_VER > 11 - struct mutex { void lock_shared() {} @@ -28,11 +27,8 @@ struct mutex mutex m; -#endif // _LIBCPP_STD_VER > 11 - int main() { -#if _LIBCPP_STD_VER > 11 std::shared_lock lk1(m); std::shared_lock lk2; lk1.swap(lk2); @@ -41,5 +37,4 @@ int main() assert(lk2.mutex() == &m); assert(lk2.owns_lock() == true); static_assert(noexcept(lk1.swap(lk2)), "member swap must be noexcept"); -#endif // _LIBCPP_STD_VER > 11 } diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/nonmember_swap.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/nonmember_swap.pass.cpp index 057dbc4c..0f19174d 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/nonmember_swap.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/nonmember_swap.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03, c++11 // @@ -19,8 +20,6 @@ #include #include -#if _LIBCPP_STD_VER > 11 - struct mutex { void lock_shared() {} @@ -29,11 +28,8 @@ struct mutex mutex m; -#endif // _LIBCPP_STD_VER > 11 - int main() { -#if _LIBCPP_STD_VER > 11 std::shared_lock lk1(m); std::shared_lock lk2; swap(lk1, lk2); @@ -42,5 +38,4 @@ int main() assert(lk2.mutex() == &m); assert(lk2.owns_lock() == true); static_assert(noexcept(swap(lk1, lk2)), "non-member swap must be noexcept"); -#endif // _LIBCPP_STD_VER > 11 } diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/release.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/release.pass.cpp index 65ddca62..2b5f8c1f 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/release.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/release.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03, c++11 // @@ -18,8 +19,6 @@ #include #include -#if _LIBCPP_STD_VER > 11 - struct mutex { static int lock_count; @@ -33,11 +32,8 @@ int mutex::unlock_count = 0; mutex m; -#endif // _LIBCPP_STD_VER > 11 - int main() { -#if _LIBCPP_STD_VER > 11 std::shared_lock lk(m); assert(lk.mutex() == &m); assert(lk.owns_lock() == true); @@ -49,5 +45,4 @@ int main() assert(mutex::lock_count == 1); assert(mutex::unlock_count == 0); static_assert(noexcept(lk.release()), "release must be noexcept"); -#endif // _LIBCPP_STD_VER > 11 } diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/mutex.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/mutex.pass.cpp index 4eb75d8f..711ab7c6 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/mutex.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/mutex.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03, c++11 // @@ -18,15 +19,10 @@ #include #include -#if _LIBCPP_STD_VER > 11 - std::shared_timed_mutex m; -#endif // _LIBCPP_STD_VER > 11 - int main() { -#if _LIBCPP_STD_VER > 11 std::shared_lock lk0; assert(lk0.mutex() == nullptr); std::shared_lock lk1(m); @@ -34,5 +30,4 @@ int main() lk1.unlock(); assert(lk1.mutex() == &m); static_assert(noexcept(lk0.mutex()), "mutex() must be noexcept"); -#endif // _LIBCPP_STD_VER > 11 } diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/op_bool.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/op_bool.pass.cpp index d079d2d8..3f6ad2b5 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/op_bool.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/op_bool.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03, c++11 // @@ -18,15 +19,10 @@ #include #include -#if _LIBCPP_STD_VER > 11 - std::shared_timed_mutex m; -#endif // _LIBCPP_STD_VER > 11 - int main() { -#if _LIBCPP_STD_VER > 11 std::shared_lock lk0; assert(static_cast(lk0) == false); std::shared_lock lk1(m); @@ -34,5 +30,4 @@ int main() lk1.unlock(); assert(static_cast(lk1) == false); static_assert(noexcept(static_cast(lk0)), "explicit operator bool() must be noexcept"); -#endif // _LIBCPP_STD_VER > 11 } diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/owns_lock.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/owns_lock.pass.cpp index d64b0aa6..5ab3ac00 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/owns_lock.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/owns_lock.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03, c++11 // @@ -18,15 +19,10 @@ #include #include -#if _LIBCPP_STD_VER > 11 - std::shared_timed_mutex m; -#endif // _LIBCPP_STD_VER > 11 - int main() { -#if _LIBCPP_STD_VER > 11 std::shared_lock lk0; assert(lk0.owns_lock() == false); std::shared_lock lk1(m); @@ -34,5 +30,4 @@ int main() lk1.unlock(); assert(lk1.owns_lock() == false); static_assert(noexcept(lk0.owns_lock()), "owns_lock must be noexcept"); -#endif // _LIBCPP_STD_VER > 11 } diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/types.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/types.pass.cpp index c153b455..f555d3de 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/types.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/types.pass.cpp @@ -8,6 +8,8 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03, c++11 + // @@ -24,8 +26,6 @@ int main() { -#if _LIBCPP_STD_VER > 11 static_assert((std::is_same::mutex_type, std::mutex>::value), ""); -#endif // _LIBCPP_STD_VER > 11 }