diff --git a/libcxx/test/std/thread/thread.mutex/thread.lock.algorithm/lock.pass.cpp b/libcxx/test/std/thread/thread.mutex/thread.lock.algorithm/lock.pass.cpp index 9e20144e8c85de..46d04cdac350ea 100644 --- a/libcxx/test/std/thread/thread.mutex/thread.lock.algorithm/lock.pass.cpp +++ b/libcxx/test/std/thread/thread.mutex/thread.lock.algorithm/lock.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// // -// XFAIL: libcpp-no-exceptions // UNSUPPORTED: libcpp-has-no-threads // This test hangs forever when built against libstdc++. In order to allow @@ -23,6 +22,8 @@ #include #include +#include "test_macros.h" + class L0 { bool locked_; @@ -78,12 +79,12 @@ class L2 void lock() { - throw 1; + TEST_THROW(1); } bool try_lock() { - throw 1; + TEST_THROW(1); return locked_; } @@ -115,6 +116,7 @@ int main() assert(l0.locked()); assert(l1.locked()); } +#ifndef TEST_HAS_NO_EXCEPTIONS { L0 l0; L2 l1; @@ -185,6 +187,7 @@ int main() assert(!l1.locked()); } } +#endif #ifndef _LIBCPP_HAS_NO_VARIADICS { L0 l0; @@ -195,6 +198,7 @@ int main() assert(l1.locked()); assert(l2.locked()); } +#ifndef TEST_HAS_NO_EXCEPTIONS { L2 l0; L2 l1; @@ -211,6 +215,7 @@ int main() assert(!l2.locked()); } } +#endif { L0 l0; L0 l1; @@ -238,6 +243,7 @@ int main() assert(l1.locked()); assert(l2.locked()); } +#ifndef TEST_HAS_NO_EXCEPTIONS { L0 l0; L0 l1; @@ -382,6 +388,7 @@ int main() assert(!l2.locked()); } } +#endif // TEST_HAS_NO_EXCEPTIONS { L0 l0; L0 l1; @@ -437,6 +444,7 @@ int main() assert(l2.locked()); assert(l3.locked()); } +#ifndef TEST_HAS_NO_EXCEPTIONS { L0 l0; L0 l1; @@ -509,5 +517,6 @@ int main() assert(!l3.locked()); } } +#endif // TEST_HAS_NO_EXCEPTIONS #endif // _LIBCPP_HAS_NO_VARIADICS } diff --git a/libcxx/test/std/thread/thread.mutex/thread.lock.algorithm/try_lock.pass.cpp b/libcxx/test/std/thread/thread.mutex/thread.lock.algorithm/try_lock.pass.cpp index 8889408be2d7cc..fb563cbe0b1412 100644 --- a/libcxx/test/std/thread/thread.mutex/thread.lock.algorithm/try_lock.pass.cpp +++ b/libcxx/test/std/thread/thread.mutex/thread.lock.algorithm/try_lock.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// // -// XFAIL: libcpp-no-exceptions // UNSUPPORTED: libcpp-has-no-threads // @@ -18,6 +17,8 @@ #include #include +#include "test_macros.h" + class L0 { bool locked_; @@ -63,7 +64,7 @@ class L2 bool try_lock() { - throw 1; + TEST_THROW(1); return locked_; } @@ -95,6 +96,7 @@ int main() assert(!l0.locked()); assert(!l1.locked()); } +#ifndef TEST_HAS_NO_EXCEPTIONS { L0 l0; L2 l1; @@ -123,6 +125,7 @@ int main() assert(!l1.locked()); } } +#endif #ifndef _LIBCPP_HAS_NO_VARIADICS { L0 l0; @@ -142,6 +145,7 @@ int main() assert(!l1.locked()); assert(!l2.locked()); } +#ifndef TEST_HAS_NO_EXCEPTIONS { L2 l0; L2 l1; @@ -167,6 +171,7 @@ int main() assert(!l1.locked()); assert(!l2.locked()); } +#endif { L0 l0; L0 l1; @@ -194,6 +199,7 @@ int main() assert(!l1.locked()); assert(!l2.locked()); } +#ifndef TEST_HAS_NO_EXCEPTIONS { L0 l0; L0 l1; @@ -242,6 +248,7 @@ int main() assert(!l2.locked()); } } +#endif { L1 l0; L1 l1; @@ -269,6 +276,7 @@ int main() assert(!l1.locked()); assert(!l2.locked()); } +#ifndef TEST_HAS_NO_EXCEPTIONS { L1 l0; L1 l1; @@ -458,6 +466,7 @@ int main() assert(!l2.locked()); } } +#endif // TEST_HAS_NO_EXCEPTIONS { L0 l0; L0 l1; diff --git a/libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/lock.pass.cpp b/libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/lock.pass.cpp index 5c3513c98e03b4..25d78ab1902143 100644 --- a/libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/lock.pass.cpp +++ b/libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/lock.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// // -// XFAIL: libcpp-no-exceptions // UNSUPPORTED: libcpp-has-no-threads // UNSUPPORTED: c++98, c++03, c++11 @@ -54,6 +53,7 @@ void f() assert(lk.owns_lock() == true); ns d = t1 - t0 - WaitTime; assert(d < Tolerance); // within tolerance +#ifndef TEST_HAS_NO_EXCEPTIONS try { lk.lock(); @@ -63,8 +63,10 @@ void f() { assert(e.code().value() == EDEADLK); } +#endif lk.unlock(); lk.release(); +#ifndef TEST_HAS_NO_EXCEPTIONS try { lk.lock(); @@ -74,6 +76,7 @@ void f() { assert(e.code().value() == EPERM); } +#endif } int main() diff --git a/libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock.pass.cpp b/libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock.pass.cpp index 01693c77ea39e5..947b1ad012ecfe 100644 --- a/libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock.pass.cpp +++ b/libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// // -// XFAIL: libcpp-no-exceptions // UNSUPPORTED: libcpp-has-no-threads // UNSUPPORTED: c++98, c++03, c++11 @@ -20,6 +19,8 @@ #include #include +#include "test_macros.h" + bool try_lock_called = false; struct mutex @@ -36,11 +37,11 @@ mutex m; int main() { - std::shared_lock lk(m, std::defer_lock); assert(lk.try_lock() == true); assert(try_lock_called == true); assert(lk.owns_lock() == true); +#ifndef TEST_HAS_NO_EXCEPTIONS try { lk.try_lock(); @@ -50,11 +51,13 @@ int main() { assert(e.code().value() == EDEADLK); } +#endif lk.unlock(); assert(lk.try_lock() == false); assert(try_lock_called == false); assert(lk.owns_lock() == false); lk.release(); +#ifndef TEST_HAS_NO_EXCEPTIONS try { lk.try_lock(); @@ -64,4 +67,5 @@ int main() { assert(e.code().value() == EPERM); } +#endif } diff --git a/libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_for.pass.cpp b/libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_for.pass.cpp index 852a94eb65ece8..5cb8054125632b 100644 --- a/libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_for.pass.cpp +++ b/libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_for.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// // -// XFAIL: libcpp-no-exceptions // UNSUPPORTED: libcpp-has-no-threads // UNSUPPORTED: c++98, c++03, c++11 @@ -21,6 +20,8 @@ #include #include +#include "test_macros.h" + bool try_lock_for_called = false; typedef std::chrono::milliseconds ms; @@ -45,6 +46,7 @@ int main() assert(lk.try_lock_for(ms(5)) == true); assert(try_lock_for_called == true); assert(lk.owns_lock() == true); +#ifndef TEST_HAS_NO_EXCEPTIONS try { lk.try_lock_for(ms(5)); @@ -54,11 +56,13 @@ int main() { assert(e.code().value() == EDEADLK); } +#endif lk.unlock(); assert(lk.try_lock_for(ms(5)) == false); assert(try_lock_for_called == false); assert(lk.owns_lock() == false); lk.release(); +#ifndef TEST_HAS_NO_EXCEPTIONS try { lk.try_lock_for(ms(5)); @@ -68,4 +72,5 @@ int main() { assert(e.code().value() == EPERM); } +#endif } diff --git a/libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_until.pass.cpp b/libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_until.pass.cpp index 31574afd7d8f5d..3ba4128d719c64 100644 --- a/libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_until.pass.cpp +++ b/libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_until.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// // -// XFAIL: libcpp-no-exceptions // UNSUPPORTED: libcpp-has-no-threads // UNSUPPORTED: c++98, c++03, c++11 @@ -21,6 +20,8 @@ #include #include +#include "test_macros.h" + bool try_lock_until_called = false; struct mutex @@ -45,6 +46,7 @@ int main() assert(lk.try_lock_until(Clock::now()) == true); assert(try_lock_until_called == true); assert(lk.owns_lock() == true); +#ifndef TEST_HAS_NO_EXCEPTIONS try { lk.try_lock_until(Clock::now()); @@ -54,11 +56,13 @@ int main() { assert(e.code().value() == EDEADLK); } +#endif lk.unlock(); assert(lk.try_lock_until(Clock::now()) == false); assert(try_lock_until_called == false); assert(lk.owns_lock() == false); lk.release(); +#ifndef TEST_HAS_NO_EXCEPTIONS try { lk.try_lock_until(Clock::now()); @@ -68,4 +72,5 @@ int main() { assert(e.code().value() == EPERM); } +#endif } diff --git a/libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/unlock.pass.cpp b/libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/unlock.pass.cpp index 6a7385ed42a60d..903b53ace0f248 100644 --- a/libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/unlock.pass.cpp +++ b/libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/unlock.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// // -// XFAIL: libcpp-no-exceptions // UNSUPPORTED: libcpp-has-no-threads // UNSUPPORTED: c++98, c++03, c++11 @@ -20,6 +19,8 @@ #include #include +#include "test_macros.h" + bool unlock_called = false; struct mutex @@ -36,6 +37,7 @@ int main() lk.unlock(); assert(unlock_called == true); assert(lk.owns_lock() == false); +#ifndef TEST_HAS_NO_EXCEPTIONS try { lk.unlock(); @@ -45,7 +47,9 @@ int main() { assert(e.code().value() == EPERM); } +#endif lk.release(); +#ifndef TEST_HAS_NO_EXCEPTIONS try { lk.unlock(); @@ -55,4 +59,5 @@ int main() { assert(e.code().value() == EPERM); } +#endif } diff --git a/libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/lock.pass.cpp b/libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/lock.pass.cpp index 6ce33761068f69..cb5c55925eef41 100644 --- a/libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/lock.pass.cpp +++ b/libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/lock.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// // -// XFAIL: libcpp-no-exceptions // UNSUPPORTED: libcpp-has-no-threads // @@ -21,6 +20,8 @@ #include #include +#include "test_macros.h" + std::mutex m; typedef std::chrono::system_clock Clock; @@ -38,6 +39,7 @@ void f() assert(lk.owns_lock() == true); ns d = t1 - t0 - ms(250); assert(d < ms(25)); // within 25ms +#ifndef TEST_HAS_NO_EXCEPTIONS try { lk.lock(); @@ -47,8 +49,10 @@ void f() { assert(e.code().value() == EDEADLK); } +#endif lk.unlock(); lk.release(); +#ifndef TEST_HAS_NO_EXCEPTIONS try { lk.lock(); @@ -58,6 +62,7 @@ void f() { assert(e.code().value() == EPERM); } +#endif } int main() diff --git a/libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock.pass.cpp b/libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock.pass.cpp index 27d0562de31ffb..709c56978af80a 100644 --- a/libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock.pass.cpp +++ b/libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// // -// XFAIL: libcpp-no-exceptions // UNSUPPORTED: libcpp-has-no-threads // @@ -19,6 +18,8 @@ #include #include +#include "test_macros.h" + bool try_lock_called = false; struct mutex @@ -39,6 +40,7 @@ int main() assert(lk.try_lock() == true); assert(try_lock_called == true); assert(lk.owns_lock() == true); +#ifndef TEST_HAS_NO_EXCEPTIONS try { lk.try_lock(); @@ -48,11 +50,13 @@ int main() { assert(e.code().value() == EDEADLK); } +#endif lk.unlock(); assert(lk.try_lock() == false); assert(try_lock_called == false); assert(lk.owns_lock() == false); lk.release(); +#ifndef TEST_HAS_NO_EXCEPTIONS try { lk.try_lock(); @@ -62,4 +66,5 @@ int main() { assert(e.code().value() == EPERM); } +#endif } diff --git a/libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_for.pass.cpp b/libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_for.pass.cpp index 6f0a7219d2d8c7..6c981787d4b4ad 100644 --- a/libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_for.pass.cpp +++ b/libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_for.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// // -// XFAIL: libcpp-no-exceptions // UNSUPPORTED: libcpp-has-no-threads // @@ -20,6 +19,8 @@ #include #include +#include "test_macros.h" + bool try_lock_for_called = false; typedef std::chrono::milliseconds ms; @@ -44,6 +45,7 @@ int main() assert(lk.try_lock_for(ms(5)) == true); assert(try_lock_for_called == true); assert(lk.owns_lock() == true); +#ifndef TEST_HAS_NO_EXCEPTIONS try { lk.try_lock_for(ms(5)); @@ -53,11 +55,13 @@ int main() { assert(e.code().value() == EDEADLK); } +#endif lk.unlock(); assert(lk.try_lock_for(ms(5)) == false); assert(try_lock_for_called == false); assert(lk.owns_lock() == false); lk.release(); +#ifndef TEST_HAS_NO_EXCEPTIONS try { lk.try_lock_for(ms(5)); @@ -67,4 +71,5 @@ int main() { assert(e.code().value() == EPERM); } +#endif } diff --git a/libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_until.pass.cpp b/libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_until.pass.cpp index b7e87249b59607..57231b207a7269 100644 --- a/libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_until.pass.cpp +++ b/libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_until.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// // -// XFAIL: libcpp-no-exceptions // UNSUPPORTED: libcpp-has-no-threads // @@ -20,6 +19,8 @@ #include #include +#include "test_macros.h" + bool try_lock_until_called = false; struct mutex @@ -44,6 +45,7 @@ int main() assert(lk.try_lock_until(Clock::now()) == true); assert(try_lock_until_called == true); assert(lk.owns_lock() == true); +#ifndef TEST_HAS_NO_EXCEPTIONS try { lk.try_lock_until(Clock::now()); @@ -53,11 +55,13 @@ int main() { assert(e.code().value() == EDEADLK); } +#endif lk.unlock(); assert(lk.try_lock_until(Clock::now()) == false); assert(try_lock_until_called == false); assert(lk.owns_lock() == false); lk.release(); +#ifndef TEST_HAS_NO_EXCEPTIONS try { lk.try_lock_until(Clock::now()); @@ -67,4 +71,5 @@ int main() { assert(e.code().value() == EPERM); } +#endif } diff --git a/libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/unlock.pass.cpp b/libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/unlock.pass.cpp index 62497c9ec45a10..124ff551f94729 100644 --- a/libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/unlock.pass.cpp +++ b/libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/unlock.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// // -// XFAIL: libcpp-no-exceptions // UNSUPPORTED: libcpp-has-no-threads // @@ -19,6 +18,8 @@ #include #include +#include "test_macros.h" + bool unlock_called = false; struct mutex @@ -35,6 +36,7 @@ int main() lk.unlock(); assert(unlock_called == true); assert(lk.owns_lock() == false); +#ifndef TEST_HAS_NO_EXCEPTIONS try { lk.unlock(); @@ -44,7 +46,9 @@ int main() { assert(e.code().value() == EPERM); } +#endif lk.release(); +#ifndef TEST_HAS_NO_EXCEPTIONS try { lk.unlock(); @@ -54,4 +58,5 @@ int main() { assert(e.code().value() == EPERM); } +#endif } diff --git a/libcxx/test/std/thread/thread.mutex/thread.once/thread.once.callonce/call_once.pass.cpp b/libcxx/test/std/thread/thread.mutex/thread.once/thread.once.callonce/call_once.pass.cpp index 71b054fced8864..138b657196da06 100644 --- a/libcxx/test/std/thread/thread.mutex/thread.once/thread.once.callonce/call_once.pass.cpp +++ b/libcxx/test/std/thread/thread.mutex/thread.once/thread.once.callonce/call_once.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// // -// XFAIL: libcpp-no-exceptions // UNSUPPORTED: libcpp-has-no-threads // @@ -50,12 +49,13 @@ void init3() ++init3_called; std::this_thread::sleep_for(ms(250)); if (init3_called == 1) - throw 1; + TEST_THROW(1); ++init3_completed; } void f3() { +#ifndef TEST_HAS_NO_EXCEPTIONS try { std::call_once(flg3, init3); @@ -63,6 +63,7 @@ void f3() catch (...) { } +#endif } #ifndef _LIBCPP_HAS_NO_VARIADICS @@ -197,6 +198,7 @@ int main() t1.join(); assert(init0_called == 1); } +#ifndef TEST_HAS_NO_EXCEPTIONS // check basic exception safety { std::thread t0(f3); @@ -206,6 +208,7 @@ int main() assert(init3_called == 2); assert(init3_completed == 1); } +#endif // check deadlock avoidance { std::thread t0(f41);