diff options
Diffstat (limited to 'test/std/thread')
67 files changed, 416 insertions, 62 deletions
diff --git a/test/std/thread/futures/futures.async/async.pass.cpp b/test/std/thread/futures/futures.async/async.pass.cpp index 5cb824d48224..9adebb285111 100644 --- a/test/std/thread/futures/futures.async/async.pass.cpp +++ b/test/std/thread/futures/futures.async/async.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// // -// XFAIL: libcpp-no-exceptions // UNSUPPORTED: libcpp-has-no-threads // UNSUPPORTED: c++98, c++03 @@ -73,7 +72,8 @@ std::unique_ptr<int> f4(std::unique_ptr<int>&& p) void f5(int j) { std::this_thread::sleep_for(ms(200)); - throw j; + ((void)j); + TEST_THROW(j); } template <class Ret, class CheckLamdba, class ...Args> @@ -140,6 +140,7 @@ int main() test<Ret>(checkUPtr, DPID, f3, 3); test<Ret>(checkUPtr, DPID, f4, std::unique_ptr<int>(new int(3))); } +#ifndef TEST_HAS_NO_EXCEPTIONS { std::future<void> f = std::async(f5, 3); std::this_thread::sleep_for(ms(300)); @@ -150,4 +151,5 @@ int main() std::this_thread::sleep_for(ms(300)); try { f.get(); assert (false); } catch ( int ) {} } +#endif } diff --git a/test/std/thread/futures/futures.future_error/code.pass.cpp b/test/std/thread/futures/futures.future_error/code.pass.cpp index e02af486fc39..35d44df5bbbf 100644 --- a/test/std/thread/futures/futures.future_error/code.pass.cpp +++ b/test/std/thread/futures/futures.future_error/code.pass.cpp @@ -12,12 +12,16 @@ // <future> // class future_error +// future_error(error_code __ec); // exposition only +// explicit future_error(future_errc _Ev) : __ec_(make_error_code(_Ev)) {} // C++17 // const error_code& code() const throw(); #include <future> #include <cassert> +#include "test_macros.h" + int main() { { @@ -40,4 +44,14 @@ int main() std::future_error f(ec); assert(f.code() == ec); } +#if TEST_STD_VER > 14 + { + std::future_error f(std::future_errc::broken_promise); + assert(f.code() == std::make_error_code(std::future_errc::broken_promise)); + } + { + std::future_error f(std::future_errc::no_state); + assert(f.code() == std::make_error_code(std::future_errc::no_state)); + } +#endif } diff --git a/test/std/thread/futures/futures.future_error/what.pass.cpp b/test/std/thread/futures/futures.future_error/what.pass.cpp index 52d2e944a684..a44f8af7d41b 100644 --- a/test/std/thread/futures/futures.future_error/what.pass.cpp +++ b/test/std/thread/futures/futures.future_error/what.pass.cpp @@ -26,25 +26,27 @@ #include <cstring> #include <cassert> +#include "test_macros.h" + int main() { { std::future_error f(std::make_error_code(std::future_errc::broken_promise)); - assert(std::strcmp(f.what(), "The associated promise has been destructed prior " + LIBCPP_ASSERT(std::strcmp(f.what(), "The associated promise has been destructed prior " "to the associated state becoming ready.") == 0); } { std::future_error f(std::make_error_code(std::future_errc::future_already_retrieved)); - assert(std::strcmp(f.what(), "The future has already been retrieved from " + LIBCPP_ASSERT(std::strcmp(f.what(), "The future has already been retrieved from " "the promise or packaged_task.") == 0); } { std::future_error f(std::make_error_code(std::future_errc::promise_already_satisfied)); - assert(std::strcmp(f.what(), "The state of the promise has already been set.") == 0); + LIBCPP_ASSERT(std::strcmp(f.what(), "The state of the promise has already been set.") == 0); } { std::future_error f(std::make_error_code(std::future_errc::no_state)); - assert(std::strcmp(f.what(), "Operation not permitted on an object without " + LIBCPP_ASSERT(std::strcmp(f.what(), "Operation not permitted on an object without " "an associated state.") == 0); } } diff --git a/test/std/thread/futures/futures.overview/is_error_code_enum_future_errc.pass.cpp b/test/std/thread/futures/futures.overview/is_error_code_enum_future_errc.pass.cpp index 499de52598b6..8a3987cb5127 100644 --- a/test/std/thread/futures/futures.overview/is_error_code_enum_future_errc.pass.cpp +++ b/test/std/thread/futures/futures.overview/is_error_code_enum_future_errc.pass.cpp @@ -14,8 +14,12 @@ // template <> struct is_error_code_enum<future_errc> : public true_type {}; #include <future> +#include "test_macros.h" int main() { - static_assert(std::is_error_code_enum<std::future_errc>::value, ""); + static_assert(std::is_error_code_enum <std::future_errc>::value, ""); +#if TEST_STD_VER > 14 + static_assert(std::is_error_code_enum_v<std::future_errc>, ""); +#endif } diff --git a/test/std/thread/futures/futures.promise/dtor.pass.cpp b/test/std/thread/futures/futures.promise/dtor.pass.cpp index e3151ab38322..49010a67b39e 100644 --- a/test/std/thread/futures/futures.promise/dtor.pass.cpp +++ b/test/std/thread/futures/futures.promise/dtor.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// // -// XFAIL: libcpp-no-exceptions // UNSUPPORTED: libcpp-has-no-threads // UNSUPPORTED: c++98, c++03 @@ -20,6 +19,8 @@ #include <future> #include <cassert> +#include "test_macros.h" + int main() { { @@ -32,6 +33,7 @@ int main() } assert(f.get() == 3); } +#ifndef TEST_HAS_NO_EXCEPTIONS { typedef int T; std::future<T> f; @@ -42,6 +44,7 @@ int main() try { T i = f.get(); + ((void)i); // Prevent unused warning assert(false); } catch (const std::future_error& e) @@ -49,6 +52,7 @@ int main() assert(e.code() == make_error_code(std::future_errc::broken_promise)); } } +#endif { typedef int& T; @@ -61,6 +65,7 @@ int main() } assert(&f.get() == &i); } +#ifndef TEST_HAS_NO_EXCEPTIONS { typedef int& T; std::future<T> f; @@ -71,6 +76,7 @@ int main() try { T i = f.get(); + ((void)i); // Prevent unused warning assert(false); } catch (const std::future_error& e) @@ -78,6 +84,7 @@ int main() assert(e.code() == make_error_code(std::future_errc::broken_promise)); } } +#endif { typedef void T; @@ -90,6 +97,7 @@ int main() f.get(); assert(true); } +#ifndef TEST_HAS_NO_EXCEPTIONS { typedef void T; std::future<T> f; @@ -115,4 +123,5 @@ int main() e.code() == std::error_code(0, std::future_category())); } } +#endif } diff --git a/test/std/thread/futures/futures.promise/get_future.pass.cpp b/test/std/thread/futures/futures.promise/get_future.pass.cpp index bc45e28a9f96..fc606c6c8366 100644 --- a/test/std/thread/futures/futures.promise/get_future.pass.cpp +++ b/test/std/thread/futures/futures.promise/get_future.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// // -// XFAIL: libcpp-no-exceptions // UNSUPPORTED: libcpp-has-no-threads // UNSUPPORTED: c++98, c++03 @@ -20,6 +19,8 @@ #include <future> #include <cassert> +#include "test_macros.h" + int main() { { @@ -28,6 +29,7 @@ int main() p.set_value(105.5); assert(f.get() == 105.5); } +#ifndef TEST_HAS_NO_EXCEPTIONS { std::promise<double> p; std::future<double> f = p.get_future(); @@ -54,4 +56,5 @@ int main() assert(e.code() == make_error_code(std::future_errc::no_state)); } } +#endif } diff --git a/test/std/thread/futures/futures.promise/move_assign.pass.cpp b/test/std/thread/futures/futures.promise/move_assign.pass.cpp index 9dd8a9daef80..ad72bf78e0a4 100644 --- a/test/std/thread/futures/futures.promise/move_assign.pass.cpp +++ b/test/std/thread/futures/futures.promise/move_assign.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// // -// XFAIL: libcpp-no-exceptions // UNSUPPORTED: libcpp-has-no-threads // UNSUPPORTED: c++98, c++03 @@ -20,6 +19,7 @@ #include <future> #include <cassert> +#include "test_macros.h" #include "test_allocator.h" int main() @@ -34,6 +34,7 @@ int main() std::future<int> f = p.get_future(); assert(test_alloc_base::alloc_count == 1); assert(f.valid()); +#ifndef TEST_HAS_NO_EXCEPTIONS try { f = p0.get_future(); @@ -43,6 +44,7 @@ int main() { assert(e.code() == make_error_code(std::future_errc::no_state)); } +#endif assert(test_alloc_base::alloc_count == 1); } assert(test_alloc_base::alloc_count == 0); @@ -55,6 +57,7 @@ int main() std::future<int&> f = p.get_future(); assert(test_alloc_base::alloc_count == 1); assert(f.valid()); +#ifndef TEST_HAS_NO_EXCEPTIONS try { f = p0.get_future(); @@ -64,6 +67,7 @@ int main() { assert(e.code() == make_error_code(std::future_errc::no_state)); } +#endif assert(test_alloc_base::alloc_count == 1); } assert(test_alloc_base::alloc_count == 0); @@ -76,6 +80,7 @@ int main() std::future<void> f = p.get_future(); assert(test_alloc_base::alloc_count == 1); assert(f.valid()); +#ifndef TEST_HAS_NO_EXCEPTIONS try { f = p0.get_future(); @@ -85,6 +90,7 @@ int main() { assert(e.code() == make_error_code(std::future_errc::no_state)); } +#endif assert(test_alloc_base::alloc_count == 1); } assert(test_alloc_base::alloc_count == 0); diff --git a/test/std/thread/futures/futures.promise/move_ctor.pass.cpp b/test/std/thread/futures/futures.promise/move_ctor.pass.cpp index 9a68b5c1b4e1..c9971b0a3f04 100644 --- a/test/std/thread/futures/futures.promise/move_ctor.pass.cpp +++ b/test/std/thread/futures/futures.promise/move_ctor.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// // -// XFAIL: libcpp-no-exceptions // UNSUPPORTED: libcpp-has-no-threads // UNSUPPORTED: c++98, c++03 @@ -20,6 +19,7 @@ #include <future> #include <cassert> +#include "test_macros.h" #include "test_allocator.h" int main() @@ -32,6 +32,7 @@ int main() std::future<int> f = p.get_future(); assert(test_alloc_base::alloc_count == 1); assert(f.valid()); +#ifndef TEST_HAS_NO_EXCEPTIONS try { f = p0.get_future(); @@ -42,6 +43,7 @@ int main() assert(e.code() == make_error_code(std::future_errc::no_state)); } assert(test_alloc_base::alloc_count == 1); +#endif } assert(test_alloc_base::alloc_count == 0); { @@ -51,6 +53,7 @@ int main() std::future<int&> f = p.get_future(); assert(test_alloc_base::alloc_count == 1); assert(f.valid()); +#ifndef TEST_HAS_NO_EXCEPTIONS try { f = p0.get_future(); @@ -61,6 +64,7 @@ int main() assert(e.code() == make_error_code(std::future_errc::no_state)); } assert(test_alloc_base::alloc_count == 1); +#endif } assert(test_alloc_base::alloc_count == 0); { @@ -70,6 +74,7 @@ int main() std::future<void> f = p.get_future(); assert(test_alloc_base::alloc_count == 1); assert(f.valid()); +#ifndef TEST_HAS_NO_EXCEPTIONS try { f = p0.get_future(); @@ -80,6 +85,7 @@ int main() assert(e.code() == make_error_code(std::future_errc::no_state)); } assert(test_alloc_base::alloc_count == 1); +#endif } assert(test_alloc_base::alloc_count == 0); } diff --git a/test/std/thread/futures/futures.promise/set_exception.pass.cpp b/test/std/thread/futures/futures.promise/set_exception.pass.cpp index 6ef41af94545..8788c6314d0f 100644 --- a/test/std/thread/futures/futures.promise/set_exception.pass.cpp +++ b/test/std/thread/futures/futures.promise/set_exception.pass.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -// XFAIL: libcpp-no-exceptions +// UNSUPPORTED: libcpp-no-exceptions // UNSUPPORTED: libcpp-has-no-threads // UNSUPPORTED: c++98, c++03 diff --git a/test/std/thread/futures/futures.promise/set_exception_at_thread_exit.pass.cpp b/test/std/thread/futures/futures.promise/set_exception_at_thread_exit.pass.cpp index f54d7cd16bdb..1cdeadf84958 100644 --- a/test/std/thread/futures/futures.promise/set_exception_at_thread_exit.pass.cpp +++ b/test/std/thread/futures/futures.promise/set_exception_at_thread_exit.pass.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -// XFAIL: libcpp-no-exceptions +// UNSUPPORTED: libcpp-no-exceptions // UNSUPPORTED: libcpp-has-no-threads // UNSUPPORTED: c++98, c++03 @@ -22,7 +22,6 @@ void func(std::promise<int> p) { - const int i = 5; p.set_exception_at_thread_exit(std::make_exception_ptr(3)); } diff --git a/test/std/thread/futures/futures.promise/set_lvalue.pass.cpp b/test/std/thread/futures/futures.promise/set_lvalue.pass.cpp index 98394871e703..6e2a4a5d9109 100644 --- a/test/std/thread/futures/futures.promise/set_lvalue.pass.cpp +++ b/test/std/thread/futures/futures.promise/set_lvalue.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// // -// XFAIL: libcpp-no-exceptions // UNSUPPORTED: libcpp-has-no-threads // UNSUPPORTED: c++98, c++03 @@ -20,6 +19,8 @@ #include <future> #include <cassert> +#include "test_macros.h" + int main() { { @@ -32,6 +33,7 @@ int main() assert(j == 3); ++i; assert(j == 4); +#ifndef TEST_HAS_NO_EXCEPTIONS try { p.set_value(i); @@ -41,5 +43,6 @@ int main() { assert(e.code() == make_error_code(std::future_errc::promise_already_satisfied)); } +#endif } } diff --git a/test/std/thread/futures/futures.promise/set_value_const.pass.cpp b/test/std/thread/futures/futures.promise/set_value_const.pass.cpp index db7465ceab85..9c670c1e3f77 100644 --- a/test/std/thread/futures/futures.promise/set_value_const.pass.cpp +++ b/test/std/thread/futures/futures.promise/set_value_const.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// // -// XFAIL: libcpp-no-exceptions // UNSUPPORTED: libcpp-has-no-threads // UNSUPPORTED: c++98, c++03 @@ -20,10 +19,14 @@ #include <future> #include <cassert> +#include "test_macros.h" + struct A { A() {} - A(const A&) {throw 10;} + A(const A&) { + TEST_THROW(10); + } }; int main() @@ -36,6 +39,7 @@ int main() p.set_value(i); ++i; assert(f.get() == 3); +#ifndef TEST_HAS_NO_EXCEPTIONS --i; try { @@ -46,12 +50,14 @@ int main() { assert(e.code() == make_error_code(std::future_errc::promise_already_satisfied)); } +#endif } { typedef A T; T i; std::promise<T> p; std::future<T> f = p.get_future(); +#ifndef TEST_HAS_NO_EXCEPTIONS try { p.set_value(i); @@ -61,5 +67,6 @@ int main() { assert(j == 10); } +#endif } } diff --git a/test/std/thread/futures/futures.promise/set_value_void.pass.cpp b/test/std/thread/futures/futures.promise/set_value_void.pass.cpp index 87be8cd60a5e..30c6853c973b 100644 --- a/test/std/thread/futures/futures.promise/set_value_void.pass.cpp +++ b/test/std/thread/futures/futures.promise/set_value_void.pass.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -// XFAIL: libcpp-no-exceptions +// UNSUPPORTED: libcpp-no-exceptions // UNSUPPORTED: libcpp-has-no-threads // UNSUPPORTED: c++98, c++03 diff --git a/test/std/thread/futures/futures.shared_future/copy_assign.pass.cpp b/test/std/thread/futures/futures.shared_future/copy_assign.pass.cpp index 3f9e945dddaf..abb9928e88a1 100644 --- a/test/std/thread/futures/futures.shared_future/copy_assign.pass.cpp +++ b/test/std/thread/futures/futures.shared_future/copy_assign.pass.cpp @@ -15,10 +15,13 @@ // class shared_future<R> // shared_future& operator=(const shared_future& rhs); +// noexcept in C++17 #include <future> #include <cassert> +#include "test_macros.h" + int main() { { @@ -27,6 +30,9 @@ int main() std::shared_future<T> f0 = p.get_future(); std::shared_future<T> f; f = f0; +#if TEST_STD_VER > 14 + static_assert(noexcept(f = f0), "" ); +#endif assert(f0.valid()); assert(f.valid()); } diff --git a/test/std/thread/futures/futures.shared_future/copy_ctor.pass.cpp b/test/std/thread/futures/futures.shared_future/copy_ctor.pass.cpp index 1da08808db2e..2b6633138879 100644 --- a/test/std/thread/futures/futures.shared_future/copy_ctor.pass.cpp +++ b/test/std/thread/futures/futures.shared_future/copy_ctor.pass.cpp @@ -15,10 +15,13 @@ // class shared_future<R> // shared_future(const shared_future& rhs); +// noexcept in C++17 #include <future> #include <cassert> +#include "test_macros.h" + int main() { { @@ -26,6 +29,9 @@ int main() std::promise<T> p; std::shared_future<T> f0 = p.get_future(); std::shared_future<T> f = f0; +#if TEST_STD_VER > 14 + static_assert(noexcept(std::shared_future<T>{f0}), "" ); +#endif assert(f0.valid()); assert(f.valid()); } diff --git a/test/std/thread/futures/futures.shared_future/get.pass.cpp b/test/std/thread/futures/futures.shared_future/get.pass.cpp index 6eea1d889b6d..23d33138e3bc 100644 --- a/test/std/thread/futures/futures.shared_future/get.pass.cpp +++ b/test/std/thread/futures/futures.shared_future/get.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// // -// XFAIL: libcpp-no-exceptions // UNSUPPORTED: libcpp-has-no-threads // UNSUPPORTED: c++98, c++03 @@ -22,6 +21,8 @@ #include <future> #include <cassert> +#include "test_macros.h" + void func1(std::promise<int> p) { std::this_thread::sleep_for(std::chrono::milliseconds(500)); @@ -73,6 +74,7 @@ int main() assert(f.get() == 3); assert(f.valid()); } +#ifndef TEST_HAS_NO_EXCEPTIONS { std::promise<T> p; std::shared_future<T> f = p.get_future(); @@ -89,6 +91,7 @@ int main() } assert(f.valid()); } +#endif } { typedef int& T; @@ -100,6 +103,7 @@ int main() assert(f.get() == 5); assert(f.valid()); } +#ifndef TEST_HAS_NO_EXCEPTIONS { std::promise<T> p; std::shared_future<T> f = p.get_future(); @@ -116,6 +120,7 @@ int main() } assert(f.valid()); } +#endif } { typedef void T; @@ -127,6 +132,7 @@ int main() f.get(); assert(f.valid()); } +#ifndef TEST_HAS_NO_EXCEPTIONS { std::promise<T> p; std::shared_future<T> f = p.get_future(); @@ -143,5 +149,6 @@ int main() } assert(f.valid()); } +#endif } } diff --git a/test/std/thread/futures/futures.task/futures.task.members/ctor1.fail.cpp b/test/std/thread/futures/futures.task/futures.task.members/ctor1.fail.cpp index 6d7d734bd5e7..9d1ad61cef69 100644 --- a/test/std/thread/futures/futures.task/futures.task.members/ctor1.fail.cpp +++ b/test/std/thread/futures/futures.task/futures.task.members/ctor1.fail.cpp @@ -28,6 +28,9 @@ typedef volatile std::packaged_task<A(int, char)> VPT; int main() { - PT p { VPT{} }; // expected-error {{no matching constructor for initialization of 'PT' (aka 'packaged_task<A (int, char)>')}} - // expected-note@future:* 1 {{candidate template ignored: disabled by 'enable_if'}} + VPT init{}; + auto const& c_init = init; + PT p1{init}; // expected-error {{no matching constructor}} + PT p2{c_init}; // expected-error {{no matching constructor}} + PT p3{std::move(init)}; // expected-error {{no matching constructor for initialization of 'PT' (aka 'packaged_task<A (int, char)>')}} } diff --git a/test/std/thread/futures/futures.task/futures.task.members/dtor.pass.cpp b/test/std/thread/futures/futures.task/futures.task.members/dtor.pass.cpp index 7fafd1005649..07eeaaa46afe 100644 --- a/test/std/thread/futures/futures.task/futures.task.members/dtor.pass.cpp +++ b/test/std/thread/futures/futures.task/futures.task.members/dtor.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// // -// XFAIL: libcpp-no-exceptions // UNSUPPORTED: libcpp-has-no-threads // UNSUPPORTED: c++98, c++03 @@ -20,6 +19,8 @@ #include <future> #include <cassert> +#include "test_macros.h" + class A { long data_; @@ -30,7 +31,7 @@ public: long operator()(long i, long j) const {return data_ + i + j;} }; -void func(std::packaged_task<double(int, char)> p) +void func(std::packaged_task<double(int, char)>) { } @@ -41,6 +42,7 @@ void func2(std::packaged_task<double(int, char)> p) int main() { +#ifndef TEST_HAS_NO_EXCEPTIONS { std::packaged_task<double(int, char)> p(A(5)); std::future<double> f = p.get_future(); @@ -48,6 +50,7 @@ int main() try { double i = f.get(); + ((void)i); // Prevent unused warning assert(false); } catch (const std::future_error& e) @@ -55,6 +58,7 @@ int main() assert(e.code() == make_error_code(std::future_errc::broken_promise)); } } +#endif { std::packaged_task<double(int, char)> p(A(5)); std::future<double> f = p.get_future(); diff --git a/test/std/thread/futures/futures.task/futures.task.members/get_future.pass.cpp b/test/std/thread/futures/futures.task/futures.task.members/get_future.pass.cpp index c8e5d6efd6b4..8f51dccd8d30 100644 --- a/test/std/thread/futures/futures.task/futures.task.members/get_future.pass.cpp +++ b/test/std/thread/futures/futures.task/futures.task.members/get_future.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// // -// XFAIL: libcpp-no-exceptions // UNSUPPORTED: libcpp-has-no-threads // UNSUPPORTED: c++98, c++03 @@ -20,6 +19,8 @@ #include <future> #include <cassert> +#include "test_macros.h" + class A { long data_; @@ -38,6 +39,7 @@ int main() p(3, 'a'); assert(f.get() == 105.0); } +#ifndef TEST_HAS_NO_EXCEPTIONS { std::packaged_task<double(int, char)> p(A(5)); std::future<double> f = p.get_future(); @@ -63,4 +65,5 @@ int main() assert(e.code() == make_error_code(std::future_errc::no_state)); } } +#endif } diff --git a/test/std/thread/futures/futures.task/futures.task.members/make_ready_at_thread_exit.pass.cpp b/test/std/thread/futures/futures.task/futures.task.members/make_ready_at_thread_exit.pass.cpp index 54ac64458248..a597c9d8304d 100644 --- a/test/std/thread/futures/futures.task/futures.task.members/make_ready_at_thread_exit.pass.cpp +++ b/test/std/thread/futures/futures.task/futures.task.members/make_ready_at_thread_exit.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// // -// XFAIL: libcpp-no-exceptions // UNSUPPORTED: libcpp-has-no-threads // UNSUPPORTED: c++98, c++03 @@ -20,6 +19,8 @@ #include <future> #include <cassert> +#include "test_macros.h" + class A { long data_; @@ -30,7 +31,7 @@ public: long operator()(long i, long j) const { if (j == 'z') - throw A(6); + TEST_THROW(A(6)); return data_ + i + j; } }; @@ -49,6 +50,7 @@ void func1(std::packaged_task<double(int, char)> p) void func2(std::packaged_task<double(int, char)> p) { +#ifndef TEST_HAS_NO_EXCEPTIONS p.make_ready_at_thread_exit(3, 'a'); try { @@ -58,10 +60,14 @@ void func2(std::packaged_task<double(int, char)> p) { assert(e.code() == make_error_code(std::future_errc::promise_already_satisfied)); } +#else + ((void)p); +#endif } void func3(std::packaged_task<double(int, char)> p) { +#ifndef TEST_HAS_NO_EXCEPTIONS try { p.make_ready_at_thread_exit(3, 'a'); @@ -70,6 +76,9 @@ void func3(std::packaged_task<double(int, char)> p) { assert(e.code() == make_error_code(std::future_errc::no_state)); } +#else + ((void)p); +#endif } int main() @@ -80,6 +89,7 @@ int main() std::thread(func0, std::move(p)).detach(); assert(f.get() == 105.0); } +#ifndef TEST_HAS_NO_EXCEPTIONS { std::packaged_task<double(int, char)> p(A(5)); std::future<double> f = p.get_future(); @@ -105,4 +115,5 @@ int main() std::thread t(func3, std::move(p)); t.join(); } +#endif } diff --git a/test/std/thread/futures/futures.task/futures.task.members/operator.pass.cpp b/test/std/thread/futures/futures.task/futures.task.members/operator.pass.cpp index 9ad1509517f6..6acf8c5a619b 100644 --- a/test/std/thread/futures/futures.task/futures.task.members/operator.pass.cpp +++ b/test/std/thread/futures/futures.task/futures.task.members/operator.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// // -// XFAIL: libcpp-no-exceptions // UNSUPPORTED: libcpp-has-no-threads // UNSUPPORTED: c++98, c++03 @@ -20,6 +19,8 @@ #include <future> #include <cassert> +#include "test_macros.h" + class A { long data_; @@ -30,7 +31,7 @@ public: long operator()(long i, long j) const { if (j == 'z') - throw A(6); + TEST_THROW(A(6)); return data_ + i + j; } }; @@ -49,6 +50,7 @@ void func1(std::packaged_task<double(int, char)> p) void func2(std::packaged_task<double(int, char)> p) { +#ifndef TEST_HAS_NO_EXCEPTIONS p(3, 'a'); try { @@ -58,10 +60,14 @@ void func2(std::packaged_task<double(int, char)> p) { assert(e.code() == make_error_code(std::future_errc::promise_already_satisfied)); } +#else + ((void)p); +#endif } void func3(std::packaged_task<double(int, char)> p) { +#ifndef TEST_HAS_NO_EXCEPTIONS try { p(3, 'a'); @@ -70,6 +76,9 @@ void func3(std::packaged_task<double(int, char)> p) { assert(e.code() == make_error_code(std::future_errc::no_state)); } +#else + ((void)p); +#endif } int main() @@ -80,6 +89,7 @@ int main() std::thread(func0, std::move(p)).detach(); assert(f.get() == 105.0); } +#ifndef TEST_HAS_NO_EXCEPTIONS { std::packaged_task<double(int, char)> p(A(5)); std::future<double> f = p.get_future(); @@ -106,4 +116,5 @@ int main() std::thread t(func3, std::move(p)); t.join(); } +#endif } diff --git a/test/std/thread/futures/futures.task/futures.task.members/reset.pass.cpp b/test/std/thread/futures/futures.task/futures.task.members/reset.pass.cpp index 02a567500ee2..190afdc6af66 100644 --- a/test/std/thread/futures/futures.task/futures.task.members/reset.pass.cpp +++ b/test/std/thread/futures/futures.task/futures.task.members/reset.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// // -// XFAIL: libcpp-no-exceptions // UNSUPPORTED: libcpp-has-no-threads // UNSUPPORTED: c++98, c++03 @@ -20,6 +19,8 @@ #include <future> #include <cassert> +#include "test_macros.h" + class A { long data_; @@ -29,8 +30,6 @@ public: long operator()(long i, long j) const { - if (j == 'z') - throw A(6); return data_ + i + j; } }; @@ -47,6 +46,7 @@ int main() f = p.get_future(); assert(f.get() == 106.0); } +#ifndef TEST_HAS_NO_EXCEPTIONS { std::packaged_task<double(int, char)> p; try @@ -59,4 +59,5 @@ int main() assert(e.code() == make_error_code(std::future_errc::no_state)); } } +#endif } diff --git a/test/std/thread/futures/futures.unique_future/get.pass.cpp b/test/std/thread/futures/futures.unique_future/get.pass.cpp index 67b1052c175d..87a54251ecde 100644 --- a/test/std/thread/futures/futures.unique_future/get.pass.cpp +++ b/test/std/thread/futures/futures.unique_future/get.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// // -// XFAIL: libcpp-no-exceptions // UNSUPPORTED: libcpp-has-no-threads // UNSUPPORTED: c++98, c++03 @@ -22,6 +21,8 @@ #include <future> #include <cassert> +#include "test_macros.h" + void func1(std::promise<int> p) { std::this_thread::sleep_for(std::chrono::milliseconds(500)); @@ -73,6 +74,7 @@ int main() assert(f.get() == 3); assert(!f.valid()); } +#ifndef TEST_HAS_NO_EXCEPTIONS { std::promise<T> p; std::future<T> f = p.get_future(); @@ -89,6 +91,7 @@ int main() } assert(!f.valid()); } +#endif } { typedef int& T; @@ -100,6 +103,7 @@ int main() assert(f.get() == 5); assert(!f.valid()); } +#ifndef TEST_HAS_NO_EXCEPTIONS { std::promise<T> p; std::future<T> f = p.get_future(); @@ -116,6 +120,7 @@ int main() } assert(!f.valid()); } +#endif } { typedef void T; @@ -127,6 +132,7 @@ int main() f.get(); assert(!f.valid()); } +#ifndef TEST_HAS_NO_EXCEPTIONS { std::promise<T> p; std::future<T> f = p.get_future(); @@ -143,5 +149,6 @@ int main() } assert(!f.valid()); } +#endif } } diff --git a/test/std/thread/thread.condition/PR30202_notify_from_pthread_created_thread.pass.cpp b/test/std/thread/thread.condition/PR30202_notify_from_pthread_created_thread.pass.cpp new file mode 100644 index 000000000000..d60e42918860 --- /dev/null +++ b/test/std/thread/thread.condition/PR30202_notify_from_pthread_created_thread.pass.cpp @@ -0,0 +1,75 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// UNSUPPORTED: libcpp-has-no-threads + +// notify_all_at_thread_exit(...) requires move semantics to transfer the +// unique_lock. +// UNSUPPORTED: c++98, c++03 + +// <condition_variable> + +// void +// notify_all_at_thread_exit(condition_variable& cond, unique_lock<mutex> lk); + +// Test that this function works with threads that were not created by +// std::thread. See http://llvm.org/PR30202. + + +#include <condition_variable> +#include <mutex> +#include <thread> +#include <chrono> +#include <cassert> +#include <pthread.h> + +std::condition_variable cv; +std::mutex mut; +bool exited = false; + +typedef std::chrono::milliseconds ms; +typedef std::chrono::high_resolution_clock Clock; + +void* func(void*) +{ + std::unique_lock<std::mutex> lk(mut); + std::notify_all_at_thread_exit(cv, std::move(lk)); + std::this_thread::sleep_for(ms(300)); + exited = true; + return nullptr; +} + +int main() +{ + { + std::unique_lock<std::mutex> lk(mut); + pthread_t id; + int res = pthread_create(&id, 0, &func, nullptr); + assert(res == 0); + Clock::time_point t0 = Clock::now(); + assert(exited == false); + cv.wait(lk); + Clock::time_point t1 = Clock::now(); + assert(exited); + assert(t1-t0 > ms(250)); + pthread_join(id, 0); + } + exited = false; + { + std::unique_lock<std::mutex> lk(mut); + std::thread t(&func, nullptr); + Clock::time_point t0 = Clock::now(); + assert(exited == false); + cv.wait(lk); + Clock::time_point t1 = Clock::now(); + assert(exited); + assert(t1-t0 > ms(250)); + t.join(); + } +} diff --git a/test/std/thread/thread.condition/thread.condition.condvar/wait_for_pred.pass.cpp b/test/std/thread/thread.condition/thread.condition.condvar/wait_for_pred.pass.cpp index 0ee40d161b7b..9c0af808686e 100644 --- a/test/std/thread/thread.condition/thread.condition.condvar/wait_for_pred.pass.cpp +++ b/test/std/thread/thread.condition/thread.condition.condvar/wait_for_pred.pass.cpp @@ -52,6 +52,7 @@ void f() cv.notify_one(); Clock::time_point t0 = Clock::now(); bool r = cv.wait_for(lk, milliseconds(250), Pred(test2)); + ((void)r); // Prevent unused warning Clock::time_point t1 = Clock::now(); if (runs == 0) { diff --git a/test/std/thread/thread.condition/thread.condition.condvarany/wait_for_pred.pass.cpp b/test/std/thread/thread.condition/thread.condition.condvarany/wait_for_pred.pass.cpp index b2403079275d..47da788335c2 100644 --- a/test/std/thread/thread.condition/thread.condition.condvarany/wait_for_pred.pass.cpp +++ b/test/std/thread/thread.condition/thread.condition.condvarany/wait_for_pred.pass.cpp @@ -44,6 +44,7 @@ int test1 = 0; int test2 = 0; int runs = 0; +bool expect_result = false; void f() { @@ -54,7 +55,8 @@ void f() test1 = 1; cv.notify_one(); Clock::time_point t0 = Clock::now(); - bool r = cv.wait_for(lk, milliseconds(250), Pred(test2)); + bool result = cv.wait_for(lk, milliseconds(250), Pred(test2)); + assert(result == expect_result); Clock::time_point t1 = Clock::now(); if (runs == 0) { @@ -72,6 +74,7 @@ void f() int main() { { + expect_result = true; L1 lk(m0); std::thread t(f); assert(test1 == 0); @@ -86,6 +89,7 @@ int main() test1 = 0; test2 = 0; { + expect_result = false; L1 lk(m0); std::thread t(f); assert(test1 == 0); diff --git a/test/std/thread/thread.condition/thread.condition.condvarany/wait_terminates.sh.cpp b/test/std/thread/thread.condition/thread.condition.condvarany/wait_terminates.sh.cpp index f9a35cc905c7..a2b7061c2546 100644 --- a/test/std/thread/thread.condition/thread.condition.condvarany/wait_terminates.sh.cpp +++ b/test/std/thread/thread.condition/thread.condition.condvarany/wait_terminates.sh.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -// XFAIL: libcpp-no-exceptions +// UNSUPPORTED: libcpp-no-exceptions // UNSUPPORTED: libcpp-has-no-threads // <condition_variable> diff --git a/test/std/thread/thread.mutex/thread.lock.algorithm/lock.pass.cpp b/test/std/thread/thread.mutex/thread.lock.algorithm/lock.pass.cpp index eac7600b5d11..46d04cdac350 100644 --- a/test/std/thread/thread.mutex/thread.lock.algorithm/lock.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock.algorithm/lock.pass.cpp @@ -7,9 +7,13 @@ // //===----------------------------------------------------------------------===// // -// XFAIL: libcpp-no-exceptions // UNSUPPORTED: libcpp-has-no-threads +// This test hangs forever when built against libstdc++. In order to allow +// validation of the test suite against other STLs we have to mark it +// unsupported. +// UNSUPPORTED: libstdc++ + // <mutex> // template <class L1, class L2, class... L3> @@ -18,6 +22,8 @@ #include <mutex> #include <cassert> +#include "test_macros.h" + class L0 { bool locked_; @@ -73,12 +79,12 @@ public: void lock() { - throw 1; + TEST_THROW(1); } bool try_lock() { - throw 1; + TEST_THROW(1); return locked_; } @@ -110,6 +116,7 @@ int main() assert(l0.locked()); assert(l1.locked()); } +#ifndef TEST_HAS_NO_EXCEPTIONS { L0 l0; L2 l1; @@ -180,6 +187,7 @@ int main() assert(!l1.locked()); } } +#endif #ifndef _LIBCPP_HAS_NO_VARIADICS { L0 l0; @@ -190,6 +198,7 @@ int main() assert(l1.locked()); assert(l2.locked()); } +#ifndef TEST_HAS_NO_EXCEPTIONS { L2 l0; L2 l1; @@ -206,6 +215,7 @@ int main() assert(!l2.locked()); } } +#endif { L0 l0; L0 l1; @@ -233,6 +243,7 @@ int main() assert(l1.locked()); assert(l2.locked()); } +#ifndef TEST_HAS_NO_EXCEPTIONS { L0 l0; L0 l1; @@ -377,6 +388,7 @@ int main() assert(!l2.locked()); } } +#endif // TEST_HAS_NO_EXCEPTIONS { L0 l0; L0 l1; @@ -432,6 +444,7 @@ int main() assert(l2.locked()); assert(l3.locked()); } +#ifndef TEST_HAS_NO_EXCEPTIONS { L0 l0; L0 l1; @@ -504,5 +517,6 @@ int main() assert(!l3.locked()); } } +#endif // TEST_HAS_NO_EXCEPTIONS #endif // _LIBCPP_HAS_NO_VARIADICS } diff --git a/test/std/thread/thread.mutex/thread.lock.algorithm/try_lock.pass.cpp b/test/std/thread/thread.mutex/thread.lock.algorithm/try_lock.pass.cpp index 8889408be2d7..fb563cbe0b14 100644 --- a/test/std/thread/thread.mutex/thread.lock.algorithm/try_lock.pass.cpp +++ b/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 // <mutex> @@ -18,6 +17,8 @@ #include <mutex> #include <cassert> +#include "test_macros.h" + class L0 { bool locked_; @@ -63,7 +64,7 @@ public: 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/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_adopt_lock.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_adopt_lock.pass.cpp index 840af6788d04..81fc0d368f6a 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_adopt_lock.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_adopt_lock.pass.cpp @@ -16,6 +16,7 @@ // lock_guard(Mutex&..., adopt_lock_t); +// MODULES_DEFINES: _LIBCPP_ABI_VARIADIC_LOCK_GUARD #define _LIBCPP_ABI_VARIADIC_LOCK_GUARD #include <mutex> #include <cassert> diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_assign.fail.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_assign.fail.cpp index 18193e000edc..1b4c9d4bfd5d 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_assign.fail.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_assign.fail.cpp @@ -16,6 +16,7 @@ // lock_guard& operator=(lock_guard const&) = delete; +// MODULES_DEFINES: _LIBCPP_ABI_VARIADIC_LOCK_GUARD #define _LIBCPP_ABI_VARIADIC_LOCK_GUARD #include <mutex> diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_copy.fail.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_copy.fail.cpp index 6dc37e970fb6..c7fd0e94b771 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_copy.fail.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_copy.fail.cpp @@ -16,6 +16,7 @@ // lock_guard(lock_guard const&) = delete; +// MODULES_DEFINES: _LIBCPP_ABI_VARIADIC_LOCK_GUARD #define _LIBCPP_ABI_VARIADIC_LOCK_GUARD #include <mutex> diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_mutex.fail.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_mutex.fail.cpp index 866538a2834f..1eef7e268fb2 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_mutex.fail.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_mutex.fail.cpp @@ -16,6 +16,7 @@ // explicit lock_guard(Mutex&...); +// MODULES_DEFINES: _LIBCPP_ABI_VARIADIC_LOCK_GUARD #define _LIBCPP_ABI_VARIADIC_LOCK_GUARD #include <mutex> diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_mutex.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_mutex.pass.cpp index 4910d837cae3..8d83ddf98c6d 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_mutex.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_mutex.pass.cpp @@ -16,6 +16,7 @@ // explicit lock_guard(mutex_type& m); +// MODULES_DEFINES: _LIBCPP_ABI_VARIADIC_LOCK_GUARD #define _LIBCPP_ABI_VARIADIC_LOCK_GUARD #include <mutex> #include <cassert> diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_mutex_cxx03.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_mutex_cxx03.pass.cpp index 3c134e0b8861..0ad16e2856fd 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_mutex_cxx03.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_mutex_cxx03.pass.cpp @@ -8,7 +8,6 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads - // <mutex> // template <class ...Mutex> class lock_guard; @@ -17,5 +16,6 @@ // dialects, including C++03, even though it is forward declared using // variadic templates. +// MODULES_DEFINES: _LIBCPP_ABI_VARIADIC_LOCK_GUARD #define _LIBCPP_ABI_VARIADIC_LOCK_GUARD #include "mutex.pass.cpp" // Use the existing non-variadic test diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_types.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_types.pass.cpp index 2b06742a673e..600399d9793e 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_types.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_types.pass.cpp @@ -20,6 +20,7 @@ // ... // }; +// MODULES_DEFINES: _LIBCPP_ABI_VARIADIC_LOCK_GUARD #define _LIBCPP_ABI_VARIADIC_LOCK_GUARD #include <mutex> #include <type_traits> 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 12bef34cf87b..f9a537085c30 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 @@ -10,6 +10,8 @@ // UNSUPPORTED: libcpp-has-no-threads // UNSUPPORTED: c++98, c++03, c++11 +// FLAKY_TEST. + // <shared_mutex> // template <class Mutex> class shared_lock; 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 84f868d6810b..839e12dba685 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 @@ -10,6 +10,8 @@ // UNSUPPORTED: libcpp-has-no-threads // UNSUPPORTED: c++98, c++03, c++11 +// FLAKY_TEST. + // <shared_mutex> // class timed_mutex; 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 9359731486dd..9401cea2ed10 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 @@ -10,6 +10,8 @@ // UNSUPPORTED: libcpp-has-no-threads // UNSUPPORTED: c++98, c++03, c++11 +// FLAKY_TEST. + // <shared_mutex> // class shared_timed_mutex; 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 5c3513c98e03..25d78ab19021 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 @@ -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/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 01693c77ea39..947b1ad012ec 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 @@ -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 <shared_mutex> #include <cassert> +#include "test_macros.h" + bool try_lock_called = false; struct mutex @@ -36,11 +37,11 @@ mutex m; int main() { - std::shared_lock<mutex> 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/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 852a94eb65ec..5cb805412563 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 @@ -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 <shared_mutex> #include <cassert> +#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/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 31574afd7d8f..3ba4128d719c 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 @@ -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 <shared_mutex> #include <cassert> +#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/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 6a7385ed42a6..903b53ace0f2 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 @@ -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 <shared_mutex> #include <cassert> +#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/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_duration.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_duration.pass.cpp index 33e400b0da80..0939a5792644 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_duration.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_duration.pass.cpp @@ -9,6 +9,8 @@ // // UNSUPPORTED: libcpp-has-no-threads +// FLAKY_TEST. + // <mutex> // class timed_mutex; diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_time_point.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_time_point.pass.cpp index 2ead67097730..ceb29370182d 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_time_point.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_time_point.pass.cpp @@ -9,6 +9,8 @@ // // UNSUPPORTED: libcpp-has-no-threads +// FLAKY_TEST. + // <mutex> // class timed_mutex; diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/lock.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/lock.pass.cpp index 6ce33761068f..cb5c55925eef 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/lock.pass.cpp +++ b/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 // <mutex> @@ -21,6 +20,8 @@ #include <cstdlib> #include <cassert> +#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/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock.pass.cpp index 27d0562de31f..709c56978af8 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock.pass.cpp +++ b/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 // <mutex> @@ -19,6 +18,8 @@ #include <mutex> #include <cassert> +#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/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_for.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_for.pass.cpp index 6f0a7219d2d8..6c981787d4b4 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_for.pass.cpp +++ b/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 // <mutex> @@ -20,6 +19,8 @@ #include <mutex> #include <cassert> +#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/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_until.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_until.pass.cpp index b7e87249b596..57231b207a72 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_until.pass.cpp +++ b/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 // <mutex> @@ -20,6 +19,8 @@ #include <mutex> #include <cassert> +#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/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/unlock.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/unlock.pass.cpp index 62497c9ec45a..124ff551f947 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/unlock.pass.cpp +++ b/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 // <mutex> @@ -19,6 +18,8 @@ #include <mutex> #include <cassert> +#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/test/std/thread/thread.mutex/thread.lock/types.pass.cpp b/test/std/thread/thread.mutex/thread.lock/types.pass.cpp index 64df0680b0b9..5baaee533a6a 100644 --- a/test/std/thread/thread.mutex/thread.lock/types.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/types.pass.cpp @@ -28,7 +28,7 @@ int main() typedef std::try_to_lock_t T2; typedef std::adopt_lock_t T3; - T1 t1 = std::defer_lock; - T2 t2 = std::try_to_lock; - T3 t3 = std::adopt_lock; + T1 t1 = std::defer_lock; ((void)t1); + T2 t2 = std::try_to_lock; ((void)t2); + T3 t3 = std::adopt_lock; ((void)t3); } diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/lock.pass.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/lock.pass.cpp index 75ddebff0ed9..0a6d6e3683ed 100644 --- a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/lock.pass.cpp +++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/lock.pass.cpp @@ -10,6 +10,8 @@ // UNSUPPORTED: libcpp-has-no-threads // UNSUPPORTED: c++03, c++98, c++11, c++14 +// FLAKY_TEST. + // <shared_mutex> // class shared_mutex; diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/lock_shared.pass.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/lock_shared.pass.cpp index 6b5089d38859..b7edc50978d2 100644 --- a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/lock_shared.pass.cpp +++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/lock_shared.pass.cpp @@ -10,6 +10,8 @@ // UNSUPPORTED: libcpp-has-no-threads // UNSUPPORTED: c++03, c++98, c++11, c++14 +// FLAKY_TEST. + // <shared_mutex> // class shared_mutex; diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/try_lock_shared.pass.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/try_lock_shared.pass.cpp index 52007155ba5f..f615981bc94d 100644 --- a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/try_lock_shared.pass.cpp +++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/try_lock_shared.pass.cpp @@ -10,6 +10,8 @@ // UNSUPPORTED: libcpp-has-no-threads // UNSUPPORTED: c++03, c++98, c++11, c++14 +// FLAKY_TEST. + // <shared_mutex> // class shared_mutex; diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/lock.pass.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/lock.pass.cpp index 2818bd617542..83979d4c4e51 100644 --- a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/lock.pass.cpp +++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/lock.pass.cpp @@ -10,6 +10,8 @@ // UNSUPPORTED: libcpp-has-no-threads // UNSUPPORTED: c++03, c++98, c++11 +// FLAKY_TEST. + // <shared_mutex> // class shared_timed_mutex; diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/lock_shared.pass.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/lock_shared.pass.cpp index 77a9107de923..516f43192580 100644 --- a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/lock_shared.pass.cpp +++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/lock_shared.pass.cpp @@ -10,6 +10,8 @@ // UNSUPPORTED: libcpp-has-no-threads // UNSUPPORTED: c++03, c++98, c++11 +// FLAKY_TEST. + // <shared_mutex> // class shared_timed_mutex; diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_for.pass.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_for.pass.cpp index 320a268ae77d..3d36911889b1 100644 --- a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_for.pass.cpp +++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_for.pass.cpp @@ -10,6 +10,8 @@ // UNSUPPORTED: libcpp-has-no-threads // UNSUPPORTED: c++03, c++98, c++11 +// FLAKY_TEST. + // <shared_mutex> // class shared_timed_mutex; diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_shared.pass.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_shared.pass.cpp index 3d5604d886cb..452fc3c19d65 100644 --- a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_shared.pass.cpp +++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_shared.pass.cpp @@ -10,6 +10,8 @@ // UNSUPPORTED: libcpp-has-no-threads // UNSUPPORTED: c++03, c++98, c++11 +// FLAKY_TEST. + // <shared_mutex> // class shared_timed_mutex; diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_shared_for.pass.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_shared_for.pass.cpp index 4cdb5873f9a1..f478a29367a1 100644 --- a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_shared_for.pass.cpp +++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_shared_for.pass.cpp @@ -10,6 +10,8 @@ // UNSUPPORTED: libcpp-has-no-threads // UNSUPPORTED: c++03, c++98, c++11 +// FLAKY_TEST. + // <shared_mutex> // class shared_timed_mutex; diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_shared_until.pass.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_shared_until.pass.cpp index f7ddbaeef498..f33edfc1a534 100644 --- a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_shared_until.pass.cpp +++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_shared_until.pass.cpp @@ -10,6 +10,8 @@ // UNSUPPORTED: libcpp-has-no-threads // UNSUPPORTED: c++03, c++98, c++11 +// FLAKY_TEST. + // <shared_mutex> // class shared_timed_mutex; diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_until.pass.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_until.pass.cpp index 1560af2c9ecc..d5715c76f458 100644 --- a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_until.pass.cpp +++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_until.pass.cpp @@ -10,6 +10,8 @@ // UNSUPPORTED: libcpp-has-no-threads // UNSUPPORTED: c++03, c++98, c++11 +// FLAKY_TEST. + // <shared_mutex> // class shared_timed_mutex; diff --git a/test/std/thread/thread.mutex/thread.once/thread.once.callonce/call_once.pass.cpp b/test/std/thread/thread.mutex/thread.once/thread.once.callonce/call_once.pass.cpp index 71b054fced88..138b657196da 100644 --- a/test/std/thread/thread.mutex/thread.once/thread.once.callonce/call_once.pass.cpp +++ b/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 // <mutex> @@ -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); diff --git a/test/std/thread/thread.mutex/thread.once/thread.once.callonce/race.pass.cpp b/test/std/thread/thread.mutex/thread.once/thread.once.callonce/race.pass.cpp new file mode 100644 index 000000000000..33215819f585 --- /dev/null +++ b/test/std/thread/thread.mutex/thread.once/thread.once.callonce/race.pass.cpp @@ -0,0 +1,48 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// UNSUPPORTED: libcpp-has-no-threads + +// <mutex> + +// struct once_flag; + +// template<class Callable, class ...Args> +// void call_once(once_flag& flag, Callable&& func, Args&&... args); + +// This test is supposed to be run with ThreadSanitizer and verifies that +// call_once properly synchronizes user state, a data race that was fixed +// in r280621. + +#include <mutex> +#include <thread> +#include <cassert> + +std::once_flag flg0; +long global = 0; + +void init0() +{ + ++global; +} + +void f0() +{ + std::call_once(flg0, init0); + assert(global == 1); +} + +int main() +{ + std::thread t0(f0); + std::thread t1(f0); + t0.join(); + t1.join(); + assert(global == 1); +} diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/move2.pass.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/move2.pass.cpp index 6c31df593c0e..e452ac98c49e 100644 --- a/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/move2.pass.cpp +++ b/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/move2.pass.cpp @@ -58,7 +58,6 @@ int main() { G g; std::thread t0(g, 5, 5.5); - std::thread::id id = t0.get_id(); std::thread t1; t0 = std::move(t1); assert(false); diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp index 5dd6a40a0eb7..437b42037913 100644 --- a/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp +++ b/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// // -// XFAIL: libcpp-no-exceptions // UNSUPPORTED: libcpp-has-no-threads // <thread> @@ -30,10 +29,10 @@ std::atomic<unsigned> throw_one(0xFFFF); std::atomic<unsigned> outstanding_new(0); -void* operator new(std::size_t s) throw(std::bad_alloc) +void* operator new(std::size_t s) TEST_THROW_SPEC(std::bad_alloc) { if (throw_one == 0) - throw std::bad_alloc(); + TEST_THROW(std::bad_alloc()); --throw_one; ++outstanding_new; void* ret = std::malloc(s); @@ -41,7 +40,7 @@ void* operator new(std::size_t s) throw(std::bad_alloc) return ret; } -void operator delete(void* p) throw() +void operator delete(void* p) TEST_NOEXCEPT { --outstanding_new; std::free(p); @@ -118,6 +117,7 @@ public: // 3 Finally check that a thread runs successfully if we throw after 'N+1' // allocations. void test_throwing_new_during_thread_creation() { +#ifndef TEST_HAS_NO_EXCEPTIONS throw_one = 0xFFF; { std::thread t(f); @@ -142,6 +142,7 @@ void test_throwing_new_during_thread_creation() { } f_run = false; throw_one = 0xFFF; +#endif } int main() @@ -162,6 +163,7 @@ int main() assert(G::op_run); } G::op_run = false; +#ifndef TEST_HAS_NO_EXCEPTIONS { try { @@ -178,6 +180,7 @@ int main() assert(!G::op_run); } } +#endif #if TEST_STD_VER >= 11 { assert(G::n_alive == 0); diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/get_id.pass.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/get_id.pass.cpp index 5cca7b0b66b8..f9f38c85f0e9 100644 --- a/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/get_id.pass.cpp +++ b/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/get_id.pass.cpp @@ -50,7 +50,8 @@ int main() std::thread::id id0 = t0.get_id(); std::thread t1; std::thread::id id1 = t1.get_id(); - assert(t0.get_id() != id1); + assert(t0.get_id() == id0); + assert(id0 != id1); assert(t1.get_id() == std::thread::id()); t0.join(); } |