diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2015-12-30 11:54:09 +0000 | 
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2015-12-30 11:54:09 +0000 | 
| commit | b4c64ad90b81d2a779786b7edb4c5c6dd28cc57d (patch) | |
| tree | 13f237c02db4d1894ab06884d1b739344766bede /test/std/thread | |
| parent | 61b9a7258a7693d7f3674a5a1daf7b036ff1d382 (diff) | |
Notes
Diffstat (limited to 'test/std/thread')
108 files changed, 859 insertions, 1021 deletions
diff --git a/test/std/thread/futures/futures.async/async.pass.cpp b/test/std/thread/futures/futures.async/async.pass.cpp index c8a742566d8f..2c1313b7a2f0 100644 --- a/test/std/thread/futures/futures.async/async.pass.cpp +++ b/test/std/thread/futures/futures.async/async.pass.cpp @@ -7,7 +7,9 @@  //  //===----------------------------------------------------------------------===//  // +// XFAIL: libcpp-no-exceptions  // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03  // <future> diff --git a/test/std/thread/futures/futures.async/async_race.pass.cpp b/test/std/thread/futures/futures.async/async_race.pass.cpp index 325a027132de..9acdd1abc485 100644 --- a/test/std/thread/futures/futures.async/async_race.pass.cpp +++ b/test/std/thread/futures/futures.async/async_race.pass.cpp @@ -8,6 +8,7 @@  //===----------------------------------------------------------------------===//  //  // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03  // <future> diff --git a/test/std/thread/futures/futures.promise/alloc_ctor.pass.cpp b/test/std/thread/futures/futures.promise/alloc_ctor.pass.cpp index 70a4e00b0d6a..c0fe2ef881e8 100644 --- a/test/std/thread/futures/futures.promise/alloc_ctor.pass.cpp +++ b/test/std/thread/futures/futures.promise/alloc_ctor.pass.cpp @@ -8,6 +8,7 @@  //===----------------------------------------------------------------------===//  //  // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03  // <future> @@ -19,36 +20,36 @@  #include <future>  #include <cassert> -#include "../test_allocator.h" +#include "test_allocator.h"  #include "min_allocator.h"  int main()  { -    assert(test_alloc_base::count == 0); +    assert(test_alloc_base::alloc_count == 0);      { -        std::promise<int> p(std::allocator_arg, test_allocator<int>()); -        assert(test_alloc_base::count == 1); +        std::promise<int> p(std::allocator_arg, test_allocator<int>(42)); +        assert(test_alloc_base::alloc_count == 1);          std::future<int> f = p.get_future(); -        assert(test_alloc_base::count == 1); +        assert(test_alloc_base::alloc_count == 1);          assert(f.valid());      } -    assert(test_alloc_base::count == 0); +    assert(test_alloc_base::alloc_count == 0);      { -        std::promise<int&> p(std::allocator_arg, test_allocator<int>()); -        assert(test_alloc_base::count == 1); +        std::promise<int&> p(std::allocator_arg, test_allocator<int>(42)); +        assert(test_alloc_base::alloc_count == 1);          std::future<int&> f = p.get_future(); -        assert(test_alloc_base::count == 1); +        assert(test_alloc_base::alloc_count == 1);          assert(f.valid());      } -    assert(test_alloc_base::count == 0); +    assert(test_alloc_base::alloc_count == 0);      { -        std::promise<void> p(std::allocator_arg, test_allocator<void>()); -        assert(test_alloc_base::count == 1); +        std::promise<void> p(std::allocator_arg, test_allocator<void>(42)); +        assert(test_alloc_base::alloc_count == 1);          std::future<void> f = p.get_future(); -        assert(test_alloc_base::count == 1); +        assert(test_alloc_base::alloc_count == 1);          assert(f.valid());      } -    assert(test_alloc_base::count == 0); +    assert(test_alloc_base::alloc_count == 0);      // Test with a minimal allocator      {          std::promise<int> p(std::allocator_arg, bare_allocator<void>()); diff --git a/test/std/thread/futures/futures.promise/copy_assign.fail.cpp b/test/std/thread/futures/futures.promise/copy_assign.fail.cpp index c08278122225..e150ba0df65a 100644 --- a/test/std/thread/futures/futures.promise/copy_assign.fail.cpp +++ b/test/std/thread/futures/futures.promise/copy_assign.fail.cpp @@ -14,74 +14,36 @@  // promise& operator=(const promise& rhs) = delete;  #include <future> -#include <cassert> -#include "../test_allocator.h" +#include "test_macros.h"  int main()  { -    assert(test_alloc_base::count == 0); +#if TEST_STD_VER >= 11      { -        std::promise<int> p0(std::allocator_arg, test_allocator<int>()); -        std::promise<int> p(std::allocator_arg, test_allocator<int>()); -        assert(test_alloc_base::count == 2); -        p = p0; -        assert(test_alloc_base::count == 1); -        std::future<int> f = p.get_future(); -        assert(test_alloc_base::count == 1); -        assert(f.valid()); -        try -        { -            f = p0.get_future(); -            assert(false); -        } -        catch (const std::future_error& e) -        { -            assert(e.code() == make_error_code(std::future_errc::no_state)); -        } -        assert(test_alloc_base::count == 1); +        std::promise<int> p0, p; +        p = p0; // expected-error {{overload resolution selected deleted operator '='}}      } -    assert(test_alloc_base::count == 0);      { -        std::promise<int&> p0(std::allocator_arg, test_allocator<int>()); -        std::promise<int&> p(std::allocator_arg, test_allocator<int>()); -        assert(test_alloc_base::count == 2); -        p = p0; -        assert(test_alloc_base::count == 1); -        std::future<int&> f = p.get_future(); -        assert(test_alloc_base::count == 1); -        assert(f.valid()); -        try -        { -            f = p0.get_future(); -            assert(false); -        } -        catch (const std::future_error& e) -        { -            assert(e.code() == make_error_code(std::future_errc::no_state)); -        } -        assert(test_alloc_base::count == 1); +        std::promise<int&> p0, p; +        p = p0; // expected-error {{overload resolution selected deleted operator '='}}      } -    assert(test_alloc_base::count == 0);      { -        std::promise<void> p0(std::allocator_arg, test_allocator<void>()); -        std::promise<void> p(std::allocator_arg, test_allocator<void>()); -        assert(test_alloc_base::count == 2); -        p = p0; -        assert(test_alloc_base::count == 1); -        std::future<void> f = p.get_future(); -        assert(test_alloc_base::count == 1); -        assert(f.valid()); -        try -        { -            f = p0.get_future(); -            assert(false); -        } -        catch (const std::future_error& e) -        { -            assert(e.code() == make_error_code(std::future_errc::no_state)); -        } -        assert(test_alloc_base::count == 1); +        std::promise<void> p0, p; +        p = p0; // expected-error {{overload resolution selected deleted operator '='}}      } -    assert(test_alloc_base::count == 0); +#else +    { +        std::promise<int> p0, p; +        p = p0; // expected-error {{'operator=' is a private member of 'std::__1::promise<int>'}} +    } +    { +        std::promise<int&> p0, p; +        p = p0; // expected-error {{'operator=' is a private member of 'std::__1::promise<int &>'}} +    } +    { +        std::promise<void> p0, p; +        p = p0; // expected-error {{'operator=' is a private member of 'std::__1::promise<void>'}} +    } +#endif  } diff --git a/test/std/thread/futures/futures.promise/copy_ctor.fail.cpp b/test/std/thread/futures/futures.promise/copy_ctor.fail.cpp index 36a3555aed46..34becbc1259b 100644 --- a/test/std/thread/futures/futures.promise/copy_ctor.fail.cpp +++ b/test/std/thread/futures/futures.promise/copy_ctor.fail.cpp @@ -14,68 +14,36 @@  // promise(const promise&) = delete;  #include <future> -#include <cassert> -#include "../test_allocator.h" +#include "test_macros.h"  int main()  { -    assert(test_alloc_base::count == 0); +#if TEST_STD_VER >= 11      { -        std::promise<int> p0(std::allocator_arg, test_allocator<int>()); -        std::promise<int> p(p0); -        assert(test_alloc_base::count == 1); -        std::future<int> f = p.get_future(); -        assert(test_alloc_base::count == 1); -        assert(f.valid()); -        try -        { -            f = p0.get_future(); -            assert(false); -        } -        catch (const std::future_error& e) -        { -            assert(e.code() == make_error_code(std::future_errc::no_state)); -        } -        assert(test_alloc_base::count == 1); +        std::promise<int> p0; +        std::promise<int> p(p0); // expected-error {{call to deleted constructor of 'std::promise<int>'}}      } -    assert(test_alloc_base::count == 0);      { -        std::promise<int&> p0(std::allocator_arg, test_allocator<int>()); -        std::promise<int&> p(p0); -        assert(test_alloc_base::count == 1); -        std::future<int&> f = p.get_future(); -        assert(test_alloc_base::count == 1); -        assert(f.valid()); -        try -        { -            f = p0.get_future(); -            assert(false); -        } -        catch (const std::future_error& e) -        { -            assert(e.code() == make_error_code(std::future_errc::no_state)); -        } -        assert(test_alloc_base::count == 1); +        std::promise<int &> p0; +        std::promise<int &> p(p0); // expected-error {{call to deleted constructor of 'std::promise<int &>'}}      } -    assert(test_alloc_base::count == 0);      { -        std::promise<void> p0(std::allocator_arg, test_allocator<void>()); -        std::promise<void> p(p0); -        assert(test_alloc_base::count == 1); -        std::future<void> f = p.get_future(); -        assert(test_alloc_base::count == 1); -        assert(f.valid()); -        try -        { -            f = p0.get_future(); -            assert(false); -        } -        catch (const std::future_error& e) -        { -            assert(e.code() == make_error_code(std::future_errc::no_state)); -        } -        assert(test_alloc_base::count == 1); +        std::promise<void> p0; +        std::promise<void> p(p0); // expected-error {{call to deleted constructor of 'std::promise<void>'}}      } -    assert(test_alloc_base::count == 0); +#else +    { +        std::promise<int> p0; +        std::promise<int> p(p0); // expected-error {{calling a private constructor of class 'std::__1::promise<int>'}} +    } +    { +        std::promise<int &> p0; +        std::promise<int &> p(p0); // expected-error {{calling a private constructor of class 'std::__1::promise<int &>'}} +    } +    { +        std::promise<void> p0; +        std::promise<void> p(p0); // expected-error {{calling a private constructor of class 'std::__1::promise<void>'}} +    } +#endif  } diff --git a/test/std/thread/futures/futures.promise/default.pass.cpp b/test/std/thread/futures/futures.promise/default.pass.cpp index 95c9657c633e..d108b42756e2 100644 --- a/test/std/thread/futures/futures.promise/default.pass.cpp +++ b/test/std/thread/futures/futures.promise/default.pass.cpp @@ -8,6 +8,7 @@  //===----------------------------------------------------------------------===//  //  // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03  // <future> diff --git a/test/std/thread/futures/futures.promise/dtor.pass.cpp b/test/std/thread/futures/futures.promise/dtor.pass.cpp index 78912f12adb9..e3151ab38322 100644 --- a/test/std/thread/futures/futures.promise/dtor.pass.cpp +++ b/test/std/thread/futures/futures.promise/dtor.pass.cpp @@ -7,7 +7,9 @@  //  //===----------------------------------------------------------------------===//  // +// XFAIL: libcpp-no-exceptions  // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03  // <future> 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 a7d084ee7873..bc45e28a9f96 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,9 @@  //  //===----------------------------------------------------------------------===//  // +// XFAIL: libcpp-no-exceptions  // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03  // <future> 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 c3097df74990..9dd8a9daef80 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,9 @@  //  //===----------------------------------------------------------------------===//  // +// XFAIL: libcpp-no-exceptions  // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03  // <future> @@ -18,20 +20,19 @@  #include <future>  #include <cassert> -#include "../test_allocator.h" +#include "test_allocator.h"  int main()  { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES -    assert(test_alloc_base::count == 0); +    assert(test_alloc_base::alloc_count == 0);      {          std::promise<int> p0(std::allocator_arg, test_allocator<int>());          std::promise<int> p(std::allocator_arg, test_allocator<int>()); -        assert(test_alloc_base::count == 2); +        assert(test_alloc_base::alloc_count == 2);          p = std::move(p0); -        assert(test_alloc_base::count == 1); +        assert(test_alloc_base::alloc_count == 1);          std::future<int> f = p.get_future(); -        assert(test_alloc_base::count == 1); +        assert(test_alloc_base::alloc_count == 1);          assert(f.valid());          try          { @@ -42,17 +43,17 @@ int main()          {              assert(e.code() == make_error_code(std::future_errc::no_state));          } -        assert(test_alloc_base::count == 1); +        assert(test_alloc_base::alloc_count == 1);      } -    assert(test_alloc_base::count == 0); +    assert(test_alloc_base::alloc_count == 0);      {          std::promise<int&> p0(std::allocator_arg, test_allocator<int>());          std::promise<int&> p(std::allocator_arg, test_allocator<int>()); -        assert(test_alloc_base::count == 2); +        assert(test_alloc_base::alloc_count == 2);          p = std::move(p0); -        assert(test_alloc_base::count == 1); +        assert(test_alloc_base::alloc_count == 1);          std::future<int&> f = p.get_future(); -        assert(test_alloc_base::count == 1); +        assert(test_alloc_base::alloc_count == 1);          assert(f.valid());          try          { @@ -63,17 +64,17 @@ int main()          {              assert(e.code() == make_error_code(std::future_errc::no_state));          } -        assert(test_alloc_base::count == 1); +        assert(test_alloc_base::alloc_count == 1);      } -    assert(test_alloc_base::count == 0); +    assert(test_alloc_base::alloc_count == 0);      {          std::promise<void> p0(std::allocator_arg, test_allocator<void>());          std::promise<void> p(std::allocator_arg, test_allocator<void>()); -        assert(test_alloc_base::count == 2); +        assert(test_alloc_base::alloc_count == 2);          p = std::move(p0); -        assert(test_alloc_base::count == 1); +        assert(test_alloc_base::alloc_count == 1);          std::future<void> f = p.get_future(); -        assert(test_alloc_base::count == 1); +        assert(test_alloc_base::alloc_count == 1);          assert(f.valid());          try          { @@ -84,8 +85,7 @@ int main()          {              assert(e.code() == make_error_code(std::future_errc::no_state));          } -        assert(test_alloc_base::count == 1); +        assert(test_alloc_base::alloc_count == 1);      } -    assert(test_alloc_base::count == 0); -#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES +    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 eeec4fb15b95..9a68b5c1b4e1 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,9 @@  //  //===----------------------------------------------------------------------===//  // +// XFAIL: libcpp-no-exceptions  // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03  // <future> @@ -18,18 +20,17 @@  #include <future>  #include <cassert> -#include "../test_allocator.h" +#include "test_allocator.h"  int main()  { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES -    assert(test_alloc_base::count == 0); +    assert(test_alloc_base::alloc_count == 0);      {          std::promise<int> p0(std::allocator_arg, test_allocator<int>());          std::promise<int> p(std::move(p0)); -        assert(test_alloc_base::count == 1); +        assert(test_alloc_base::alloc_count == 1);          std::future<int> f = p.get_future(); -        assert(test_alloc_base::count == 1); +        assert(test_alloc_base::alloc_count == 1);          assert(f.valid());          try          { @@ -40,15 +41,15 @@ int main()          {              assert(e.code() == make_error_code(std::future_errc::no_state));          } -        assert(test_alloc_base::count == 1); +        assert(test_alloc_base::alloc_count == 1);      } -    assert(test_alloc_base::count == 0); +    assert(test_alloc_base::alloc_count == 0);      {          std::promise<int&> p0(std::allocator_arg, test_allocator<int>());          std::promise<int&> p(std::move(p0)); -        assert(test_alloc_base::count == 1); +        assert(test_alloc_base::alloc_count == 1);          std::future<int&> f = p.get_future(); -        assert(test_alloc_base::count == 1); +        assert(test_alloc_base::alloc_count == 1);          assert(f.valid());          try          { @@ -59,15 +60,15 @@ int main()          {              assert(e.code() == make_error_code(std::future_errc::no_state));          } -        assert(test_alloc_base::count == 1); +        assert(test_alloc_base::alloc_count == 1);      } -    assert(test_alloc_base::count == 0); +    assert(test_alloc_base::alloc_count == 0);      {          std::promise<void> p0(std::allocator_arg, test_allocator<void>());          std::promise<void> p(std::move(p0)); -        assert(test_alloc_base::count == 1); +        assert(test_alloc_base::alloc_count == 1);          std::future<void> f = p.get_future(); -        assert(test_alloc_base::count == 1); +        assert(test_alloc_base::alloc_count == 1);          assert(f.valid());          try          { @@ -78,8 +79,7 @@ int main()          {              assert(e.code() == make_error_code(std::future_errc::no_state));          } -        assert(test_alloc_base::count == 1); +        assert(test_alloc_base::alloc_count == 1);      } -    assert(test_alloc_base::count == 0); -#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES +    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 51c05eb803cb..6ef41af94545 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,9 @@  //  //===----------------------------------------------------------------------===//  // +// XFAIL: libcpp-no-exceptions  // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03  // <future> 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 5e57692563d8..f54d7cd16bdb 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,9 @@  //  //===----------------------------------------------------------------------===//  // +// XFAIL: libcpp-no-exceptions  // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03  // <future> 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 cdc37775012c..98394871e703 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,9 @@  //  //===----------------------------------------------------------------------===//  // +// XFAIL: libcpp-no-exceptions  // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03  // <future> diff --git a/test/std/thread/futures/futures.promise/set_lvalue_at_thread_exit.pass.cpp b/test/std/thread/futures/futures.promise/set_lvalue_at_thread_exit.pass.cpp index 18f87c596a00..e127d2c37faf 100644 --- a/test/std/thread/futures/futures.promise/set_lvalue_at_thread_exit.pass.cpp +++ b/test/std/thread/futures/futures.promise/set_lvalue_at_thread_exit.pass.cpp @@ -8,6 +8,7 @@  //===----------------------------------------------------------------------===//  //  // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03  // <future> diff --git a/test/std/thread/futures/futures.promise/set_rvalue.pass.cpp b/test/std/thread/futures/futures.promise/set_rvalue.pass.cpp index dab4bf7e9c83..9cce3f59550a 100644 --- a/test/std/thread/futures/futures.promise/set_rvalue.pass.cpp +++ b/test/std/thread/futures/futures.promise/set_rvalue.pass.cpp @@ -7,6 +7,7 @@  //  //===----------------------------------------------------------------------===//  // +// XFAIL: libcpp-no-exceptions  // UNSUPPORTED: libcpp-has-no-threads  // <future> diff --git a/test/std/thread/futures/futures.promise/set_value_at_thread_exit_const.pass.cpp b/test/std/thread/futures/futures.promise/set_value_at_thread_exit_const.pass.cpp index ec50cc310298..79137488e606 100644 --- a/test/std/thread/futures/futures.promise/set_value_at_thread_exit_const.pass.cpp +++ b/test/std/thread/futures/futures.promise/set_value_at_thread_exit_const.pass.cpp @@ -8,6 +8,7 @@  //===----------------------------------------------------------------------===//  //  // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03  // <future> diff --git a/test/std/thread/futures/futures.promise/set_value_at_thread_exit_void.pass.cpp b/test/std/thread/futures/futures.promise/set_value_at_thread_exit_void.pass.cpp index 8c092084668d..6a0ce36326eb 100644 --- a/test/std/thread/futures/futures.promise/set_value_at_thread_exit_void.pass.cpp +++ b/test/std/thread/futures/futures.promise/set_value_at_thread_exit_void.pass.cpp @@ -8,6 +8,7 @@  //===----------------------------------------------------------------------===//  //  // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03  // <future> 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 6673f6307579..db7465ceab85 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,9 @@  //  //===----------------------------------------------------------------------===//  // +// XFAIL: libcpp-no-exceptions  // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03  // <future> 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 5012e0bfe5fd..87be8cd60a5e 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,9 @@  //  //===----------------------------------------------------------------------===//  // +// XFAIL: libcpp-no-exceptions  // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03  // <future> diff --git a/test/std/thread/futures/futures.promise/swap.pass.cpp b/test/std/thread/futures/futures.promise/swap.pass.cpp index 1ed3e646813c..21c946981a28 100644 --- a/test/std/thread/futures/futures.promise/swap.pass.cpp +++ b/test/std/thread/futures/futures.promise/swap.pass.cpp @@ -8,6 +8,7 @@  //===----------------------------------------------------------------------===//  //  // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03  // <future> @@ -20,65 +21,65 @@  #include <future>  #include <cassert> -#include "../test_allocator.h" +#include "test_allocator.h"  int main()  { -    assert(test_alloc_base::count == 0); +    assert(test_alloc_base::alloc_count == 0);      {          std::promise<int> p0(std::allocator_arg, test_allocator<int>());          std::promise<int> p(std::allocator_arg, test_allocator<int>()); -        assert(test_alloc_base::count == 2); +        assert(test_alloc_base::alloc_count == 2);          p.swap(p0); -        assert(test_alloc_base::count == 2); +        assert(test_alloc_base::alloc_count == 2);          std::future<int> f = p.get_future(); -        assert(test_alloc_base::count == 2); +        assert(test_alloc_base::alloc_count == 2);          assert(f.valid());          f = p0.get_future();          assert(f.valid()); -        assert(test_alloc_base::count == 2); +        assert(test_alloc_base::alloc_count == 2);      } -    assert(test_alloc_base::count == 0); +    assert(test_alloc_base::alloc_count == 0);      {          std::promise<int> p0(std::allocator_arg, test_allocator<int>());          std::promise<int> p(std::allocator_arg, test_allocator<int>()); -        assert(test_alloc_base::count == 2); +        assert(test_alloc_base::alloc_count == 2);          swap(p, p0); -        assert(test_alloc_base::count == 2); +        assert(test_alloc_base::alloc_count == 2);          std::future<int> f = p.get_future(); -        assert(test_alloc_base::count == 2); +        assert(test_alloc_base::alloc_count == 2);          assert(f.valid());          f = p0.get_future();          assert(f.valid()); -        assert(test_alloc_base::count == 2); +        assert(test_alloc_base::alloc_count == 2);      } -    assert(test_alloc_base::count == 0); +    assert(test_alloc_base::alloc_count == 0);      {          std::promise<int> p0(std::allocator_arg, test_allocator<int>());          std::promise<int> p; -        assert(test_alloc_base::count == 1); +        assert(test_alloc_base::alloc_count == 1);          p.swap(p0); -        assert(test_alloc_base::count == 1); +        assert(test_alloc_base::alloc_count == 1);          std::future<int> f = p.get_future(); -        assert(test_alloc_base::count == 1); +        assert(test_alloc_base::alloc_count == 1);          assert(f.valid());          f = p0.get_future();          assert(f.valid()); -        assert(test_alloc_base::count == 1); +        assert(test_alloc_base::alloc_count == 1);      } -    assert(test_alloc_base::count == 0); +    assert(test_alloc_base::alloc_count == 0);      {          std::promise<int> p0(std::allocator_arg, test_allocator<int>());          std::promise<int> p; -        assert(test_alloc_base::count == 1); +        assert(test_alloc_base::alloc_count == 1);          swap(p, p0); -        assert(test_alloc_base::count == 1); +        assert(test_alloc_base::alloc_count == 1);          std::future<int> f = p.get_future(); -        assert(test_alloc_base::count == 1); +        assert(test_alloc_base::alloc_count == 1);          assert(f.valid());          f = p0.get_future();          assert(f.valid()); -        assert(test_alloc_base::count == 1); +        assert(test_alloc_base::alloc_count == 1);      } -    assert(test_alloc_base::count == 0); +    assert(test_alloc_base::alloc_count == 0);  } diff --git a/test/std/thread/futures/futures.promise/uses_allocator.pass.cpp b/test/std/thread/futures/futures.promise/uses_allocator.pass.cpp index 458826e956e1..9a1d41cc0cb6 100644 --- a/test/std/thread/futures/futures.promise/uses_allocator.pass.cpp +++ b/test/std/thread/futures/futures.promise/uses_allocator.pass.cpp @@ -18,7 +18,7 @@  //      : true_type { };  #include <future> -#include "../test_allocator.h" +#include "test_allocator.h"  int main()  { 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 b23ba196ec30..3f9e945dddaf 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 @@ -8,6 +8,7 @@  //===----------------------------------------------------------------------===//  //  // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03  // <future> @@ -20,7 +21,6 @@  int main()  { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES      {          typedef int T;          std::promise<T> p; @@ -72,5 +72,4 @@ int main()          assert(!f0.valid());          assert(!f.valid());      } -#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES  } 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 425d1f9be96f..1da08808db2e 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 @@ -8,6 +8,7 @@  //===----------------------------------------------------------------------===//  //  // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03  // <future> diff --git a/test/std/thread/futures/futures.shared_future/ctor_future.pass.cpp b/test/std/thread/futures/futures.shared_future/ctor_future.pass.cpp index 3a78b80f0634..1590efd7b634 100644 --- a/test/std/thread/futures/futures.shared_future/ctor_future.pass.cpp +++ b/test/std/thread/futures/futures.shared_future/ctor_future.pass.cpp @@ -8,6 +8,7 @@  //===----------------------------------------------------------------------===//  //  // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03  // <future> diff --git a/test/std/thread/futures/futures.shared_future/dtor.pass.cpp b/test/std/thread/futures/futures.shared_future/dtor.pass.cpp index baa89cb12b1c..af061268410d 100644 --- a/test/std/thread/futures/futures.shared_future/dtor.pass.cpp +++ b/test/std/thread/futures/futures.shared_future/dtor.pass.cpp @@ -7,7 +7,9 @@  //  //===----------------------------------------------------------------------===//  // +// XFAIL: libcpp-no-exceptions  // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03  // <future> @@ -18,51 +20,51 @@  #include <future>  #include <cassert> -#include "../test_allocator.h" +#include "test_allocator.h"  int main()  { -    assert(test_alloc_base::count == 0); +    assert(test_alloc_base::alloc_count == 0);      {          typedef int T;          std::shared_future<T> f;          {              std::promise<T> p(std::allocator_arg, test_allocator<T>()); -            assert(test_alloc_base::count == 1); +            assert(test_alloc_base::alloc_count == 1);              f = p.get_future(); -            assert(test_alloc_base::count == 1); +            assert(test_alloc_base::alloc_count == 1);              assert(f.valid());          } -        assert(test_alloc_base::count == 1); +        assert(test_alloc_base::alloc_count == 1);          assert(f.valid());      } -    assert(test_alloc_base::count == 0); +    assert(test_alloc_base::alloc_count == 0);      {          typedef int& T;          std::shared_future<T> f;          {              std::promise<T> p(std::allocator_arg, test_allocator<int>()); -            assert(test_alloc_base::count == 1); +            assert(test_alloc_base::alloc_count == 1);              f = p.get_future(); -            assert(test_alloc_base::count == 1); +            assert(test_alloc_base::alloc_count == 1);              assert(f.valid());          } -        assert(test_alloc_base::count == 1); +        assert(test_alloc_base::alloc_count == 1);          assert(f.valid());      } -    assert(test_alloc_base::count == 0); +    assert(test_alloc_base::alloc_count == 0);      {          typedef void T;          std::shared_future<T> f;          {              std::promise<T> p(std::allocator_arg, test_allocator<T>()); -            assert(test_alloc_base::count == 1); +            assert(test_alloc_base::alloc_count == 1);              f = p.get_future(); -            assert(test_alloc_base::count == 1); +            assert(test_alloc_base::alloc_count == 1);              assert(f.valid());          } -        assert(test_alloc_base::count == 1); +        assert(test_alloc_base::alloc_count == 1);          assert(f.valid());      } -    assert(test_alloc_base::count == 0); +    assert(test_alloc_base::alloc_count == 0);  } 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 c5ee234b127f..6eea1d889b6d 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,9 @@  //  //===----------------------------------------------------------------------===//  // +// XFAIL: libcpp-no-exceptions  // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03  // <future> diff --git a/test/std/thread/futures/futures.shared_future/move_assign.pass.cpp b/test/std/thread/futures/futures.shared_future/move_assign.pass.cpp index 6b58f41c9085..3a1ef7a6849c 100644 --- a/test/std/thread/futures/futures.shared_future/move_assign.pass.cpp +++ b/test/std/thread/futures/futures.shared_future/move_assign.pass.cpp @@ -8,6 +8,7 @@  //===----------------------------------------------------------------------===//  //  // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03  // <future> @@ -20,7 +21,6 @@  int main()  { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES      {          typedef int T;          std::promise<T> p; @@ -72,5 +72,4 @@ int main()          assert(!f0.valid());          assert(!f.valid());      } -#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES  } diff --git a/test/std/thread/futures/futures.shared_future/move_ctor.pass.cpp b/test/std/thread/futures/futures.shared_future/move_ctor.pass.cpp index 32b8fd77c672..15323d678e3c 100644 --- a/test/std/thread/futures/futures.shared_future/move_ctor.pass.cpp +++ b/test/std/thread/futures/futures.shared_future/move_ctor.pass.cpp @@ -8,6 +8,7 @@  //===----------------------------------------------------------------------===//  //  // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03  // <future> diff --git a/test/std/thread/futures/futures.shared_future/wait.pass.cpp b/test/std/thread/futures/futures.shared_future/wait.pass.cpp index 4293fcab3564..6ff74f6c6b90 100644 --- a/test/std/thread/futures/futures.shared_future/wait.pass.cpp +++ b/test/std/thread/futures/futures.shared_future/wait.pass.cpp @@ -8,6 +8,7 @@  //===----------------------------------------------------------------------===//  //  // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03  // <future> diff --git a/test/std/thread/futures/futures.shared_future/wait_for.pass.cpp b/test/std/thread/futures/futures.shared_future/wait_for.pass.cpp index e5a4754e38ad..1ec086266b0d 100644 --- a/test/std/thread/futures/futures.shared_future/wait_for.pass.cpp +++ b/test/std/thread/futures/futures.shared_future/wait_for.pass.cpp @@ -8,6 +8,7 @@  //===----------------------------------------------------------------------===//  //  // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03  // <future> diff --git a/test/std/thread/futures/futures.shared_future/wait_until.pass.cpp b/test/std/thread/futures/futures.shared_future/wait_until.pass.cpp index 6a6aeba7759e..9cdc2e431f45 100644 --- a/test/std/thread/futures/futures.shared_future/wait_until.pass.cpp +++ b/test/std/thread/futures/futures.shared_future/wait_until.pass.cpp @@ -8,6 +8,7 @@   //===----------------------------------------------------------------------===//   //   // UNSUPPORTED: libcpp-has-no-threads + // UNSUPPORTED: c++98, c++03   // <future> diff --git a/test/std/thread/futures/futures.tas/futures.task.members/assign_copy.fail.cpp b/test/std/thread/futures/futures.tas/futures.task.members/assign_copy.fail.cpp index 70ea0ad31fed..6c6418594d00 100644 --- a/test/std/thread/futures/futures.tas/futures.task.members/assign_copy.fail.cpp +++ b/test/std/thread/futures/futures.tas/futures.task.members/assign_copy.fail.cpp @@ -7,6 +7,8 @@  //  //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 +  // <future>  // class packaged_task<R(ArgTypes...)> @@ -14,35 +16,11 @@  // packaged_task& operator=(packaged_task&) = delete;  #include <future> -#include <cassert> - -class A -{ -    long data_; - -public: -    explicit A(long i) : data_(i) {} - -    long operator()(long i, long j) const {return data_ + i + j;} -};  int main()  {      { -        std::packaged_task<double(int, char)> p0(A(5)); -        std::packaged_task<double(int, char)> p; -        p = p0; -        assert(!p0.valid()); -        assert(p.valid()); -        std::future<double> f = p.get_future(); -        p(3, 'a'); -        assert(f.get() == 105.0); -    } -    { -        std::packaged_task<double(int, char)> p0; -        std::packaged_task<double(int, char)> p; -        p = p0; -        assert(!p0.valid()); -        assert(!p.valid()); +        std::packaged_task<double(int, char)> p0, p; +        p = p0; // expected-error {{overload resolution selected deleted operator '='}}      }  } diff --git a/test/std/thread/futures/futures.tas/futures.task.members/assign_move.pass.cpp b/test/std/thread/futures/futures.tas/futures.task.members/assign_move.pass.cpp index 18786f4eb7a2..3f11d670bede 100644 --- a/test/std/thread/futures/futures.tas/futures.task.members/assign_move.pass.cpp +++ b/test/std/thread/futures/futures.tas/futures.task.members/assign_move.pass.cpp @@ -8,6 +8,7 @@  //===----------------------------------------------------------------------===//  //  // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03  // <future> diff --git a/test/std/thread/futures/futures.tas/futures.task.members/ctor1.fail.cpp b/test/std/thread/futures/futures.tas/futures.task.members/ctor1.fail.cpp index 45048b747f7a..7097d428962a 100644 --- a/test/std/thread/futures/futures.tas/futures.task.members/ctor1.fail.cpp +++ b/test/std/thread/futures/futures.tas/futures.task.members/ctor1.fail.cpp @@ -7,6 +7,8 @@  //  //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 +  // <future>  // class packaged_task<R(ArgTypes...)> @@ -25,5 +27,6 @@ typedef volatile std::packaged_task<A(int, char)> VPT;  int main()  { -    PT p { VPT{} }; +    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'}}  } diff --git a/test/std/thread/futures/futures.tas/futures.task.members/ctor2.fail.cpp b/test/std/thread/futures/futures.tas/futures.task.members/ctor2.fail.cpp index e4df4ec225e7..feb7657bed37 100644 --- a/test/std/thread/futures/futures.tas/futures.task.members/ctor2.fail.cpp +++ b/test/std/thread/futures/futures.tas/futures.task.members/ctor2.fail.cpp @@ -7,6 +7,8 @@  //  //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 +  // <future>  // class packaged_task<R(ArgTypes...)> @@ -18,7 +20,7 @@  #include <future>  #include <cassert> -#include "../../test_allocator.h" +#include "test_allocator.h"  struct A {};  typedef std::packaged_task<A(int, char)> PT; @@ -26,5 +28,6 @@ typedef volatile std::packaged_task<A(int, char)> VPT;  int main()  { -    PT p { std::allocator_arg_t{}, test_allocator<A>{}, VPT {}}; +    PT p { std::allocator_arg_t{}, test_allocator<A>{}, 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'}}  } diff --git a/test/std/thread/futures/futures.tas/futures.task.members/ctor_copy.fail.cpp b/test/std/thread/futures/futures.tas/futures.task.members/ctor_copy.fail.cpp index 9884c49a6dc7..97624f90f3df 100644 --- a/test/std/thread/futures/futures.tas/futures.task.members/ctor_copy.fail.cpp +++ b/test/std/thread/futures/futures.tas/futures.task.members/ctor_copy.fail.cpp @@ -7,6 +7,8 @@  //  //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 +  // <future>  // class packaged_task<R(ArgTypes...)> @@ -14,33 +16,12 @@  // packaged_task(packaged_task&) = delete;  #include <future> -#include <cassert> - -class A -{ -    long data_; -public: -    explicit A(long i) : data_(i) {} - -    long operator()(long i, long j) const {return data_ + i + j;} -};  int main()  {      { -        std::packaged_task<double(int, char)> p0(A(5)); -        std::packaged_task<double(int, char)> p(p0); -        assert(!p0.valid()); -        assert(p.valid()); -        std::future<double> f = p.get_future(); -        p(3, 'a'); -        assert(f.get() == 105.0); -    } -    {          std::packaged_task<double(int, char)> p0; -        std::packaged_task<double(int, char)> p(p0); -        assert(!p0.valid()); -        assert(!p.valid()); +        std::packaged_task<double(int, char)> p(p0); // expected-error {{call to deleted constructor of 'std::packaged_task<double (int, char)>'}}      }  } diff --git a/test/std/thread/futures/futures.tas/futures.task.members/ctor_default.pass.cpp b/test/std/thread/futures/futures.tas/futures.task.members/ctor_default.pass.cpp index 76904962a778..ed147d74895b 100644 --- a/test/std/thread/futures/futures.tas/futures.task.members/ctor_default.pass.cpp +++ b/test/std/thread/futures/futures.tas/futures.task.members/ctor_default.pass.cpp @@ -8,6 +8,7 @@  //===----------------------------------------------------------------------===//  //  // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03  // <future> diff --git a/test/std/thread/futures/futures.tas/futures.task.members/ctor_func.pass.cpp b/test/std/thread/futures/futures.tas/futures.task.members/ctor_func.pass.cpp index 2eee2cbc2d50..14ac7614bb8e 100644 --- a/test/std/thread/futures/futures.tas/futures.task.members/ctor_func.pass.cpp +++ b/test/std/thread/futures/futures.tas/futures.task.members/ctor_func.pass.cpp @@ -8,6 +8,7 @@  //===----------------------------------------------------------------------===//  //  // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03  // <future> diff --git a/test/std/thread/futures/futures.tas/futures.task.members/ctor_func_alloc.pass.cpp b/test/std/thread/futures/futures.tas/futures.task.members/ctor_func_alloc.pass.cpp index 3aac2b26bfc1..39784876b8c3 100644 --- a/test/std/thread/futures/futures.tas/futures.task.members/ctor_func_alloc.pass.cpp +++ b/test/std/thread/futures/futures.tas/futures.task.members/ctor_func_alloc.pass.cpp @@ -8,6 +8,7 @@  //===----------------------------------------------------------------------===//  //  // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03  // <future> @@ -19,7 +20,7 @@  #include <future>  #include <cassert> -#include "../../test_allocator.h" +#include "test_allocator.h"  #include "min_allocator.h"  class A @@ -47,7 +48,7 @@ int main()      {          std::packaged_task<double(int, char)> p(std::allocator_arg,                                                  test_allocator<A>(), A(5)); -        assert(test_alloc_base::count > 0); +        assert(test_alloc_base::alloc_count > 0);          assert(p.valid());          std::future<double> f = p.get_future();          p(3, 'a'); @@ -55,14 +56,14 @@ int main()          assert(A::n_copies == 0);          assert(A::n_moves > 0);      } -    assert(test_alloc_base::count == 0); +    assert(test_alloc_base::alloc_count == 0);      A::n_copies = 0;      A::n_moves  = 0;      {          A a(5);          std::packaged_task<double(int, char)> p(std::allocator_arg,                                                  test_allocator<A>(), a); -        assert(test_alloc_base::count > 0); +        assert(test_alloc_base::alloc_count > 0);          assert(p.valid());          std::future<double> f = p.get_future();          p(3, 'a'); @@ -70,31 +71,31 @@ int main()          assert(A::n_copies > 0);          assert(A::n_moves > 0);      } -    assert(test_alloc_base::count == 0); +    assert(test_alloc_base::alloc_count == 0);      A::n_copies = 0;      A::n_moves  = 0;      {          A a(5);          std::packaged_task<int(int)> p(std::allocator_arg, test_allocator<A>(), &func); -        assert(test_alloc_base::count > 0); +        assert(test_alloc_base::alloc_count > 0);          assert(p.valid());          std::future<int> f = p.get_future();          p(4);          assert(f.get() == 4);      } -    assert(test_alloc_base::count == 0); +    assert(test_alloc_base::alloc_count == 0);      A::n_copies = 0;      A::n_moves  = 0;      {          A a(5);          std::packaged_task<int(int)> p(std::allocator_arg, test_allocator<A>(), func); -        assert(test_alloc_base::count > 0); +        assert(test_alloc_base::alloc_count > 0);          assert(p.valid());          std::future<int> f = p.get_future();          p(4);          assert(f.get() == 4);      } -    assert(test_alloc_base::count == 0); +    assert(test_alloc_base::alloc_count == 0);      A::n_copies = 0;      A::n_moves  = 0;      { diff --git a/test/std/thread/futures/futures.tas/futures.task.members/ctor_move.pass.cpp b/test/std/thread/futures/futures.tas/futures.task.members/ctor_move.pass.cpp index 88f072281750..d9951dca585a 100644 --- a/test/std/thread/futures/futures.tas/futures.task.members/ctor_move.pass.cpp +++ b/test/std/thread/futures/futures.tas/futures.task.members/ctor_move.pass.cpp @@ -8,6 +8,7 @@  //===----------------------------------------------------------------------===//  //  // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03  // <future> diff --git a/test/std/thread/futures/futures.tas/futures.task.members/dtor.pass.cpp b/test/std/thread/futures/futures.tas/futures.task.members/dtor.pass.cpp index e24232d1b227..7fafd1005649 100644 --- a/test/std/thread/futures/futures.tas/futures.task.members/dtor.pass.cpp +++ b/test/std/thread/futures/futures.tas/futures.task.members/dtor.pass.cpp @@ -7,7 +7,9 @@  //  //===----------------------------------------------------------------------===//  // +// XFAIL: libcpp-no-exceptions  // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03  // <future> diff --git a/test/std/thread/futures/futures.tas/futures.task.members/get_future.pass.cpp b/test/std/thread/futures/futures.tas/futures.task.members/get_future.pass.cpp index 13b5db110668..c8e5d6efd6b4 100644 --- a/test/std/thread/futures/futures.tas/futures.task.members/get_future.pass.cpp +++ b/test/std/thread/futures/futures.tas/futures.task.members/get_future.pass.cpp @@ -7,7 +7,9 @@  //  //===----------------------------------------------------------------------===//  // +// XFAIL: libcpp-no-exceptions  // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03  // <future> diff --git a/test/std/thread/futures/futures.tas/futures.task.members/make_ready_at_thread_exit.pass.cpp b/test/std/thread/futures/futures.tas/futures.task.members/make_ready_at_thread_exit.pass.cpp index 61a6a4f87965..54ac64458248 100644 --- a/test/std/thread/futures/futures.tas/futures.task.members/make_ready_at_thread_exit.pass.cpp +++ b/test/std/thread/futures/futures.tas/futures.task.members/make_ready_at_thread_exit.pass.cpp @@ -7,7 +7,9 @@  //  //===----------------------------------------------------------------------===//  // +// XFAIL: libcpp-no-exceptions  // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03  // <future> diff --git a/test/std/thread/futures/futures.tas/futures.task.members/operator.pass.cpp b/test/std/thread/futures/futures.tas/futures.task.members/operator.pass.cpp index 2a09353b1e63..9ad1509517f6 100644 --- a/test/std/thread/futures/futures.tas/futures.task.members/operator.pass.cpp +++ b/test/std/thread/futures/futures.tas/futures.task.members/operator.pass.cpp @@ -7,7 +7,9 @@  //  //===----------------------------------------------------------------------===//  // +// XFAIL: libcpp-no-exceptions  // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03  // <future> diff --git a/test/std/thread/futures/futures.tas/futures.task.members/reset.pass.cpp b/test/std/thread/futures/futures.tas/futures.task.members/reset.pass.cpp index 9d38d9b409c0..02a567500ee2 100644 --- a/test/std/thread/futures/futures.tas/futures.task.members/reset.pass.cpp +++ b/test/std/thread/futures/futures.tas/futures.task.members/reset.pass.cpp @@ -7,7 +7,9 @@  //  //===----------------------------------------------------------------------===//  // +// XFAIL: libcpp-no-exceptions  // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03  // <future> diff --git a/test/std/thread/futures/futures.tas/futures.task.members/swap.pass.cpp b/test/std/thread/futures/futures.tas/futures.task.members/swap.pass.cpp index 33763bef0d0f..eb0091c8e817 100644 --- a/test/std/thread/futures/futures.tas/futures.task.members/swap.pass.cpp +++ b/test/std/thread/futures/futures.tas/futures.task.members/swap.pass.cpp @@ -8,6 +8,7 @@  //===----------------------------------------------------------------------===//  //  // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03  // <future> diff --git a/test/std/thread/futures/futures.tas/futures.task.nonmembers/swap.pass.cpp b/test/std/thread/futures/futures.tas/futures.task.nonmembers/swap.pass.cpp index 668732b9b24a..d90d593a75bd 100644 --- a/test/std/thread/futures/futures.tas/futures.task.nonmembers/swap.pass.cpp +++ b/test/std/thread/futures/futures.tas/futures.task.nonmembers/swap.pass.cpp @@ -8,6 +8,7 @@  //===----------------------------------------------------------------------===//  //  // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03  // <future> diff --git a/test/std/thread/futures/futures.tas/futures.task.nonmembers/uses_allocator.pass.cpp b/test/std/thread/futures/futures.tas/futures.task.nonmembers/uses_allocator.pass.cpp index 986f71e29a46..bbe75de7f8a9 100644 --- a/test/std/thread/futures/futures.tas/futures.task.nonmembers/uses_allocator.pass.cpp +++ b/test/std/thread/futures/futures.tas/futures.task.nonmembers/uses_allocator.pass.cpp @@ -9,6 +9,12 @@  //  // UNSUPPORTED: libcpp-has-no-threads +// This test is marked XFAIL and not UNSUPPORTED because the non-variadic +// declaration of packaged_task is available in C++03. Therefore the test +// should fail because the static_assert fires and not because std::packaged_task +// in undefined. +// XFAIL: c++98, c++03 +  // <future>  // class packaged_task<R(ArgTypes...)> @@ -18,7 +24,7 @@  //      : true_type { };  #include <future> -#include "../../test_allocator.h" +#include "test_allocator.h"  int main()  { diff --git a/test/std/thread/futures/futures.tas/types.pass.cpp b/test/std/thread/futures/futures.tas/types.pass.cpp index dd1724ddbda5..f7c9b223add1 100644 --- a/test/std/thread/futures/futures.tas/types.pass.cpp +++ b/test/std/thread/futures/futures.tas/types.pass.cpp @@ -8,6 +8,7 @@  //===----------------------------------------------------------------------===//  //  // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03  // <future> diff --git a/test/std/thread/futures/futures.unique_future/copy_assign.fail.cpp b/test/std/thread/futures/futures.unique_future/copy_assign.fail.cpp index ebdcbf98d996..781c9c9d6199 100644 --- a/test/std/thread/futures/futures.unique_future/copy_assign.fail.cpp +++ b/test/std/thread/futures/futures.unique_future/copy_assign.fail.cpp @@ -14,61 +14,36 @@  // future& operator=(const future&) = delete;  #include <future> -#include <cassert> + +#include "test_macros.h"  int main()  { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +#if TEST_STD_VER >= 11      { -        typedef int T; -        std::promise<T> p; -        std::future<T> f0 = p.get_future(); -        std::future<T> f; -        f = f0; -        assert(!f0.valid()); -        assert(f.valid()); +        std::future<int> f0, f; +        f = f0; // expected-error {{overload resolution selected deleted operator '='}}      }      { -        typedef int T; -        std::future<T> f0; -        std::future<T> f; -        f = f0; -        assert(!f0.valid()); -        assert(!f.valid()); +        std::future<int &> f0, f; +        f = f0; // expected-error {{overload resolution selected deleted operator '='}}      }      { -        typedef int& T; -        std::promise<T> p; -        std::future<T> f0 = p.get_future(); -        std::future<T> f; -        f = f0; -        assert(!f0.valid()); -        assert(f.valid()); +        std::future<void> f0, f; +        f = f0; // expected-error {{overload resolution selected deleted operator '='}}      } +#else      { -        typedef int& T; -        std::future<T> f0; -        std::future<T> f; -        f = f0; -        assert(!f0.valid()); -        assert(!f.valid()); +        std::future<int> f0, f; +        f = f0; // expected-error {{'operator=' is a private member of 'std::__1::future<int>'}}      }      { -        typedef void T; -        std::promise<T> p; -        std::future<T> f0 = p.get_future(); -        std::future<T> f; -        f = f0; -        assert(!f0.valid()); -        assert(f.valid()); +        std::future<int &> f0, f; +        f = f0; // expected-error {{'operator=' is a private member of 'std::__1::future<int &>'}}      }      { -        typedef void T; -        std::future<T> f0; -        std::future<T> f; -        f = f0; -        assert(!f0.valid()); -        assert(!f.valid()); +        std::future<void> f0, f; +        f = f0; // expected-error {{'operator=' is a private member of 'std::__1::future<void>'}}      } -#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES +#endif  } diff --git a/test/std/thread/futures/futures.unique_future/copy_ctor.fail.cpp b/test/std/thread/futures/futures.unique_future/copy_ctor.fail.cpp index 8d43294edc26..0d7b5f5074d3 100644 --- a/test/std/thread/futures/futures.unique_future/copy_ctor.fail.cpp +++ b/test/std/thread/futures/futures.unique_future/copy_ctor.fail.cpp @@ -14,53 +14,36 @@  // future(const future&) = delete;  #include <future> -#include <cassert> + +#include "test_macros.h"  int main()  { +#if TEST_STD_VER >= 11      { -        typedef int T; -        std::promise<T> p; -        std::future<T> f0 = p.get_future(); -        std::future<T> f = f0; -        assert(!f0.valid()); -        assert(f.valid()); +        std::future<int> f0; +        std::future<int> f = f0; // expected-error {{call to deleted constructor of 'std::future<int>'}}      }      { -        typedef int T; -        std::future<T> f0; -        std::future<T> f = f0; -        assert(!f0.valid()); -        assert(!f.valid()); +        std::future<int &> f0; +        std::future<int &> f = f0; // expected-error {{call to deleted constructor of 'std::future<int &>'}}      }      { -        typedef int& T; -        std::promise<T> p; -        std::future<T> f0 = p.get_future(); -        std::future<T> f = f0; -        assert(!f0.valid()); -        assert(f.valid()); +        std::future<void> f0; +        std::future<void> f = f0; // expected-error {{call to deleted constructor of 'std::future<void>'}}      } +#else      { -        typedef int& T; -        std::future<T> f0; -        std::future<T> f = std::move(f0); -        assert(!f0.valid()); -        assert(!f.valid()); +        std::future<int> f0; +        std::future<int> f = f0; // expected-error {{calling a private constructor of class 'std::__1::future<int>'}}      }      { -        typedef void T; -        std::promise<T> p; -        std::future<T> f0 = p.get_future(); -        std::future<T> f = f0; -        assert(!f0.valid()); -        assert(f.valid()); +        std::future<int &> f0; +        std::future<int &> f = f0; // expected-error {{calling a private constructor of class 'std::__1::future<int &>'}}      }      { -        typedef void T; -        std::future<T> f0; -        std::future<T> f = f0; -        assert(!f0.valid()); -        assert(!f.valid()); +        std::future<void> f0; +        std::future<void> f = f0; // expected-error {{calling a private constructor of class 'std::__1::future<void>'}}      } +#endif  } diff --git a/test/std/thread/futures/futures.unique_future/dtor.pass.cpp b/test/std/thread/futures/futures.unique_future/dtor.pass.cpp index 5e9697bb939b..03d7c915cb61 100644 --- a/test/std/thread/futures/futures.unique_future/dtor.pass.cpp +++ b/test/std/thread/futures/futures.unique_future/dtor.pass.cpp @@ -7,7 +7,9 @@  //  //===----------------------------------------------------------------------===//  // +// XFAIL: libcpp-no-exceptions  // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03  // <future> @@ -18,51 +20,51 @@  #include <future>  #include <cassert> -#include "../test_allocator.h" +#include "test_allocator.h"  int main()  { -    assert(test_alloc_base::count == 0); +    assert(test_alloc_base::alloc_count == 0);      {          typedef int T;          std::future<T> f;          {              std::promise<T> p(std::allocator_arg, test_allocator<T>()); -            assert(test_alloc_base::count == 1); +            assert(test_alloc_base::alloc_count == 1);              f = p.get_future(); -            assert(test_alloc_base::count == 1); +            assert(test_alloc_base::alloc_count == 1);              assert(f.valid());          } -        assert(test_alloc_base::count == 1); +        assert(test_alloc_base::alloc_count == 1);          assert(f.valid());      } -    assert(test_alloc_base::count == 0); +    assert(test_alloc_base::alloc_count == 0);      {          typedef int& T;          std::future<T> f;          {              std::promise<T> p(std::allocator_arg, test_allocator<int>()); -            assert(test_alloc_base::count == 1); +            assert(test_alloc_base::alloc_count == 1);              f = p.get_future(); -            assert(test_alloc_base::count == 1); +            assert(test_alloc_base::alloc_count == 1);              assert(f.valid());          } -        assert(test_alloc_base::count == 1); +        assert(test_alloc_base::alloc_count == 1);          assert(f.valid());      } -    assert(test_alloc_base::count == 0); +    assert(test_alloc_base::alloc_count == 0);      {          typedef void T;          std::future<T> f;          {              std::promise<T> p(std::allocator_arg, test_allocator<T>()); -            assert(test_alloc_base::count == 1); +            assert(test_alloc_base::alloc_count == 1);              f = p.get_future(); -            assert(test_alloc_base::count == 1); +            assert(test_alloc_base::alloc_count == 1);              assert(f.valid());          } -        assert(test_alloc_base::count == 1); +        assert(test_alloc_base::alloc_count == 1);          assert(f.valid());      } -    assert(test_alloc_base::count == 0); +    assert(test_alloc_base::alloc_count == 0);  } 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 758e38a7dae9..67b1052c175d 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,9 @@  //  //===----------------------------------------------------------------------===//  // +// XFAIL: libcpp-no-exceptions  // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03  // <future> diff --git a/test/std/thread/futures/futures.unique_future/share.pass.cpp b/test/std/thread/futures/futures.unique_future/share.pass.cpp index 794b5ce38feb..ef011d8df752 100644 --- a/test/std/thread/futures/futures.unique_future/share.pass.cpp +++ b/test/std/thread/futures/futures.unique_future/share.pass.cpp @@ -8,6 +8,7 @@  //===----------------------------------------------------------------------===//  //  // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03  // <future> diff --git a/test/std/thread/futures/futures.unique_future/wait.pass.cpp b/test/std/thread/futures/futures.unique_future/wait.pass.cpp index e10d37cf8064..f6de983f3057 100644 --- a/test/std/thread/futures/futures.unique_future/wait.pass.cpp +++ b/test/std/thread/futures/futures.unique_future/wait.pass.cpp @@ -8,6 +8,7 @@  //===----------------------------------------------------------------------===//  //  // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03  // <future> diff --git a/test/std/thread/futures/futures.unique_future/wait_for.pass.cpp b/test/std/thread/futures/futures.unique_future/wait_for.pass.cpp index 0a381d9ca2f0..c4f358268432 100644 --- a/test/std/thread/futures/futures.unique_future/wait_for.pass.cpp +++ b/test/std/thread/futures/futures.unique_future/wait_for.pass.cpp @@ -8,6 +8,7 @@  //===----------------------------------------------------------------------===//  //  // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03  // <future> diff --git a/test/std/thread/futures/futures.unique_future/wait_until.pass.cpp b/test/std/thread/futures/futures.unique_future/wait_until.pass.cpp index d5865b9b9dcf..541c00860752 100644 --- a/test/std/thread/futures/futures.unique_future/wait_until.pass.cpp +++ b/test/std/thread/futures/futures.unique_future/wait_until.pass.cpp @@ -1,129 +1,130 @@ - //===----------------------------------------------------------------------===// - // - //                     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 - - // <future> - - // class future<R> - - // template <class Clock, class Duration> - //   future_status - //   wait_until(const chrono::time_point<Clock, Duration>& abs_time) const; - - #include <future> - #include <atomic> - #include <cassert> - - enum class WorkerThreadState { Uninitialized, AllowedToRun, Exiting }; - typedef std::chrono::milliseconds ms; - - std::atomic<WorkerThreadState> thread_state(WorkerThreadState::Uninitialized); - - void set_worker_thread_state(WorkerThreadState state) - { -     thread_state.store(state, std::memory_order_relaxed); - } - - void wait_for_worker_thread_state(WorkerThreadState state) - { -     while (thread_state.load(std::memory_order_relaxed) != state); - } - - void func1(std::promise<int> p) - { -     wait_for_worker_thread_state(WorkerThreadState::AllowedToRun); -     p.set_value(3); -     set_worker_thread_state(WorkerThreadState::Exiting); - } - - int j = 0; - - void func3(std::promise<int&> p) - { -     wait_for_worker_thread_state(WorkerThreadState::AllowedToRun); -     j = 5; -     p.set_value(j); -     set_worker_thread_state(WorkerThreadState::Exiting); - } - - void func5(std::promise<void> p) - { -     wait_for_worker_thread_state(WorkerThreadState::AllowedToRun); -     p.set_value(); -     set_worker_thread_state(WorkerThreadState::Exiting); - } - - int main() - { -     typedef std::chrono::high_resolution_clock Clock; -     { -         typedef int T; -         std::promise<T> p; -         std::future<T> f = p.get_future(); -         std::thread(func1, std::move(p)).detach(); -         assert(f.valid()); -         assert(f.wait_until(Clock::now() + ms(10)) == std::future_status::timeout); -         assert(f.valid()); - -         // allow the worker thread to produce the result and wait until the worker is done -         set_worker_thread_state(WorkerThreadState::AllowedToRun); -         wait_for_worker_thread_state(WorkerThreadState::Exiting); - -         assert(f.wait_until(Clock::now() + ms(10)) == std::future_status::ready); -         assert(f.valid()); -         Clock::time_point t0 = Clock::now(); -         f.wait(); -         Clock::time_point t1 = Clock::now(); -         assert(f.valid()); -         assert(t1-t0 < ms(5)); -     } -     { -         typedef int& T; -         std::promise<T> p; -         std::future<T> f = p.get_future(); -         std::thread(func3, std::move(p)).detach(); -         assert(f.valid()); -         assert(f.wait_until(Clock::now() + ms(10)) == std::future_status::timeout); -         assert(f.valid()); - -         // allow the worker thread to produce the result and wait until the worker is done -         set_worker_thread_state(WorkerThreadState::AllowedToRun); -         wait_for_worker_thread_state(WorkerThreadState::Exiting); - -         assert(f.wait_until(Clock::now() + ms(10)) == std::future_status::ready); -         assert(f.valid()); -         Clock::time_point t0 = Clock::now(); -         f.wait(); -         Clock::time_point t1 = Clock::now(); -         assert(f.valid()); -         assert(t1-t0 < ms(5)); -     } -     { -         typedef void T; -         std::promise<T> p; -         std::future<T> f = p.get_future(); -         std::thread(func5, std::move(p)).detach(); -         assert(f.valid()); -         assert(f.wait_until(Clock::now() + ms(10)) == std::future_status::timeout); -         assert(f.valid()); - -         // allow the worker thread to produce the result and wait until the worker is done -         set_worker_thread_state(WorkerThreadState::AllowedToRun); -         wait_for_worker_thread_state(WorkerThreadState::Exiting); - -         assert(f.wait_until(Clock::now() + ms(10)) == std::future_status::ready); -         assert(f.valid()); -         Clock::time_point t0 = Clock::now(); -         f.wait(); -         Clock::time_point t1 = Clock::now(); -         assert(f.valid()); -         assert(t1-t0 < ms(5)); -     } - } +//===----------------------------------------------------------------------===// +// +//                     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 +// UNSUPPORTED: c++98, c++03 + +// <future> + +// class future<R> + +// template <class Clock, class Duration> +//   future_status +//   wait_until(const chrono::time_point<Clock, Duration>& abs_time) const; + +#include <future> +#include <atomic> +#include <cassert> + +enum class WorkerThreadState { Uninitialized, AllowedToRun, Exiting }; +typedef std::chrono::milliseconds ms; + +std::atomic<WorkerThreadState> thread_state(WorkerThreadState::Uninitialized); + +void set_worker_thread_state(WorkerThreadState state) +{ +    thread_state.store(state, std::memory_order_relaxed); +} + +void wait_for_worker_thread_state(WorkerThreadState state) +{ +    while (thread_state.load(std::memory_order_relaxed) != state); +} + +void func1(std::promise<int> p) +{ +    wait_for_worker_thread_state(WorkerThreadState::AllowedToRun); +    p.set_value(3); +    set_worker_thread_state(WorkerThreadState::Exiting); +} + +int j = 0; + +void func3(std::promise<int&> p) +{ +    wait_for_worker_thread_state(WorkerThreadState::AllowedToRun); +    j = 5; +    p.set_value(j); +    set_worker_thread_state(WorkerThreadState::Exiting); +} + +void func5(std::promise<void> p) +{ +    wait_for_worker_thread_state(WorkerThreadState::AllowedToRun); +    p.set_value(); +    set_worker_thread_state(WorkerThreadState::Exiting); +} + +int main() +{ +    typedef std::chrono::high_resolution_clock Clock; +    { +        typedef int T; +        std::promise<T> p; +        std::future<T> f = p.get_future(); +        std::thread(func1, std::move(p)).detach(); +        assert(f.valid()); +        assert(f.wait_until(Clock::now() + ms(10)) == std::future_status::timeout); +        assert(f.valid()); + +        // allow the worker thread to produce the result and wait until the worker is done +        set_worker_thread_state(WorkerThreadState::AllowedToRun); +        wait_for_worker_thread_state(WorkerThreadState::Exiting); + +        assert(f.wait_until(Clock::now() + ms(10)) == std::future_status::ready); +        assert(f.valid()); +        Clock::time_point t0 = Clock::now(); +        f.wait(); +        Clock::time_point t1 = Clock::now(); +        assert(f.valid()); +        assert(t1-t0 < ms(5)); +    } +    { +        typedef int& T; +        std::promise<T> p; +        std::future<T> f = p.get_future(); +        std::thread(func3, std::move(p)).detach(); +        assert(f.valid()); +        assert(f.wait_until(Clock::now() + ms(10)) == std::future_status::timeout); +        assert(f.valid()); + +        // allow the worker thread to produce the result and wait until the worker is done +        set_worker_thread_state(WorkerThreadState::AllowedToRun); +        wait_for_worker_thread_state(WorkerThreadState::Exiting); + +        assert(f.wait_until(Clock::now() + ms(10)) == std::future_status::ready); +        assert(f.valid()); +        Clock::time_point t0 = Clock::now(); +        f.wait(); +        Clock::time_point t1 = Clock::now(); +        assert(f.valid()); +        assert(t1-t0 < ms(5)); +    } +    { +        typedef void T; +        std::promise<T> p; +        std::future<T> f = p.get_future(); +        std::thread(func5, std::move(p)).detach(); +        assert(f.valid()); +        assert(f.wait_until(Clock::now() + ms(10)) == std::future_status::timeout); +        assert(f.valid()); + +        // allow the worker thread to produce the result and wait until the worker is done +        set_worker_thread_state(WorkerThreadState::AllowedToRun); +        wait_for_worker_thread_state(WorkerThreadState::Exiting); + +        assert(f.wait_until(Clock::now() + ms(10)) == std::future_status::ready); +        assert(f.valid()); +        Clock::time_point t0 = Clock::now(); +        f.wait(); +        Clock::time_point t1 = Clock::now(); +        assert(f.valid()); +        assert(t1-t0 < ms(5)); +    } +} diff --git a/test/std/thread/futures/test_allocator.h b/test/std/thread/futures/test_allocator.h deleted file mode 100644 index 50072909fa4e..000000000000 --- a/test/std/thread/futures/test_allocator.h +++ /dev/null @@ -1,158 +0,0 @@ -//===----------------------------------------------------------------------===// -// -//                     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. -// -//===----------------------------------------------------------------------===// - -#ifndef TEST_ALLOCATOR_H -#define TEST_ALLOCATOR_H - -#include <cstddef> -#include <type_traits> -#include <utility> -#include <cstdlib> -#include <new> -#include <climits> - -class test_alloc_base -{ -public: -    static int count; -public: -    static int throw_after; -}; - -int test_alloc_base::count = 0; -int test_alloc_base::throw_after = INT_MAX; - -template <class T> -class test_allocator -    : public test_alloc_base -{ -    int data_; - -    template <class U> friend class test_allocator; -public: - -    typedef unsigned                                                   size_type; -    typedef int                                                        difference_type; -    typedef T                                                          value_type; -    typedef value_type*                                                pointer; -    typedef const value_type*                                          const_pointer; -    typedef typename std::add_lvalue_reference<value_type>::type       reference; -    typedef typename std::add_lvalue_reference<const value_type>::type const_reference; - -    template <class U> struct rebind {typedef test_allocator<U> other;}; - -    test_allocator() throw() : data_(-1) {} -    explicit test_allocator(int i) throw() : data_(i) {} -    test_allocator(const test_allocator& a) throw() -        : data_(a.data_) {} -    template <class U> test_allocator(const test_allocator<U>& a) throw() -        : data_(a.data_) {} -    ~test_allocator() throw() {data_ = 0;} -    pointer address(reference x) const {return &x;} -    const_pointer address(const_reference x) const {return &x;} -    pointer allocate(size_type n, const void* = 0) -        { -            if (count >= throw_after) { -#ifndef _LIBCPP_NO_EXCEPTIONS -                throw std::bad_alloc(); -#else -                std::terminate(); -#endif -            } -            ++count; -            return (pointer)std::malloc(n * sizeof(T)); -        } -    void deallocate(pointer p, size_type n) -        {--count; std::free(p);} -    size_type max_size() const throw() -        {return UINT_MAX / sizeof(T);} -    void construct(pointer p, const T& val) -        {::new(p) T(val);} -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES -    void construct(pointer p, T&& val) -        {::new(p) T(std::move(val));} -#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES -    void destroy(pointer p) {p->~T();} - -    friend bool operator==(const test_allocator& x, const test_allocator& y) -        {return x.data_ == y.data_;} -    friend bool operator!=(const test_allocator& x, const test_allocator& y) -        {return !(x == y);} -}; - -template <> -class test_allocator<void> -    : public test_alloc_base -{ -    int data_; - -    template <class U> friend class test_allocator; -public: - -    typedef unsigned                                                   size_type; -    typedef int                                                        difference_type; -    typedef void                                                       value_type; -    typedef value_type*                                                pointer; -    typedef const value_type*                                          const_pointer; - -    template <class U> struct rebind {typedef test_allocator<U> other;}; - -    test_allocator() throw() : data_(-1) {} -    explicit test_allocator(int i) throw() : data_(i) {} -    test_allocator(const test_allocator& a) throw() -        : data_(a.data_) {} -    template <class U> test_allocator(const test_allocator<U>& a) throw() -        : data_(a.data_) {} -    ~test_allocator() throw() {data_ = 0;} - -    friend bool operator==(const test_allocator& x, const test_allocator& y) -        {return x.data_ == y.data_;} -    friend bool operator!=(const test_allocator& x, const test_allocator& y) -        {return !(x == y);} -}; - -template <class T> -class other_allocator -{ -    int data_; - -    template <class U> friend class other_allocator; - -public: -    typedef T value_type; - -    other_allocator() : data_(-1) {} -    explicit other_allocator(int i) : data_(i) {} -    template <class U> other_allocator(const other_allocator<U>& a) -        : data_(a.data_) {} -    T* allocate(std::size_t n) -        {return (T*)std::malloc(n * sizeof(T));} -    void deallocate(T* p, std::size_t n) -        {std::free(p);} - -    other_allocator select_on_container_copy_construction() const -        {return other_allocator(-2);} - -    friend bool operator==(const other_allocator& x, const other_allocator& y) -        {return x.data_ == y.data_;} -    friend bool operator!=(const other_allocator& x, const other_allocator& y) -        {return !(x == y);} - -    typedef std::true_type propagate_on_container_copy_assignment; -    typedef std::true_type propagate_on_container_move_assignment; -    typedef std::true_type propagate_on_container_swap; - -#ifdef _LIBCPP_HAS_NO_ADVANCED_SFINAE -    std::size_t max_size() const -        {return UINT_MAX / sizeof(T);} -#endif  // _LIBCPP_HAS_NO_ADVANCED_SFINAE - -}; - -#endif  // TEST_ALLOCATOR_H diff --git a/test/std/thread/futures/version.pass.cpp b/test/std/thread/futures/version.pass.cpp deleted file mode 100644 index 6730a1477db7..000000000000 --- a/test/std/thread/futures/version.pass.cpp +++ /dev/null @@ -1,22 +0,0 @@ -//===----------------------------------------------------------------------===// -// -//                     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 - -// <future> - -#include <future> - -#ifndef _LIBCPP_VERSION -#error _LIBCPP_VERSION not defined -#endif - -int main() -{ -} diff --git a/test/std/thread/thread.condition/notify_all_at_thread_exit.pass.cpp b/test/std/thread/thread.condition/notify_all_at_thread_exit.pass.cpp index 2b8772f92ed2..02da345cb7d1 100644 --- a/test/std/thread/thread.condition/notify_all_at_thread_exit.pass.cpp +++ b/test/std/thread/thread.condition/notify_all_at_thread_exit.pass.cpp @@ -9,6 +9,10 @@  //  // 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 @@ -36,9 +40,10 @@ void func()  int main()  {      std::unique_lock<std::mutex> lk(mut); -    std::thread(func).detach(); +    std::thread t(func);      Clock::time_point t0 = Clock::now();      cv.wait(lk);      Clock::time_point t1 = Clock::now();      assert(t1-t0 > ms(250)); +    t.join();  } diff --git a/test/std/thread/thread.condition/thread.condition.condvar/notify_one.pass.cpp b/test/std/thread/thread.condition/thread.condition.condvar/notify_one.pass.cpp index 6236a13df80e..e99ebee9c8e0 100644 --- a/test/std/thread/thread.condition/thread.condition.condvar/notify_one.pass.cpp +++ b/test/std/thread/thread.condition/thread.condition.condvar/notify_one.pass.cpp @@ -16,16 +16,17 @@  // void notify_one();  #include <condition_variable> +#include <atomic>  #include <mutex>  #include <thread>  #include <cassert> +  std::condition_variable cv;  std::mutex mut; -int test0 = 0; -int test1 = 0; -int test2 = 0; +std::atomic_int test1(0); +std::atomic_int test2(0);  void f1()  { @@ -64,11 +65,13 @@ int main()      }      if (test1 == 2)      { +        assert(test2 == 1);          t1.join();          test1 = 0;      }      else if (test2 == 2)      { +        assert(test1 == 1);          t2.join();          test2 = 0;      } @@ -81,11 +84,13 @@ int main()      }      if (test1 == 2)      { +        assert(test2 == 0);          t1.join();          test1 = 0;      }      else if (test2 == 2)      { +        assert(test1 == 0);          t2.join();          test2 = 0;      } diff --git a/test/std/thread/thread.condition/thread.condition.condvarany/wait.exception.pass.cpp b/test/std/thread/thread.condition/thread.condition.condvarany/wait.exception.pass.cpp deleted file mode 100644 index 522c61b02d17..000000000000 --- a/test/std/thread/thread.condition/thread.condition.condvarany/wait.exception.pass.cpp +++ /dev/null @@ -1,63 +0,0 @@ -//===----------------------------------------------------------------------===// -// -//                     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 - -#include <thread> -#include <condition_variable> -#include <mutex> -#include <chrono> -#include <iostream> -#include <cassert> - -void f1() -{ -    std::exit(0); -} - -struct Mutex -{ -    unsigned state = 0; -    Mutex() = default; -    ~Mutex() = default; -    Mutex(const Mutex&) = delete; -    Mutex& operator=(const Mutex&) = delete; - -    void lock() -    { -    if (++state == 2) -        throw 1;  // this throw should end up calling terminate() -    } - -    void unlock() {} -}; - -Mutex mut; -std::condition_variable_any cv; - -void -signal_me() -{ -    std::this_thread::sleep_for(std::chrono::milliseconds(500)); -    cv.notify_one(); -} - -int -main() -{ -    std::set_terminate(f1); -    try -    { -        std::thread(signal_me).detach(); -        mut.lock(); -        cv.wait(mut); -    } -    catch (...) {} -    assert(false); -} diff --git a/test/std/thread/thread.condition/thread.condition.condvarany/wait_for.exception.pass.cpp b/test/std/thread/thread.condition/thread.condition.condvarany/wait_for.exception.pass.cpp deleted file mode 100644 index 1906b5892506..000000000000 --- a/test/std/thread/thread.condition/thread.condition.condvarany/wait_for.exception.pass.cpp +++ /dev/null @@ -1,63 +0,0 @@ -//===----------------------------------------------------------------------===// -// -//                     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 - -#include <thread> -#include <condition_variable> -#include <mutex> -#include <chrono> -#include <iostream> -#include <cassert> - -void f1() -{ -    std::exit(0); -} - -struct Mutex -{ -    unsigned state = 0; -    Mutex() = default; -    ~Mutex() = default; -    Mutex(const Mutex&) = delete; -    Mutex& operator=(const Mutex&) = delete; - -    void lock() -    { -    if (++state == 2) -        throw 1;  // this throw should end up calling terminate() -    } - -    void unlock() {} -}; - -Mutex mut; -std::condition_variable_any cv; - -void -signal_me() -{ -    std::this_thread::sleep_for(std::chrono::milliseconds(500)); -    cv.notify_one(); -} - -int -main() -{ -    std::set_terminate(f1); -    try -    { -        std::thread(signal_me).detach(); -        mut.lock(); -        cv.wait_for(mut, std::chrono::milliseconds(250)); -    } -    catch (...) {} -    assert(false); -} 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 new file mode 100644 index 000000000000..f9a35cc905c7 --- /dev/null +++ b/test/std/thread/thread.condition/thread.condition.condvarany/wait_terminates.sh.cpp @@ -0,0 +1,134 @@ +//===----------------------------------------------------------------------===// +// +//                     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. +// +//===----------------------------------------------------------------------===// + +// XFAIL: libcpp-no-exceptions +// UNSUPPORTED: libcpp-has-no-threads + +// <condition_variable> + +// class condition_variable_any; + +// RUN: %build +// RUN: %run 1 +// RUN: %run 2 +// RUN: %run 3 +// RUN: %run 4 +// RUN: %run 5 +// RUN: %run 6 + +// ----------------------------------------------------------------------------- +// Overview +//   Check that std::terminate is called if wait(...) fails to meet it's post +//   conditions. This can happens when reacquiring the mutex throws +//   an exception. +// +//  The following methods are tested within this file +//   1.  void wait(Lock& lock); +//   2.  void wait(Lock& lock, Pred); +//   3.  void wait_for(Lock& lock, Duration); +//   4.  void wait_for(Lock& lock, Duration, Pred); +//   5.  void wait_until(Lock& lock, TimePoint); +//   6.  void wait_until(Lock& lock, TimePoint, Pred); +// +// Plan +//   1 Create a mutex type, 'ThrowingMutex', that throws when the lock is aquired +//     for the *second* time. +// +//   2 Replace the terminate handler with one that exits with a '0' exit code. +// +//   3 Create a 'condition_variable_any' object 'cv' and a 'ThrowingMutex' +//     object 'm' and lock 'm'. +// +//   4 Start a thread 'T2' that will notify 'cv' once 'm' has been unlocked. +// +//   5 From the main thread call the specified wait method on 'cv' with 'm'. +//     When 'T2' notifies 'cv' and the wait method attempts to re-lock +//    'm' an exception will be thrown from 'm.lock()'. +// +//   6 Check that control flow does not return from the wait method and that +//     terminate is called (If the program exits with a 0 exit code we know +//     that terminate has been called) + + +#include <condition_variable> +#include <atomic> +#include <thread> +#include <chrono> +#include <string> +#include <cstdlib> +#include <cassert> + +void my_terminate() { +  std::_Exit(0); // Use _Exit to prevent cleanup from taking place. +} + +// The predicate used in the cv.wait calls. +bool pred = false; +bool pred_function() { +  return pred == true; +} + +class ThrowingMutex +{ +  std::atomic_bool locked; +  unsigned state = 0; +  ThrowingMutex(const ThrowingMutex&) = delete; +  ThrowingMutex& operator=(const ThrowingMutex&) = delete; +public: +  ThrowingMutex() { +    locked = false; +  } +  ~ThrowingMutex() = default; + +  void lock() { +    locked = true; +    if (++state == 2) { +      assert(pred); // Check that we actually waited until we were signaled. +      throw 1;  // this throw should end up calling terminate() +    } +  } + +  void unlock() { locked = false; } +  bool isLocked() const { return locked == true; } +}; + +ThrowingMutex mut; +std::condition_variable_any cv; + +void signal_me() { +  while (mut.isLocked()) {} // wait until T1 releases mut inside the cv.wait call. +  pred = true; +  cv.notify_one(); +} + +typedef std::chrono::system_clock Clock; +typedef std::chrono::milliseconds MS; + +int main(int argc, char** argv) { +  assert(argc == 2); +  int id = std::stoi(argv[1]); +  assert(id >= 1 && id <= 6); +  std::set_terminate(my_terminate); // set terminate after std::stoi because it can throw. +  MS wait(250); +  try { +    mut.lock(); +    assert(pred == false); +    std::thread(signal_me).detach(); +    switch (id) { +      case 1: cv.wait(mut); break; +      case 2: cv.wait(mut, pred_function); break; +      case 3: cv.wait_for(mut, wait); break; +      case 4: cv.wait_for(mut, wait, pred_function); break; +      case 5: cv.wait_until(mut, Clock::now() + wait); break; +      case 6: cv.wait_until(mut, Clock::now() + wait, pred_function); break; +      default: assert(false); +    } +  } catch (...) {} +  assert(false); +} 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 f67ca2169825..eac7600b5d11 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,6 +7,7 @@  //  //===----------------------------------------------------------------------===//  // +// XFAIL: libcpp-no-exceptions  // UNSUPPORTED: libcpp-has-no-threads  // <mutex> 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 f0c54b71883f..8889408be2d7 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,6 +7,7 @@  //  //===----------------------------------------------------------------------===//  // +// XFAIL: libcpp-no-exceptions  // UNSUPPORTED: libcpp-has-no-threads  // <mutex> 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 2c1c665fdeda..f7cf49c81f3f 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  // <shared_mutex> @@ -20,9 +21,7 @@  int main()  { -#if _LIBCPP_STD_VER > 11      std::shared_lock<std::shared_timed_mutex> 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 8676f2ca0472..15c193c60b5d 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  // <shared_mutex> @@ -18,16 +19,11 @@  #include <shared_mutex>  #include <cassert> -#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<std::shared_timed_mutex> lk0(m0);      std::shared_lock<std::shared_timed_mutex> 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 f59d2e826980..4f4f6a5e9fbd 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  // <shared_mutex> @@ -18,18 +19,13 @@  #include <shared_mutex>  #include <cassert> -#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<std::shared_timed_mutex> lk0(m);      std::shared_lock<std::shared_timed_mutex> 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 c8a0287314bf..12bef34cf87b 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  // <shared_mutex> @@ -21,9 +22,7 @@  #include <cstdlib>  #include <cassert> -#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 !defined(TEST_HAS_SANITIZERS) +ms Tolerance = ms(50); +#else +ms Tolerance = ms(50 * 5); +#endif + +std::shared_timed_mutex m; +  void f()  {      time_point t0 = Clock::now(); @@ -39,8 +51,8 @@ void f()      std::shared_lock<std::shared_timed_mutex> 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<std::thread> 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 3b49b3029052..995210221065 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  // <shared_mutex> @@ -20,11 +21,9 @@  int main()  { -#if _LIBCPP_STD_VER > 11      std::shared_timed_mutex m;      m.lock_shared();      std::shared_lock<std::shared_timed_mutex> 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 bbc38fcadb10..d81796b95bf3 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  // <shared_mutex> @@ -20,10 +21,8 @@  int main()  { -#if _LIBCPP_STD_VER > 11      std::shared_timed_mutex m;      std::shared_lock<std::shared_timed_mutex> 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 9816e57f692a..84f868d6810b 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  // <shared_mutex> @@ -22,7 +23,7 @@  #include <cstdlib>  #include <cassert> -#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 !defined(TEST_HAS_SANITIZERS) +ms Tolerance = ms(50); +#else +ms Tolerance = ms(50 * 5); +#endif + +  void f1()  {      time_point t0 = Clock::now(); -    std::shared_lock<std::shared_timed_mutex> lk(m, ms(300)); +    std::shared_lock<std::shared_timed_mutex> 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<std::shared_timed_mutex> lk(m, ms(250)); +    std::shared_lock<std::shared_timed_mutex> 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<std::thread> 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<std::thread> 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 5d188ab06737..9359731486dd 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  // <shared_mutex> @@ -22,7 +23,7 @@  #include <cstdlib>  #include <cassert> -#if _LIBCPP_STD_VER > 11 +#include "test_macros.h"  std::shared_timed_mutex m; @@ -32,37 +33,45 @@ 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 !defined(TEST_HAS_SANITIZERS) +ms Tolerance = ms(50); +#else +ms Tolerance = ms(50 * 5); +#endif +  void f1()  {      time_point t0 = Clock::now(); -    std::shared_lock<std::shared_timed_mutex> lk(m, Clock::now() + ms(300)); +    std::shared_lock<std::shared_timed_mutex> 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<std::shared_timed_mutex> lk(m, Clock::now() + ms(250)); +    std::shared_lock<std::shared_timed_mutex> 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<std::thread> 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 +81,9 @@ int main()          std::vector<std::thread> 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 f2d4e0deb73f..7f89f0af801f 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  // <shared_mutex> @@ -21,8 +22,6 @@  #include <cstdlib>  #include <cassert> -#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<std::thread> 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 f1500652badd..5c3513c98e03 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,9 @@  //  //===----------------------------------------------------------------------===//  // +// XFAIL: libcpp-no-exceptions  // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03, c++11  // <shared_mutex> @@ -21,7 +23,7 @@  #include <cstdlib>  #include <cassert> -#if _LIBCPP_STD_VER > 11 +#include "test_macros.h"  std::shared_timed_mutex m; @@ -31,6 +33,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 !defined(TEST_HAS_SANITIZERS) +ms Tolerance = ms(25); +#else +ms Tolerance = ms(25 * 5); +#endif + +  void f()  {      std::shared_lock<std::shared_timed_mutex> lk(m, std::defer_lock); @@ -38,8 +52,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 +76,14 @@ void f()      }  } -#endif  // _LIBCPP_STD_VER > 11 -  int main()  { -#if _LIBCPP_STD_VER > 11      m.lock();      std::vector<std::thread> 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 82b1ff865053..01693c77ea39 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,9 @@  //  //===----------------------------------------------------------------------===//  // +// XFAIL: libcpp-no-exceptions  // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03, c++11  // <shared_mutex> @@ -18,8 +20,6 @@  #include <shared_mutex>  #include <cassert> -#if _LIBCPP_STD_VER > 11 -  bool try_lock_called = false;  struct mutex @@ -34,11 +34,9 @@ struct mutex  mutex m; -#endif  // _LIBCPP_STD_VER > 11 -  int main()  { -#if _LIBCPP_STD_VER > 11 +      std::shared_lock<mutex> lk(m, std::defer_lock);      assert(lk.try_lock() == true);      assert(try_lock_called == true); @@ -66,5 +64,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 5867465a6626..852a94eb65ec 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,9 @@  //  //===----------------------------------------------------------------------===//  // +// XFAIL: libcpp-no-exceptions  // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03, c++11  // <shared_mutex> @@ -19,8 +21,6 @@  #include <shared_mutex>  #include <cassert> -#if _LIBCPP_STD_VER > 11 -  bool try_lock_for_called = false;  typedef std::chrono::milliseconds ms; @@ -39,11 +39,8 @@ struct mutex  mutex m; -#endif  // _LIBCPP_STD_VER > 11 -  int main()  { -#if _LIBCPP_STD_VER > 11      std::shared_lock<mutex> lk(m, std::defer_lock);      assert(lk.try_lock_for(ms(5)) == true);      assert(try_lock_for_called == true); @@ -71,5 +68,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 9d38983be724..31574afd7d8f 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,9 @@  //  //===----------------------------------------------------------------------===//  // +// XFAIL: libcpp-no-exceptions  // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03, c++11  // <shared_mutex> @@ -19,8 +21,6 @@  #include <shared_mutex>  #include <cassert> -#if _LIBCPP_STD_VER > 11 -  bool try_lock_until_called = false;  struct mutex @@ -38,11 +38,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<mutex> lk(m, std::defer_lock);      assert(lk.try_lock_until(Clock::now()) == true); @@ -71,5 +68,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 eb08a45cde6e..6a7385ed42a6 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,9 @@  //  //===----------------------------------------------------------------------===//  // +// XFAIL: libcpp-no-exceptions  // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03, c++11  // <shared_mutex> @@ -18,8 +20,6 @@  #include <shared_mutex>  #include <cassert> -#if _LIBCPP_STD_VER > 11 -  bool unlock_called = false;  struct mutex @@ -30,11 +30,8 @@ struct mutex  mutex m; -#endif  // _LIBCPP_STD_VER > 11 -  int main()  { -#if _LIBCPP_STD_VER > 11      std::shared_lock<mutex> lk(m);      lk.unlock();      assert(unlock_called == true); @@ -58,5 +55,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 8505763e44bc..23a0c7030d76 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  // <shared_mutex> @@ -18,8 +19,6 @@  #include <shared_mutex>  #include <cassert> -#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<mutex> lk1(m);      std::shared_lock<mutex> 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 057dbc4cd3b7..0f19174d51f0 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  // <shared_mutex> @@ -19,8 +20,6 @@  #include <shared_mutex>  #include <cassert> -#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<mutex> lk1(m);      std::shared_lock<mutex> 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 65ddca624725..2b5f8c1f1658 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  // <shared_mutex> @@ -18,8 +19,6 @@  #include <shared_mutex>  #include <cassert> -#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<mutex> 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 4eb75d8f050e..711ab7c6fca0 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  // <shared_mutex> @@ -18,15 +19,10 @@  #include <shared_mutex>  #include <cassert> -#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<std::shared_timed_mutex> lk0;      assert(lk0.mutex() == nullptr);      std::shared_lock<std::shared_timed_mutex> 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 d079d2d8b03a..3f6ad2b555a3 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  // <shared_mutex> @@ -18,15 +19,10 @@  #include <shared_mutex>  #include <cassert> -#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<std::shared_timed_mutex> lk0;      assert(static_cast<bool>(lk0) == false);      std::shared_lock<std::shared_timed_mutex> lk1(m); @@ -34,5 +30,4 @@ int main()      lk1.unlock();      assert(static_cast<bool>(lk1) == false);      static_assert(noexcept(static_cast<bool>(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 d64b0aa6a736..5ab3ac009fe1 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  // <shared_mutex> @@ -18,15 +19,10 @@  #include <shared_mutex>  #include <cassert> -#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<std::shared_timed_mutex> lk0;      assert(lk0.owns_lock() == false);      std::shared_lock<std::shared_timed_mutex> 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 c153b455f404..f555d3de5ee0 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 +  // <shared_mutex> @@ -24,8 +26,6 @@  int main()  { -#if _LIBCPP_STD_VER > 11      static_assert((std::is_same<std::shared_lock<std::mutex>::mutex_type,                     std::mutex>::value), ""); -#endif  // _LIBCPP_STD_VER > 11  } 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 f5408df98199..6ce33761068f 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,6 +7,7 @@  //  //===----------------------------------------------------------------------===//  // +// XFAIL: libcpp-no-exceptions  // UNSUPPORTED: libcpp-has-no-threads  // <mutex> 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 bd88577f0a22..27d0562de31f 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,6 +7,7 @@  //  //===----------------------------------------------------------------------===//  // +// XFAIL: libcpp-no-exceptions  // UNSUPPORTED: libcpp-has-no-threads  // <mutex> 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 558f079463a4..6f0a7219d2d8 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,6 +7,7 @@  //  //===----------------------------------------------------------------------===//  // +// XFAIL: libcpp-no-exceptions  // UNSUPPORTED: libcpp-has-no-threads  // <mutex> 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 24e4d109a097..b7e87249b596 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,6 +7,7 @@  //  //===----------------------------------------------------------------------===//  // +// XFAIL: libcpp-no-exceptions  // UNSUPPORTED: libcpp-has-no-threads  // <mutex> 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 bbabfc41df11..62497c9ec45a 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,6 +7,7 @@  //  //===----------------------------------------------------------------------===//  // +// XFAIL: libcpp-no-exceptions  // UNSUPPORTED: libcpp-has-no-threads  // <mutex> diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/assign.fail.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/assign.fail.cpp index 7bcb2d61379a..5c67a34ab52b 100644 --- a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/assign.fail.cpp +++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/assign.fail.cpp @@ -6,6 +6,8 @@  // Source Licenses. See LICENSE.TXT for details.  //  //===----------------------------------------------------------------------===// +// +// UNSUPPORTED: c++98, c++03, c++11, c++14  // <shared_mutex> @@ -15,15 +17,9 @@  #include <shared_mutex> -#include "test_macros.h" -  int main()  { -#if TEST_STD_VER > 14      std::shared_mutex m0;      std::shared_mutex m1; -    m1 = m0; -#else -#   error -#endif +    m1 = m0; // expected-error {{overload resolution selected deleted operator '='}}  } diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/copy.fail.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/copy.fail.cpp index af064aeee26c..c7cac6041c82 100644 --- a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/copy.fail.cpp +++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/copy.fail.cpp @@ -6,6 +6,8 @@  // Source Licenses. See LICENSE.TXT for details.  //  //===----------------------------------------------------------------------===// +// +// UNSUPPORTED: c++98, c++03, c++11, c++14  // <shared_mutex> @@ -15,14 +17,8 @@  #include <shared_mutex> -#include "test_macros.h" -  int main()  { -#if TEST_STD_VER > 14      std::shared_mutex m0; -    std::shared_mutex m1(m0); -#else -#   error -#endif +    std::shared_mutex m1(m0); // expected-error {{call to deleted constructor of 'std::shared_mutex'}}  } 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 9bf7a79e3400..75ddebff0ed9 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 @@ -21,6 +21,7 @@  #include <cstdlib>  #include <cassert> +#include "test_macros.h"  std::shared_mutex m; @@ -30,21 +31,32 @@ 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 !defined(TEST_HAS_SANITIZERS) +ms Tolerance = ms(50); +#else +ms Tolerance = ms(50 * 5); +#endif +  void f()  {      time_point t0 = Clock::now();      m.lock();      time_point t1 = Clock::now();      m.unlock(); -    ns d = t1 - t0 - ms(250); -    assert(d < ms(50));  // within 50ms +    ns d = t1 - t0 - WaitTime; +    assert(d < Tolerance);  // within tolerance  }  int main()  {      m.lock();      std::thread t(f); -    std::this_thread::sleep_for(ms(250)); +    std::this_thread::sleep_for(WaitTime);      m.unlock();      t.join();  } 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 3ffa9e2d0065..6b5089d38859 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 @@ -22,6 +22,8 @@  #include <cstdlib>  #include <cassert> +#include "test_macros.h" +  std::shared_mutex m;  typedef std::chrono::system_clock Clock; @@ -30,14 +32,25 @@ 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 !defined(TEST_HAS_SANITIZERS) +ms Tolerance = ms(50); +#else +ms Tolerance = ms(50 * 5); +#endif +  void f()  {      time_point t0 = Clock::now();      m.lock_shared();      time_point t1 = Clock::now();      m.unlock_shared(); -    ns d = t1 - t0 - ms(250); -    assert(d < ms(50));  // within 50ms +    ns d = t1 - t0 - WaitTime; +    assert(d < Tolerance);  // within tolerance  }  void g() @@ -47,7 +60,7 @@ void g()      time_point t1 = Clock::now();      m.unlock_shared();      ns d = t1 - t0; -    assert(d < ms(50));  // within 50ms +    assert(d < Tolerance);  // within tolerance  } @@ -57,7 +70,7 @@ int main()      std::vector<std::thread> 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(); @@ -65,7 +78,7 @@ int main()      for (auto& t : v)          t = std::thread(g);      std::thread q(f); -    std::this_thread::sleep_for(ms(250)); +    std::this_thread::sleep_for(WaitTime);      m.unlock_shared();      for (auto& t : v)          t.join(); 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 62bb736837ea..2818bd617542 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 @@ -21,6 +21,8 @@  #include <cstdlib>  #include <cassert> +#include "test_macros.h" +  std::shared_timed_mutex m;  typedef std::chrono::system_clock Clock; @@ -29,6 +31,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 + +  void f()  {      time_point t0 = Clock::now(); 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 8fc6299f1b8f..77a9107de923 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 @@ -22,6 +22,8 @@  #include <cstdlib>  #include <cassert> +#include "test_macros.h" +  std::shared_timed_mutex m;  typedef std::chrono::system_clock Clock; @@ -30,14 +32,27 @@ 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 !defined(TEST_HAS_SANITIZERS) +ms Tolerance = ms(50); +#else +ms Tolerance = ms(50 * 5); +#endif + +  void f()  {      time_point t0 = Clock::now();      m.lock_shared();      time_point t1 = Clock::now();      m.unlock_shared(); -    ns d = t1 - t0 - ms(250); -    assert(d < ms(50));  // within 50ms +    ns d = t1 - t0 - WaitTime; +    assert(d < Tolerance);  // within tolerance  }  void g() @@ -47,7 +62,7 @@ void g()      time_point t1 = Clock::now();      m.unlock_shared();      ns d = t1 - t0; -    assert(d < ms(50));  // within 50ms +    assert(d < Tolerance);  // within tolerance  } @@ -57,7 +72,7 @@ int main()      std::vector<std::thread> 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(); @@ -65,7 +80,7 @@ int main()      for (auto& t : v)          t = std::thread(g);      std::thread q(f); -    std::this_thread::sleep_for(ms(250)); +    std::this_thread::sleep_for(WaitTime);      m.unlock_shared();      for (auto& t : v)          t.join(); 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 ab20241895ba..320a268ae77d 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 @@ -22,6 +22,8 @@  #include <cstdlib>  #include <cassert> +#include "test_macros.h" +  std::shared_timed_mutex m;  typedef std::chrono::steady_clock Clock; @@ -30,23 +32,35 @@ 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 !defined(TEST_HAS_SANITIZERS) +ms Tolerance = ms(50); +#else +ms Tolerance = ms(50 * 5); +#endif +  void f1()  {      time_point t0 = Clock::now(); -    assert(m.try_lock_for(ms(300)) == true); +    assert(m.try_lock_for(WaitTime + Tolerance) == true);      time_point t1 = Clock::now();      m.unlock(); -    ns d = t1 - t0 - ms(250); -    assert(d < ms(50));  // within 50ms +    ns d = t1 - t0 - WaitTime; +    assert(d < Tolerance);  // within tolerance  }  void f2()  {      time_point t0 = Clock::now(); -    assert(m.try_lock_for(ms(250)) == false); +    assert(m.try_lock_for(WaitTime) == 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 tolerance  }  int main() @@ -54,14 +68,14 @@ int main()      {          m.lock();          std::thread t(f1); -        std::this_thread::sleep_for(ms(250)); +        std::this_thread::sleep_for(WaitTime);          m.unlock();          t.join();      }      {          m.lock();          std::thread t(f2); -        std::this_thread::sleep_for(ms(300)); +        std::this_thread::sleep_for(WaitTime + Tolerance);          m.unlock();          t.join();      } 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 9c2d8c9c8e5c..3d5604d886cb 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 @@ -22,6 +22,8 @@  #include <cstdlib>  #include <cassert> +#include "test_macros.h" +  std::shared_timed_mutex m;  typedef std::chrono::system_clock Clock; @@ -30,6 +32,13 @@ typedef Clock::duration duration;  typedef std::chrono::milliseconds ms;  typedef std::chrono::nanoseconds ns; + +#if !defined(TEST_HAS_SANITIZERS) +ms Tolerance = ms(200); +#else +ms Tolerance = ms(200 * 5); +#endif +  void f()  {      time_point t0 = Clock::now(); @@ -41,7 +50,7 @@ void f()      time_point t1 = Clock::now();      m.unlock_shared();      ns d = t1 - t0 - ms(250); -    assert(d < ms(200));  // within 200ms +    assert(d < Tolerance);  // within tolerance  }  int main() 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 35444112a5da..4cdb5873f9a1 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 @@ -23,6 +23,8 @@  #include <cstdlib>  #include <cassert> +#include "test_macros.h" +  std::shared_timed_mutex m;  typedef std::chrono::steady_clock Clock; @@ -31,23 +33,34 @@ 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 !defined(TEST_HAS_SANITIZERS) +ms Tolerance = ms(50); +#else +ms Tolerance = ms(50 * 5); +#endif +  void f1()  {      time_point t0 = Clock::now(); -    assert(m.try_lock_shared_for(ms(300)) == true); +    assert(m.try_lock_shared_for(WaitTime + Tolerance) == true);      time_point t1 = Clock::now();      m.unlock_shared(); -    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(); -    assert(m.try_lock_shared_for(ms(250)) == false); +    assert(m.try_lock_shared_for(WaitTime) == 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  }  int main() @@ -57,7 +70,7 @@ int main()          std::vector<std::thread> 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(); @@ -67,7 +80,7 @@ int main()          std::vector<std::thread> 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(); 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 4e0f19de07ce..f7ddbaeef498 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 @@ -23,6 +23,8 @@  #include <cstdlib>  #include <cassert> +#include "test_macros.h" +  std::shared_timed_mutex m;  typedef std::chrono::steady_clock Clock; @@ -31,23 +33,34 @@ 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 !defined(TEST_HAS_SANITIZERS) +ms Tolerance = ms(50); +#else +ms Tolerance = ms(50 * 5); +#endif +  void f1()  {      time_point t0 = Clock::now(); -    assert(m.try_lock_shared_until(Clock::now() + ms(300)) == true); +    assert(m.try_lock_shared_until(Clock::now() + WaitTime + Tolerance) == true);      time_point t1 = Clock::now();      m.unlock_shared(); -    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(); -    assert(m.try_lock_shared_until(Clock::now() + ms(250)) == false); +    assert(m.try_lock_shared_until(Clock::now() + WaitTime) == 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 tolerance  }  int main() @@ -57,7 +70,7 @@ int main()          std::vector<std::thread> 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(); @@ -67,7 +80,7 @@ int main()          std::vector<std::thread> 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(); 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 aa90cf71502f..1560af2c9ecc 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 @@ -32,23 +32,35 @@ 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 !defined(TEST_HAS_SANITIZERS) +ms Tolerance = ms(50); +#else +ms Tolerance = ms(50 * 5); +#endif +  void f1()  {      time_point t0 = Clock::now(); -    assert(m.try_lock_until(Clock::now() + ms(300)) == true); +    assert(m.try_lock_until(Clock::now() + WaitTime + Tolerance) == true);      time_point t1 = Clock::now();      m.unlock(); -    ns d = t1 - t0 - ms(250); -    assert(d < ms(50));  // within 50ms +    ns d = t1 - t0 - WaitTime; +    assert(d < Tolerance);  // within tolerance  }  void f2()  {      time_point t0 = Clock::now(); -    assert(m.try_lock_until(Clock::now() + ms(250)) == false); +    assert(m.try_lock_until(Clock::now() + WaitTime) == 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 tolerance  }  int main() @@ -56,14 +68,14 @@ int main()      {          m.lock();          std::thread t(f1); -        std::this_thread::sleep_for(ms(250)); +        std::this_thread::sleep_for(WaitTime);          m.unlock();          t.join();      }      {          m.lock();          std::thread t(f2); -        std::this_thread::sleep_for(ms(300)); +        std::this_thread::sleep_for(WaitTime + Tolerance);          m.unlock();          t.join();      } 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 89b99348459b..afc318cc3d7a 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,6 +7,7 @@  //  //===----------------------------------------------------------------------===//  // +// XFAIL: libcpp-no-exceptions  // UNSUPPORTED: libcpp-has-no-threads  // <mutex> 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 7198d226960a..6c31df593c0e 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 @@ -8,13 +8,7 @@  //===----------------------------------------------------------------------===//  //  // UNSUPPORTED: libcpp-has-no-threads - -// NOTE: std::terminate is called so the destructors are not invoked and the -// memory is not freed. This will cause ASAN to fail. -// XFAIL: asan - -// NOTE: TSAN will report this test as leaking a thread. -// XFAIL: tsan +// UNSUPPORTED: c++98, c++03  // <thread> @@ -38,12 +32,7 @@ public:      G(const G& g) : alive_(g.alive_) {++n_alive;}      ~G() {alive_ = 0; --n_alive;} -    void operator()() -    { -        assert(alive_ == 1); -        assert(n_alive >= 1); -        op_run = true; -    } +      void operator()(int i, double j)      { @@ -60,7 +49,7 @@ bool G::op_run = false;  void f1()  { -    std::exit(0); +    std::_Exit(0);  }  int main() 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 a8b4be16e631..3de15af8929b 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,6 +7,7 @@  //  //===----------------------------------------------------------------------===//  // +// XFAIL: libcpp-no-exceptions  // UNSUPPORTED: libcpp-has-no-threads  // <thread> @@ -22,6 +23,8 @@  #include <cstdlib>  #include <cassert> +#include "test_macros.h" +  unsigned throw_one = 0xFFFF;  void* operator new(std::size_t s) throw(std::bad_alloc) @@ -75,7 +78,7 @@ public:  int G::n_alive = 0;  bool G::op_run = false; -#ifndef _LIBCPP_HAS_NO_VARIADICS +#if TEST_STD_VER >= 11  class MoveOnly  { @@ -137,7 +140,7 @@ int main()              assert(!G::op_run);          }      } -#ifndef _LIBCPP_HAS_NO_VARIADICS +#if TEST_STD_VER >= 11      {          assert(G::n_alive == 0);          assert(!G::op_run); @@ -150,5 +153,5 @@ int main()          std::thread t = std::thread(MoveOnly(), MoveOnly());          t.join();      } -#endif  // _LIBCPP_HAS_NO_VARIADICS +#endif  } diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.destr/dtor.pass.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.destr/dtor.pass.cpp index ddf96d095730..0efb7713e985 100644 --- a/test/std/thread/thread.threads/thread.thread.class/thread.thread.destr/dtor.pass.cpp +++ b/test/std/thread/thread.threads/thread.thread.class/thread.thread.destr/dtor.pass.cpp @@ -9,8 +9,6 @@  //  // UNSUPPORTED: libcpp-has-no-threads -// NOTE: TSAN will report this test as leaking a thread. -// XFAIL: tsan  // <thread> @@ -47,7 +45,7 @@ bool G::op_run = false;  void f1()  { -    std::exit(0); +    std::_Exit(0);  }  int main() diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/detach.pass.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/detach.pass.cpp index f4a4d1f777f1..726395d99044 100644 --- a/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/detach.pass.cpp +++ b/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/detach.pass.cpp @@ -19,7 +19,7 @@  #include <atomic>  #include <cassert> -std::atomic_bool done = ATOMIC_VAR_INIT(false); +std::atomic_bool done(false);  class G  {  | 
