diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2019-08-20 18:01:01 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2019-08-20 18:01:01 +0000 |
| commit | b7332b04df5d50c92640c74cfeb138ecb7e3f7ae (patch) | |
| tree | b1b49faa0cab1482905e0cda6f0ee5d97e3fe08f /test/std/thread/thread.threads/thread.thread.class | |
| parent | 6012fe9abb1f01b1b5b4ca908464804c21ff8602 (diff) | |
Notes
Diffstat (limited to 'test/std/thread/thread.threads/thread.thread.class')
24 files changed, 0 insertions, 1302 deletions
diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.algorithm/swap.pass.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.algorithm/swap.pass.cpp deleted file mode 100644 index 4d3a742dd168..000000000000 --- a/test/std/thread/thread.threads/thread.thread.class/thread.thread.algorithm/swap.pass.cpp +++ /dev/null @@ -1,58 +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 - -// <thread> - -// class thread - -// void swap(thread& x, thread& y); - -#include <thread> -#include <new> -#include <cstdlib> -#include <cassert> - -class G -{ - int alive_; -public: - static int n_alive; - static bool op_run; - - G() : alive_(1) {++n_alive;} - 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; - } -}; - -int G::n_alive = 0; -bool G::op_run = false; - -int main() -{ - { - G g; - std::thread t0(g); - std::thread::id id0 = t0.get_id(); - std::thread t1; - std::thread::id id1 = t1.get_id(); - swap(t0, t1); - assert(t0.get_id() == id1); - assert(t1.get_id() == id0); - t1.join(); - } -} diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/copy.fail.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/copy.fail.cpp deleted file mode 100644 index 7373886f6173..000000000000 --- a/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/copy.fail.cpp +++ /dev/null @@ -1,51 +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. -// -//===----------------------------------------------------------------------===// - -// <thread> - -// class thread - -// thread& operator=(thread&& t); - -#include <thread> -#include <new> -#include <cstdlib> -#include <cassert> - -class G -{ - int alive_; -public: - static int n_alive; - static bool op_run; - - G() : alive_(1) {++n_alive;} - 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; - } - -}; - -int G::n_alive = 0; -bool G::op_run = false; - -int main() -{ - { - std::thread t0(G()); - std::thread t1; - t1 = t0; - } -} diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/move.pass.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/move.pass.cpp deleted file mode 100644 index d3478818c056..000000000000 --- a/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/move.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, c++98, c++03 - -// <thread> - -// class thread - -// thread& operator=(thread&& t); - -#include <thread> -#include <cassert> - -class G -{ - int alive_; -public: - static int n_alive; - static bool op_run; - - G() : alive_(1) {++n_alive;} - G(const G& g) : alive_(g.alive_) {++n_alive;} - ~G() {alive_ = 0; --n_alive;} - - void operator()(int i, double j) - { - assert(alive_ == 1); - assert(n_alive >= 1); - assert(i == 5); - assert(j == 5.5); - op_run = true; - } -}; - -int G::n_alive = 0; -bool G::op_run = false; - -int main() -{ - { - assert(G::n_alive == 0); - assert(!G::op_run); - { - G g; - std::thread t0(g, 5, 5.5); - std::thread::id id = t0.get_id(); - std::thread t1; - t1 = std::move(t0); - assert(t1.get_id() == id); - assert(t0.get_id() == std::thread::id()); - t1.join(); - } - assert(G::n_alive == 0); - assert(G::op_run); - } -} 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 deleted file mode 100644 index e452ac98c49e..000000000000 --- a/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/move2.pass.cpp +++ /dev/null @@ -1,65 +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 -// UNSUPPORTED: c++98, c++03 - -// <thread> - -// class thread - -// thread& operator=(thread&& t); - -#include <thread> -#include <exception> -#include <cstdlib> -#include <cassert> - -class G -{ - int alive_; -public: - static int n_alive; - static bool op_run; - - G() : alive_(1) {++n_alive;} - G(const G& g) : alive_(g.alive_) {++n_alive;} - ~G() {alive_ = 0; --n_alive;} - - - - void operator()(int i, double j) - { - assert(alive_ == 1); - assert(n_alive >= 1); - assert(i == 5); - assert(j == 5.5); - op_run = true; - } -}; - -int G::n_alive = 0; -bool G::op_run = false; - -void f1() -{ - std::_Exit(0); -} - -int main() -{ - std::set_terminate(f1); - { - G g; - std::thread t0(g, 5, 5.5); - std::thread t1; - t0 = std::move(t1); - assert(false); - } -} diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp deleted file mode 100644 index be3fc9c5d1eb..000000000000 --- a/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp +++ /dev/null @@ -1,204 +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 - -// <thread> - -// class thread - -// template <class F, class ...Args> thread(F&& f, Args&&... args); - -// UNSUPPORTED: sanitizer-new-delete - -#include <thread> -#include <new> -#include <atomic> -#include <cstdlib> -#include <cassert> - -#include "test_macros.h" - -std::atomic<unsigned> throw_one(0xFFFF); -std::atomic<unsigned> outstanding_new(0); - - -void* operator new(std::size_t s) TEST_THROW_SPEC(std::bad_alloc) -{ - if (throw_one == 0) - TEST_THROW(std::bad_alloc()); - --throw_one; - ++outstanding_new; - void* ret = std::malloc(s); - if (!ret) std::abort(); // placate MSVC's unchecked malloc warning - return ret; -} - -void operator delete(void* p) TEST_NOEXCEPT -{ - --outstanding_new; - std::free(p); -} - -bool f_run = false; - -void f() -{ - f_run = true; -} - -class G -{ - int alive_; -public: - static int n_alive; - static bool op_run; - - G() : alive_(1) {++n_alive;} - 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) - { - assert(alive_ == 1); - assert(n_alive >= 1); - assert(i == 5); - assert(j == 5.5); - op_run = true; - } -}; - -int G::n_alive = 0; -bool G::op_run = false; - -#if TEST_STD_VER >= 11 - -class MoveOnly -{ - MoveOnly(const MoveOnly&); -public: - MoveOnly() {} - MoveOnly(MoveOnly&&) {} - - void operator()(MoveOnly&&) - { - } -}; - -#endif - -// Test throwing std::bad_alloc -//----------------------------- -// Concerns: -// A Each allocation performed during thread construction should be performed -// in the parent thread so that std::terminate is not called if -// std::bad_alloc is thrown by new. -// B std::thread's constructor should properly handle exceptions and not leak -// memory. -// Plan: -// 1 Create a thread and count the number of allocations, 'N', it performs. -// 2 For each allocation performed run a test where that allocation throws. -// 2.1 check that the exception can be caught in the parent thread. -// 2.2 Check that the functor has not been called. -// 2.3 Check that no memory allocated by the creation of the thread is leaked. -// 3 Finally check that a thread runs successfully if we throw after 'N+1' -// allocations. -void test_throwing_new_during_thread_creation() { -#ifndef TEST_HAS_NO_EXCEPTIONS - throw_one = 0xFFF; - { - std::thread t(f); - t.join(); - } - const int numAllocs = 0xFFF - throw_one; - // i <= numAllocs means the last iteration is expected not to throw. - for (int i=0; i <= numAllocs; ++i) { - throw_one = i; - f_run = false; - unsigned old_outstanding = outstanding_new; - try { - std::thread t(f); - assert(i == numAllocs); // Only final iteration will not throw. - t.join(); - assert(f_run); - } catch (std::bad_alloc const&) { - assert(i < numAllocs); - assert(!f_run); // (2.2) - } - assert(old_outstanding == outstanding_new); // (2.3) - } - f_run = false; - throw_one = 0xFFF; -#endif -} - -int main() -{ - test_throwing_new_during_thread_creation(); - { - std::thread t(f); - t.join(); - assert(f_run == true); - } - - { - assert(G::n_alive == 0); - assert(!G::op_run); - { - G g; - std::thread t(g); - t.join(); - } - assert(G::n_alive == 0); - assert(G::op_run); - } - G::op_run = false; -#ifndef TEST_HAS_NO_EXCEPTIONS - { - try - { - throw_one = 0; - assert(G::n_alive == 0); - assert(!G::op_run); - std::thread t((G())); - assert(false); - } - catch (...) - { - throw_one = 0xFFFF; - assert(G::n_alive == 0); - assert(!G::op_run); - } - } -#endif -#if TEST_STD_VER >= 11 - { - assert(G::n_alive == 0); - assert(!G::op_run); - { - G g; - std::thread t(g, 5, 5.5); - t.join(); - } - assert(G::n_alive == 0); - assert(G::op_run); - } - { - std::thread t = std::thread(MoveOnly(), MoveOnly()); - t.join(); - } -#endif -} diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/constr.fail.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/constr.fail.cpp deleted file mode 100644 index 54fc0b80280c..000000000000 --- a/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/constr.fail.cpp +++ /dev/null @@ -1,26 +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. -// -//===----------------------------------------------------------------------===// - -// <thread> - -// class thread -// template <class _Fp, class ..._Args, -// explicit thread(_Fp&& __f, _Args&&... __args); -// This constructor shall not participate in overload resolution -// if decay<F>::type is the same type as std::thread. - - -#include <thread> -#include <cassert> - -int main() -{ - volatile std::thread t1; - std::thread t2 ( t1, 1, 2.0 ); -} diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/copy.fail.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/copy.fail.cpp deleted file mode 100644 index f66474c93b42..000000000000 --- a/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/copy.fail.cpp +++ /dev/null @@ -1,66 +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. -// -//===----------------------------------------------------------------------===// - -// <thread> - -// class thread - -// thread(const thread&) = delete; - -#include <thread> -#include <new> -#include <cstdlib> -#include <cassert> - -class G -{ - int alive_; -public: - static int n_alive; - static bool op_run; - - G() : alive_(1) {++n_alive;} - 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) - { - assert(alive_ == 1); - assert(n_alive >= 1); - assert(i == 5); - assert(j == 5.5); - op_run = true; - } -}; - -int G::n_alive = 0; -bool G::op_run = false; - -int main() -{ - { - assert(G::n_alive == 0); - assert(!G::op_run); - std::thread t0(G(), 5, 5.5); - std::thread::id id = t0.get_id(); - std::thread t1 = t0; - assert(t1.get_id() == id); - assert(t0.get_id() == std::thread::id()); - t1.join(); - assert(G::n_alive == 0); - assert(G::op_run); - } -} diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/default.pass.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/default.pass.cpp deleted file mode 100644 index 64d5a935ba55..000000000000 --- a/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/default.pass.cpp +++ /dev/null @@ -1,25 +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 - -// <thread> - -// class thread - -// thread(); - -#include <thread> -#include <cassert> - -int main() -{ - std::thread t; - assert(t.get_id() == std::thread::id()); -} diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/move.pass.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/move.pass.cpp deleted file mode 100644 index f349e4c56fcb..000000000000 --- a/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/move.pass.cpp +++ /dev/null @@ -1,70 +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, c++98, c++03 - -// <thread> - -// class thread - -// thread(thread&& t); - -#include <thread> -#include <new> -#include <cstdlib> -#include <cassert> - -class G -{ - int alive_; -public: - static int n_alive; - static bool op_run; - - G() : alive_(1) {++n_alive;} - 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) - { - assert(alive_ == 1); - assert(n_alive >= 1); - assert(i == 5); - assert(j == 5.5); - op_run = true; - } -}; - -int G::n_alive = 0; -bool G::op_run = false; - -int main() -{ - { - G g; - assert(G::n_alive == 1); - assert(!G::op_run); - std::thread t0(g, 5, 5.5); - std::thread::id id = t0.get_id(); - std::thread t1 = std::move(t0); - assert(t1.get_id() == id); - assert(t0.get_id() == std::thread::id()); - t1.join(); - assert(G::n_alive == 1); - assert(G::op_run); - } - assert(G::n_alive == 0); -} 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 deleted file mode 100644 index 0efb7713e985..000000000000 --- a/test/std/thread/thread.threads/thread.thread.class/thread.thread.destr/dtor.pass.cpp +++ /dev/null @@ -1,64 +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 - - -// <thread> - -// class thread - -// ~thread(); - -#include <thread> -#include <new> -#include <cstdlib> -#include <cassert> - -class G -{ - int alive_; -public: - static int n_alive; - static bool op_run; - - G() : alive_(1) {++n_alive;} - 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; - } -}; - -int G::n_alive = 0; -bool G::op_run = false; - -void f1() -{ - std::_Exit(0); -} - -int main() -{ - std::set_terminate(f1); - { - assert(G::n_alive == 0); - assert(!G::op_run); - G g; - { - std::thread t(g); - std::this_thread::sleep_for(std::chrono::milliseconds(250)); - } - } - assert(false); -} diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/assign.pass.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/assign.pass.cpp deleted file mode 100644 index 585f7ea98a03..000000000000 --- a/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/assign.pass.cpp +++ /dev/null @@ -1,29 +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 - -// <thread> - -// class thread::id - -// id& operator=(const id&) = default; - -#include <thread> -#include <cassert> - -int main() -{ - std::thread::id id0; - std::thread::id id1; - id1 = id0; - assert(id1 == id0); - id1 = std::this_thread::get_id(); - assert(id1 != id0); -} diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/copy.pass.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/copy.pass.cpp deleted file mode 100644 index e8c38016b288..000000000000 --- a/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/copy.pass.cpp +++ /dev/null @@ -1,26 +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 - -// <thread> - -// class thread::id - -// id(const id&) = default; - -#include <thread> -#include <cassert> - -int main() -{ - std::thread::id id0; - std::thread::id id1 = id0; - assert(id1 == id0); -} diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/default.pass.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/default.pass.cpp deleted file mode 100644 index 0037deb1dd65..000000000000 --- a/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/default.pass.cpp +++ /dev/null @@ -1,25 +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 - -// <thread> - -// class thread::id - -// id(); - -#include <thread> -#include <cassert> - -int main() -{ - std::thread::id id; - assert(id == std::thread::id()); -} diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/enabled_hashes.pass.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/enabled_hashes.pass.cpp deleted file mode 100644 index 9799467c4529..000000000000 --- a/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/enabled_hashes.pass.cpp +++ /dev/null @@ -1,27 +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 -// UNSUPPORTED: c++98, c++03 - -// <thread> - -// Test that <thread> provides all of the arithmetic, enum, and pointer -// hash specializations. - -#include <thread> - -#include "poisoned_hash_helper.hpp" - -int main() { - test_library_hash_specializations_available(); - { - test_hash_enabled_for_type<std::thread::id>(); - } -} diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/eq.pass.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/eq.pass.cpp deleted file mode 100644 index 6dd4c3ec4f57..000000000000 --- a/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/eq.pass.cpp +++ /dev/null @@ -1,32 +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 - -// <thread> - -// class thread::id - -// bool operator==(thread::id x, thread::id y); -// bool operator!=(thread::id x, thread::id y); - -#include <thread> -#include <cassert> - -int main() -{ - std::thread::id id0; - std::thread::id id1; - id1 = id0; - assert( (id1 == id0)); - assert(!(id1 != id0)); - id1 = std::this_thread::get_id(); - assert(!(id1 == id0)); - assert( (id1 != id0)); -} diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/lt.pass.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/lt.pass.cpp deleted file mode 100644 index de52b1d00cdf..000000000000 --- a/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/lt.pass.cpp +++ /dev/null @@ -1,43 +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 - -// <thread> - -// class thread::id - -// bool operator< (thread::id x, thread::id y); -// bool operator<=(thread::id x, thread::id y); -// bool operator> (thread::id x, thread::id y); -// bool operator>=(thread::id x, thread::id y); - -#include <thread> -#include <cassert> - -int main() -{ - std::thread::id id0; - std::thread::id id1; - std::thread::id id2 = std::this_thread::get_id(); - assert(!(id0 < id1)); - assert( (id0 <= id1)); - assert(!(id0 > id1)); - assert( (id0 >= id1)); - assert(!(id0 == id2)); - if (id0 < id2) { - assert( (id0 <= id2)); - assert(!(id0 > id2)); - assert(!(id0 >= id2)); - } else { - assert(!(id0 <= id2)); - assert( (id0 > id2)); - assert( (id0 >= id2)); - } -} diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/stream.pass.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/stream.pass.cpp deleted file mode 100644 index 126965fe3fc3..000000000000 --- a/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/stream.pass.cpp +++ /dev/null @@ -1,29 +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 - -// <thread> - -// class thread::id - -// template<class charT, class traits> -// basic_ostream<charT, traits>& -// operator<<(basic_ostream<charT, traits>& out, thread::id id); - -#include <thread> -#include <sstream> -#include <cassert> - -int main() -{ - std::thread::id id0 = std::this_thread::get_id(); - std::ostringstream os; - os << id0; -} diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/thread_id.pass.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/thread_id.pass.cpp deleted file mode 100644 index 4f1491decd31..000000000000 --- a/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/thread_id.pass.cpp +++ /dev/null @@ -1,38 +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 - -// <thread> - -// template <class T> -// struct hash -// : public unary_function<T, size_t> -// { -// size_t operator()(T val) const; -// }; - -// Not very portable - -#include <thread> -#include <cassert> - -#include "test_macros.h" - -int main() -{ - std::thread::id id1; - std::thread::id id2 = std::this_thread::get_id(); - typedef std::hash<std::thread::id> H; - static_assert((std::is_same<typename H::argument_type, std::thread::id>::value), "" ); - static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" ); - ASSERT_NOEXCEPT(H()(id2)); - H h; - assert(h(id1) != h(id2)); -} 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 deleted file mode 100644 index 3dd7c6a6014c..000000000000 --- a/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/detach.pass.cpp +++ /dev/null @@ -1,90 +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 - -// <thread> - -// class thread - -// void detach(); - -#include <thread> -#include <atomic> -#include <system_error> -#include <cassert> - -#include "test_macros.h" - -std::atomic_bool done(false); - -class G -{ - int alive_; - bool done_; -public: - static int n_alive; - static bool op_run; - - G() : alive_(1), done_(false) - { - ++n_alive; - } - - G(const G& g) : alive_(g.alive_), done_(false) - { - ++n_alive; - } - ~G() - { - alive_ = 0; - --n_alive; - if (done_) done = true; - } - - void operator()() - { - assert(alive_ == 1); - assert(n_alive >= 1); - op_run = true; - done_ = true; - } -}; - -int G::n_alive = 0; -bool G::op_run = false; - -void foo() {} - -int main() -{ - { - G g; - std::thread t0(g); - assert(t0.joinable()); - t0.detach(); - assert(!t0.joinable()); - while (!done) {} - assert(G::op_run); - assert(G::n_alive == 1); - } - assert(G::n_alive == 0); -#ifndef TEST_HAS_NO_EXCEPTIONS - { - std::thread t0(foo); - assert(t0.joinable()); - t0.detach(); - assert(!t0.joinable()); - try { - t0.detach(); - } catch (std::system_error const&) { - } - } -#endif -} diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/get_id.pass.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/get_id.pass.cpp deleted file mode 100644 index f9f38c85f0e9..000000000000 --- a/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/get_id.pass.cpp +++ /dev/null @@ -1,58 +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 - -// <thread> - -// class thread - -// id get_id() const; - -#include <thread> -#include <new> -#include <cstdlib> -#include <cassert> - -class G -{ - int alive_; -public: - static int n_alive; - static bool op_run; - - G() : alive_(1) {++n_alive;} - 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; - } -}; - -int G::n_alive = 0; -bool G::op_run = false; - -int main() -{ - { - G g; - std::thread t0(g); - std::thread::id id0 = t0.get_id(); - std::thread t1; - std::thread::id id1 = t1.get_id(); - assert(t0.get_id() == id0); - assert(id0 != id1); - assert(t1.get_id() == std::thread::id()); - t0.join(); - } -} diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/join.pass.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/join.pass.cpp deleted file mode 100644 index f0c3ef74c9ab..000000000000 --- a/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/join.pass.cpp +++ /dev/null @@ -1,77 +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 - -// <thread> - -// class thread - -// void join(); - -#include <thread> -#include <new> -#include <cstdlib> -#include <cassert> -#include <system_error> - -#include "test_macros.h" - -class G -{ - int alive_; -public: - static int n_alive; - static bool op_run; - - G() : alive_(1) {++n_alive;} - 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; - } -}; - -int G::n_alive = 0; -bool G::op_run = false; - -void foo() {} - -int main() -{ - { - G g; - std::thread t0(g); - assert(t0.joinable()); - t0.join(); - assert(!t0.joinable()); -#ifndef TEST_HAS_NO_EXCEPTIONS - try { - t0.join(); - assert(false); - } catch (std::system_error const&) { - } -#endif - } -#ifndef TEST_HAS_NO_EXCEPTIONS - { - std::thread t0(foo); - t0.detach(); - try { - t0.join(); - assert(false); - } catch (std::system_error const&) { - } - } -#endif -} diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/joinable.pass.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/joinable.pass.cpp deleted file mode 100644 index b97839c32184..000000000000 --- a/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/joinable.pass.cpp +++ /dev/null @@ -1,54 +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 - -// <thread> - -// class thread - -// bool joinable() const; - -#include <thread> -#include <new> -#include <cstdlib> -#include <cassert> - -class G -{ - int alive_; -public: - static int n_alive; - static bool op_run; - - G() : alive_(1) {++n_alive;} - 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; - } -}; - -int G::n_alive = 0; -bool G::op_run = false; - -int main() -{ - { - G g; - std::thread t0(g); - assert(t0.joinable()); - t0.join(); - assert(!t0.joinable()); - } -} diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/swap.pass.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/swap.pass.cpp deleted file mode 100644 index 49d4618e86ad..000000000000 --- a/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/swap.pass.cpp +++ /dev/null @@ -1,58 +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 - -// <thread> - -// class thread - -// void swap(thread& t); - -#include <thread> -#include <new> -#include <cstdlib> -#include <cassert> - -class G -{ - int alive_; -public: - static int n_alive; - static bool op_run; - - G() : alive_(1) {++n_alive;} - 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; - } -}; - -int G::n_alive = 0; -bool G::op_run = false; - -int main() -{ - { - G g; - std::thread t0(g); - std::thread::id id0 = t0.get_id(); - std::thread t1; - std::thread::id id1 = t1.get_id(); - t0.swap(t1); - assert(t0.get_id() == id1); - assert(t1.get_id() == id0); - t1.join(); - } -} diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.static/hardware_concurrency.pass.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.static/hardware_concurrency.pass.cpp deleted file mode 100644 index 4d1ffad45937..000000000000 --- a/test/std/thread/thread.threads/thread.thread.class/thread.thread.static/hardware_concurrency.pass.cpp +++ /dev/null @@ -1,24 +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 - -// <thread> - -// class thread - -// unsigned hardware_concurrency(); - -#include <thread> -#include <cassert> - -int main() -{ - assert(std::thread::hardware_concurrency() > 0); -} |
