summaryrefslogtreecommitdiffstats
path: root/libcxx
diff options
context:
space:
mode:
Diffstat (limited to 'libcxx')
-rw-r--r--libcxx/test/libcxx/containers/sequences/vector/const_value_type.pass.cpp (renamed from libcxx/test/std/containers/sequences/vector/const_value_type.pass.cpp)4
-rw-r--r--libcxx/test/libcxx/containers/sequences/vector/db_back.pass.cpp (renamed from libcxx/test/std/containers/sequences/vector/db_back.pass.cpp)0
-rw-r--r--libcxx/test/libcxx/containers/sequences/vector/db_cback.pass.cpp (renamed from libcxx/test/std/containers/sequences/vector/db_cback.pass.cpp)0
-rw-r--r--libcxx/test/libcxx/containers/sequences/vector/db_cfront.pass.cpp (renamed from libcxx/test/std/containers/sequences/vector/db_cfront.pass.cpp)0
-rw-r--r--libcxx/test/libcxx/containers/sequences/vector/db_cindex.pass.cpp (renamed from libcxx/test/std/containers/sequences/vector/db_cindex.pass.cpp)0
-rw-r--r--libcxx/test/libcxx/containers/sequences/vector/db_front.pass.cpp (renamed from libcxx/test/std/containers/sequences/vector/db_front.pass.cpp)0
-rw-r--r--libcxx/test/libcxx/containers/sequences/vector/db_index.pass.cpp (renamed from libcxx/test/std/containers/sequences/vector/db_index.pass.cpp)0
-rw-r--r--libcxx/test/libcxx/containers/sequences/vector/db_iterators_2.pass.cpp (renamed from libcxx/test/std/containers/sequences/vector/db_iterators_2.pass.cpp)0
-rw-r--r--libcxx/test/libcxx/containers/sequences/vector/db_iterators_3.pass.cpp (renamed from libcxx/test/std/containers/sequences/vector/db_iterators_3.pass.cpp)0
-rw-r--r--libcxx/test/libcxx/containers/sequences/vector/db_iterators_4.pass.cpp (renamed from libcxx/test/std/containers/sequences/vector/db_iterators_4.pass.cpp)0
-rw-r--r--libcxx/test/libcxx/containers/sequences/vector/db_iterators_5.pass.cpp (renamed from libcxx/test/std/containers/sequences/vector/db_iterators_5.pass.cpp)0
-rw-r--r--libcxx/test/libcxx/containers/sequences/vector/db_iterators_6.pass.cpp (renamed from libcxx/test/std/containers/sequences/vector/db_iterators_6.pass.cpp)0
-rw-r--r--libcxx/test/libcxx/containers/sequences/vector/db_iterators_7.pass.cpp (renamed from libcxx/test/std/containers/sequences/vector/db_iterators_7.pass.cpp)0
-rw-r--r--libcxx/test/libcxx/containers/sequences/vector/db_iterators_8.pass.cpp (renamed from libcxx/test/std/containers/sequences/vector/db_iterators_8.pass.cpp)0
-rw-r--r--libcxx/test/libcxx/extensions/hash/specializations.fail.cpp (renamed from libcxx/test/std/extensions/hash/specializations.fail.cpp)0
-rw-r--r--libcxx/test/libcxx/extensions/hash/specializations.pass.cpp (renamed from libcxx/test/std/extensions/hash/specializations.pass.cpp)0
-rw-r--r--libcxx/test/libcxx/extensions/hash_map/const_iterator.fail.cpp (renamed from libcxx/test/std/extensions/hash_map/const_iterator.fail.cpp)0
-rw-r--r--libcxx/test/libcxx/extensions/nothing_to_do.pass.cpp (renamed from libcxx/test/std/extensions/nothing_to_do.pass.cpp)0
-rw-r--r--libcxx/test/libcxx/localization/locale.categories/__scan_keyword.pass.cpp (renamed from libcxx/test/std/localization/locale.categories/__scan_keyword.pass.cpp)0
-rw-r--r--libcxx/test/libcxx/localization/locales/locale/locale.types/locale.facet/facet.pass.cpp (renamed from libcxx/test/std/localization/locales/locale/locale.types/locale.facet/facet.pass.cpp)0
-rw-r--r--libcxx/test/libcxx/localization/locales/locale/locale.types/locale.id/id.pass.cpp (renamed from libcxx/test/std/localization/locales/locale/locale.types/locale.id/id.pass.cpp)0
-rw-r--r--libcxx/test/libcxx/utilities/meta/meta.unary/meta.unary.prop/__has_operator_addressof.pass.cpp (renamed from libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/__has_operator_addressof.pass.cpp)0
-rw-r--r--libcxx/test/std/containers/associative/map/map.modifiers/insert_or_assign.pass.cpp7
-rw-r--r--libcxx/test/std/containers/associative/map/map.modifiers/try.emplace.pass.cpp7
-rw-r--r--libcxx/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/minus1.pass1
-rw-r--r--libcxx/test/std/localization/locales/locale/locale.types/locale.facet/tested_elsewhere.pass.cpp12
-rw-r--r--libcxx/test/std/localization/locales/locale/locale.types/locale.id/tested_elsewhere.pass.cpp12
-rw-r--r--libcxx/test/std/strings/c.strings/cwchar.pass.cpp7
-rw-r--r--libcxx/test/std/thread/futures/futures.async/async.pass.cpp173
-rw-r--r--libcxx/test/std/thread/futures/futures.overview/launch.pass.cpp12
-rw-r--r--libcxx/test/support/asan_testing.h2
31 files changed, 100 insertions, 137 deletions
diff --git a/libcxx/test/std/containers/sequences/vector/const_value_type.pass.cpp b/libcxx/test/libcxx/containers/sequences/vector/const_value_type.pass.cpp
index e16e439dec4..2a150f7cce5 100644
--- a/libcxx/test/std/containers/sequences/vector/const_value_type.pass.cpp
+++ b/libcxx/test/libcxx/containers/sequences/vector/const_value_type.pass.cpp
@@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++98, c++03
+
// <vector>
// vector<const int> v; // an extension
@@ -16,7 +18,5 @@
int main()
{
-#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
std::vector<const int> v = {1, 2, 3};
-#endif
}
diff --git a/libcxx/test/std/containers/sequences/vector/db_back.pass.cpp b/libcxx/test/libcxx/containers/sequences/vector/db_back.pass.cpp
index 05f3d07712e..05f3d07712e 100644
--- a/libcxx/test/std/containers/sequences/vector/db_back.pass.cpp
+++ b/libcxx/test/libcxx/containers/sequences/vector/db_back.pass.cpp
diff --git a/libcxx/test/std/containers/sequences/vector/db_cback.pass.cpp b/libcxx/test/libcxx/containers/sequences/vector/db_cback.pass.cpp
index 5eb1a353e8b..5eb1a353e8b 100644
--- a/libcxx/test/std/containers/sequences/vector/db_cback.pass.cpp
+++ b/libcxx/test/libcxx/containers/sequences/vector/db_cback.pass.cpp
diff --git a/libcxx/test/std/containers/sequences/vector/db_cfront.pass.cpp b/libcxx/test/libcxx/containers/sequences/vector/db_cfront.pass.cpp
index 5e54da1d444..5e54da1d444 100644
--- a/libcxx/test/std/containers/sequences/vector/db_cfront.pass.cpp
+++ b/libcxx/test/libcxx/containers/sequences/vector/db_cfront.pass.cpp
diff --git a/libcxx/test/std/containers/sequences/vector/db_cindex.pass.cpp b/libcxx/test/libcxx/containers/sequences/vector/db_cindex.pass.cpp
index 133aa565282..133aa565282 100644
--- a/libcxx/test/std/containers/sequences/vector/db_cindex.pass.cpp
+++ b/libcxx/test/libcxx/containers/sequences/vector/db_cindex.pass.cpp
diff --git a/libcxx/test/std/containers/sequences/vector/db_front.pass.cpp b/libcxx/test/libcxx/containers/sequences/vector/db_front.pass.cpp
index 388058fb315..388058fb315 100644
--- a/libcxx/test/std/containers/sequences/vector/db_front.pass.cpp
+++ b/libcxx/test/libcxx/containers/sequences/vector/db_front.pass.cpp
diff --git a/libcxx/test/std/containers/sequences/vector/db_index.pass.cpp b/libcxx/test/libcxx/containers/sequences/vector/db_index.pass.cpp
index 1daf076da67..1daf076da67 100644
--- a/libcxx/test/std/containers/sequences/vector/db_index.pass.cpp
+++ b/libcxx/test/libcxx/containers/sequences/vector/db_index.pass.cpp
diff --git a/libcxx/test/std/containers/sequences/vector/db_iterators_2.pass.cpp b/libcxx/test/libcxx/containers/sequences/vector/db_iterators_2.pass.cpp
index 2d43843067b..2d43843067b 100644
--- a/libcxx/test/std/containers/sequences/vector/db_iterators_2.pass.cpp
+++ b/libcxx/test/libcxx/containers/sequences/vector/db_iterators_2.pass.cpp
diff --git a/libcxx/test/std/containers/sequences/vector/db_iterators_3.pass.cpp b/libcxx/test/libcxx/containers/sequences/vector/db_iterators_3.pass.cpp
index 051d66c3339..051d66c3339 100644
--- a/libcxx/test/std/containers/sequences/vector/db_iterators_3.pass.cpp
+++ b/libcxx/test/libcxx/containers/sequences/vector/db_iterators_3.pass.cpp
diff --git a/libcxx/test/std/containers/sequences/vector/db_iterators_4.pass.cpp b/libcxx/test/libcxx/containers/sequences/vector/db_iterators_4.pass.cpp
index 4c2aa628de1..4c2aa628de1 100644
--- a/libcxx/test/std/containers/sequences/vector/db_iterators_4.pass.cpp
+++ b/libcxx/test/libcxx/containers/sequences/vector/db_iterators_4.pass.cpp
diff --git a/libcxx/test/std/containers/sequences/vector/db_iterators_5.pass.cpp b/libcxx/test/libcxx/containers/sequences/vector/db_iterators_5.pass.cpp
index 1b1090499c2..1b1090499c2 100644
--- a/libcxx/test/std/containers/sequences/vector/db_iterators_5.pass.cpp
+++ b/libcxx/test/libcxx/containers/sequences/vector/db_iterators_5.pass.cpp
diff --git a/libcxx/test/std/containers/sequences/vector/db_iterators_6.pass.cpp b/libcxx/test/libcxx/containers/sequences/vector/db_iterators_6.pass.cpp
index 424bc939b13..424bc939b13 100644
--- a/libcxx/test/std/containers/sequences/vector/db_iterators_6.pass.cpp
+++ b/libcxx/test/libcxx/containers/sequences/vector/db_iterators_6.pass.cpp
diff --git a/libcxx/test/std/containers/sequences/vector/db_iterators_7.pass.cpp b/libcxx/test/libcxx/containers/sequences/vector/db_iterators_7.pass.cpp
index 72cdb10cbc8..72cdb10cbc8 100644
--- a/libcxx/test/std/containers/sequences/vector/db_iterators_7.pass.cpp
+++ b/libcxx/test/libcxx/containers/sequences/vector/db_iterators_7.pass.cpp
diff --git a/libcxx/test/std/containers/sequences/vector/db_iterators_8.pass.cpp b/libcxx/test/libcxx/containers/sequences/vector/db_iterators_8.pass.cpp
index 7b898533197..7b898533197 100644
--- a/libcxx/test/std/containers/sequences/vector/db_iterators_8.pass.cpp
+++ b/libcxx/test/libcxx/containers/sequences/vector/db_iterators_8.pass.cpp
diff --git a/libcxx/test/std/extensions/hash/specializations.fail.cpp b/libcxx/test/libcxx/extensions/hash/specializations.fail.cpp
index 8eeffb5802e..8eeffb5802e 100644
--- a/libcxx/test/std/extensions/hash/specializations.fail.cpp
+++ b/libcxx/test/libcxx/extensions/hash/specializations.fail.cpp
diff --git a/libcxx/test/std/extensions/hash/specializations.pass.cpp b/libcxx/test/libcxx/extensions/hash/specializations.pass.cpp
index a222b1eb5c6..a222b1eb5c6 100644
--- a/libcxx/test/std/extensions/hash/specializations.pass.cpp
+++ b/libcxx/test/libcxx/extensions/hash/specializations.pass.cpp
diff --git a/libcxx/test/std/extensions/hash_map/const_iterator.fail.cpp b/libcxx/test/libcxx/extensions/hash_map/const_iterator.fail.cpp
index e4c536e8f33..e4c536e8f33 100644
--- a/libcxx/test/std/extensions/hash_map/const_iterator.fail.cpp
+++ b/libcxx/test/libcxx/extensions/hash_map/const_iterator.fail.cpp
diff --git a/libcxx/test/std/extensions/nothing_to_do.pass.cpp b/libcxx/test/libcxx/extensions/nothing_to_do.pass.cpp
index b58f5c55b64..b58f5c55b64 100644
--- a/libcxx/test/std/extensions/nothing_to_do.pass.cpp
+++ b/libcxx/test/libcxx/extensions/nothing_to_do.pass.cpp
diff --git a/libcxx/test/std/localization/locale.categories/__scan_keyword.pass.cpp b/libcxx/test/libcxx/localization/locale.categories/__scan_keyword.pass.cpp
index b33aab9a730..b33aab9a730 100644
--- a/libcxx/test/std/localization/locale.categories/__scan_keyword.pass.cpp
+++ b/libcxx/test/libcxx/localization/locale.categories/__scan_keyword.pass.cpp
diff --git a/libcxx/test/std/localization/locales/locale/locale.types/locale.facet/facet.pass.cpp b/libcxx/test/libcxx/localization/locales/locale/locale.types/locale.facet/facet.pass.cpp
index 4a7f77ad5d9..4a7f77ad5d9 100644
--- a/libcxx/test/std/localization/locales/locale/locale.types/locale.facet/facet.pass.cpp
+++ b/libcxx/test/libcxx/localization/locales/locale/locale.types/locale.facet/facet.pass.cpp
diff --git a/libcxx/test/std/localization/locales/locale/locale.types/locale.id/id.pass.cpp b/libcxx/test/libcxx/localization/locales/locale/locale.types/locale.id/id.pass.cpp
index 3233624d87b..3233624d87b 100644
--- a/libcxx/test/std/localization/locales/locale/locale.types/locale.id/id.pass.cpp
+++ b/libcxx/test/libcxx/localization/locales/locale/locale.types/locale.id/id.pass.cpp
diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/__has_operator_addressof.pass.cpp b/libcxx/test/libcxx/utilities/meta/meta.unary/meta.unary.prop/__has_operator_addressof.pass.cpp
index 1c715e04970..1c715e04970 100644
--- a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/__has_operator_addressof.pass.cpp
+++ b/libcxx/test/libcxx/utilities/meta/meta.unary/meta.unary.prop/__has_operator_addressof.pass.cpp
diff --git a/libcxx/test/std/containers/associative/map/map.modifiers/insert_or_assign.pass.cpp b/libcxx/test/std/containers/associative/map/map.modifiers/insert_or_assign.pass.cpp
index 484ed06247d..526bcee7fdc 100644
--- a/libcxx/test/std/containers/associative/map/map.modifiers/insert_or_assign.pass.cpp
+++ b/libcxx/test/std/containers/associative/map/map.modifiers/insert_or_assign.pass.cpp
@@ -22,7 +22,6 @@
// template <class M>
// iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj); // C++17
-#include <__config>
#include <map>
#include <cassert>
#include <tuple>
@@ -60,9 +59,6 @@ public:
int main()
{
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-#ifndef _LIBCPP_HAS_NO_VARIADICS
-
{ // pair<iterator, bool> insert_or_assign(const key_type& k, M&& obj);
typedef std::map<int, Moveable> M;
typedef std::pair<M::iterator, bool> R;
@@ -186,7 +182,4 @@ int main()
assert(r->first.get() == 3); // key
assert(r->second.get() == 5); // value
}
-
-#endif // _LIBCPP_HAS_NO_VARIADICS
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
} \ No newline at end of file
diff --git a/libcxx/test/std/containers/associative/map/map.modifiers/try.emplace.pass.cpp b/libcxx/test/std/containers/associative/map/map.modifiers/try.emplace.pass.cpp
index 8e0dd7577bb..7144ed2c727 100644
--- a/libcxx/test/std/containers/associative/map/map.modifiers/try.emplace.pass.cpp
+++ b/libcxx/test/std/containers/associative/map/map.modifiers/try.emplace.pass.cpp
@@ -22,7 +22,6 @@
// template <class... Args>
// iterator try_emplace(const_iterator hint, key_type&& k, Args&&... args); // C++17
-#include <__config>
#include <map>
#include <cassert>
#include <tuple>
@@ -58,9 +57,6 @@ public:
int main()
{
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-#ifndef _LIBCPP_HAS_NO_VARIADICS
-
{ // pair<iterator, bool> try_emplace(const key_type& k, Args&&... args);
typedef std::map<int, Moveable> M;
typedef std::pair<M::iterator, bool> R;
@@ -183,7 +179,4 @@ int main()
assert(r->first.get() == 3); // key
assert(r->second.get() == 4); // value
}
-
-#endif // _LIBCPP_HAS_NO_VARIADICS
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}
diff --git a/libcxx/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/minus1.pass b/libcxx/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/minus1.pass
index 27b8cfd85c9..5f5a859cb29 100644
--- a/libcxx/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/minus1.pass
+++ b/libcxx/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/minus1.pass
@@ -22,6 +22,7 @@
// Testing to make sure that the max length values are correctly inserted
#include <iostream>
+#include <cctype>
#include <sstream>
#include <cassert>
diff --git a/libcxx/test/std/localization/locales/locale/locale.types/locale.facet/tested_elsewhere.pass.cpp b/libcxx/test/std/localization/locales/locale/locale.types/locale.facet/tested_elsewhere.pass.cpp
new file mode 100644
index 00000000000..b58f5c55b64
--- /dev/null
+++ b/libcxx/test/std/localization/locales/locale/locale.types/locale.facet/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/libcxx/test/std/localization/locales/locale/locale.types/locale.id/tested_elsewhere.pass.cpp b/libcxx/test/std/localization/locales/locale/locale.types/locale.id/tested_elsewhere.pass.cpp
new file mode 100644
index 00000000000..b58f5c55b64
--- /dev/null
+++ b/libcxx/test/std/localization/locales/locale/locale.types/locale.id/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/libcxx/test/std/strings/c.strings/cwchar.pass.cpp b/libcxx/test/std/strings/c.strings/cwchar.pass.cpp
index 85b861017fd..780509c63a1 100644
--- a/libcxx/test/std/strings/c.strings/cwchar.pass.cpp
+++ b/libcxx/test/std/strings/c.strings/cwchar.pass.cpp
@@ -35,11 +35,8 @@ int main()
std::tm *tm = 0;
std::wint_t w = 0;
::FILE* fp = 0;
-#ifdef __APPLE__
- __darwin_va_list va;
-#else
- __builtin_va_list va;
-#endif
+ std::va_list va;
+
char* ns = 0;
wchar_t* ws = 0;
static_assert((std::is_same<decltype(std::fwprintf(fp, L"")), int>::value), "");
diff --git a/libcxx/test/std/thread/futures/futures.async/async.pass.cpp b/libcxx/test/std/thread/futures/futures.async/async.pass.cpp
index 5b1a60cabf7..20c16e79821 100644
--- a/libcxx/test/std/thread/futures/futures.async/async.pass.cpp
+++ b/libcxx/test/std/thread/futures/futures.async/async.pass.cpp
@@ -21,15 +21,22 @@
// future<typename result_of<F(Args...)>::type>
// async(launch policy, F&& f, Args&&... args);
+
#include <future>
+#include <atomic>
#include <memory>
#include <cassert>
+#include "test_macros.h"
+
typedef std::chrono::high_resolution_clock Clock;
typedef std::chrono::milliseconds ms;
+std::atomic_bool invoked = ATOMIC_VAR_INIT(false);
+
int f0()
{
+ invoked = true;
std::this_thread::sleep_for(ms(200));
return 3;
}
@@ -38,23 +45,27 @@ int i = 0;
int& f1()
{
+ invoked = true;
std::this_thread::sleep_for(ms(200));
return i;
}
void f2()
{
+ invoked = true;
std::this_thread::sleep_for(ms(200));
}
std::unique_ptr<int> f3(int j)
{
+ invoked = true;
std::this_thread::sleep_for(ms(200));
return std::unique_ptr<int>(new int(j));
}
std::unique_ptr<int> f4(std::unique_ptr<int>&& p)
{
+ invoked = true;
std::this_thread::sleep_for(ms(200));
return std::move(p);
}
@@ -65,136 +76,78 @@ void f5(int j)
throw j;
}
-int main()
-{
- {
- std::future<int> f = std::async(f0);
- std::this_thread::sleep_for(ms(300));
- Clock::time_point t0 = Clock::now();
- assert(f.get() == 3);
- Clock::time_point t1 = Clock::now();
- assert(t1-t0 < ms(100));
- }
- {
- std::future<int> f = std::async(std::launch::async, f0);
- std::this_thread::sleep_for(ms(300));
- Clock::time_point t0 = Clock::now();
- assert(f.get() == 3);
- Clock::time_point t1 = Clock::now();
- assert(t1-t0 < ms(100));
- }
- {
- std::future<int> f = std::async(std::launch::any, f0);
- std::this_thread::sleep_for(ms(300));
- Clock::time_point t0 = Clock::now();
- assert(f.get() == 3);
- Clock::time_point t1 = Clock::now();
- assert(t1-t0 < ms(100));
- }
- {
- std::future<int> f = std::async(std::launch::deferred, f0);
- std::this_thread::sleep_for(ms(300));
- Clock::time_point t0 = Clock::now();
- assert(f.get() == 3);
- Clock::time_point t1 = Clock::now();
- assert(t1-t0 > ms(100));
- }
+template <class Ret, class CheckLamdba, class ...Args>
+void test(CheckLamdba&& getAndCheckFn, bool IsDeferred, Args&&... args) {
+ // Reset global state.
+ invoked = false;
- {
- std::future<int&> f = std::async(f1);
- std::this_thread::sleep_for(ms(300));
- Clock::time_point t0 = Clock::now();
- assert(&f.get() == &i);
- Clock::time_point t1 = Clock::now();
- assert(t1-t0 < ms(100));
- }
- {
- std::future<int&> f = std::async(std::launch::async, f1);
- std::this_thread::sleep_for(ms(300));
- Clock::time_point t0 = Clock::now();
- assert(&f.get() == &i);
- Clock::time_point t1 = Clock::now();
- assert(t1-t0 < ms(100));
- }
- {
- std::future<int&> f = std::async(std::launch::any, f1);
- std::this_thread::sleep_for(ms(300));
- Clock::time_point t0 = Clock::now();
- assert(&f.get() == &i);
- Clock::time_point t1 = Clock::now();
- assert(t1-t0 < ms(100));
- }
- {
- std::future<int&> f = std::async(std::launch::deferred, f1);
- std::this_thread::sleep_for(ms(300));
- Clock::time_point t0 = Clock::now();
- assert(&f.get() == &i);
- Clock::time_point t1 = Clock::now();
- assert(t1-t0 > ms(100));
- }
+ // Create the future and wait
+ std::future<Ret> f = std::async(std::forward<Args>(args)...);
+ std::this_thread::sleep_for(ms(300));
- {
- std::future<void> f = std::async(f2);
- std::this_thread::sleep_for(ms(300));
- Clock::time_point t0 = Clock::now();
- f.get();
- Clock::time_point t1 = Clock::now();
- assert(t1-t0 < ms(100));
- }
- {
- std::future<void> f = std::async(std::launch::async, f2);
- std::this_thread::sleep_for(ms(300));
- Clock::time_point t0 = Clock::now();
- f.get();
- Clock::time_point t1 = Clock::now();
+ // Check that deferred async's have not invoked the function.
+ assert(invoked == !IsDeferred);
+
+ // Time the call to f.get() and check that the returned value matches
+ // what is expected.
+ Clock::time_point t0 = Clock::now();
+ assert(getAndCheckFn(f));
+ Clock::time_point t1 = Clock::now();
+
+ // If the async is deferred it should take more than 100ms, otherwise
+ // it should take less than 100ms.
+ if (IsDeferred) {
+ assert(t1-t0 > ms(100));
+ } else {
assert(t1-t0 < ms(100));
}
+}
+
+int main()
+{
+ // The default launch policy is implementation defined. libc++ defines
+ // it to be std::launch::async.
+ bool DefaultPolicyIsDeferred = false;
+ bool DPID = DefaultPolicyIsDeferred;
+
+ std::launch AnyPolicy = std::launch::async | std::launch::deferred;
+ LIBCPP_ASSERT(AnyPolicy == std::launch::any);
+
{
- std::future<void> f = std::async(std::launch::any, f2);
- std::this_thread::sleep_for(ms(300));
- Clock::time_point t0 = Clock::now();
- f.get();
- Clock::time_point t1 = Clock::now();
- assert(t1-t0 < ms(100));
+ auto checkInt = [](std::future<int>& f) { return f.get() == 3; };
+ test<int>(checkInt, DPID, f0);
+ test<int>(checkInt, false, std::launch::async, f0);
+ test<int>(checkInt, true, std::launch::deferred, f0);
+ test<int>(checkInt, DPID, AnyPolicy, f0);
}
{
- std::future<void> f = std::async(std::launch::deferred, f2);
- std::this_thread::sleep_for(ms(300));
- Clock::time_point t0 = Clock::now();
- f.get();
- Clock::time_point t1 = Clock::now();
- assert(t1-t0 > ms(100));
+ auto checkIntRef = [&](std::future<int&>& f) { return &f.get() == &i; };
+ test<int&>(checkIntRef, DPID, f1);
+ test<int&>(checkIntRef, false, std::launch::async, f1);
+ test<int&>(checkIntRef, true, std::launch::deferred, f1);
+ test<int&>(checkIntRef, DPID, AnyPolicy, f1);
}
-
{
- std::future<std::unique_ptr<int>> f = std::async(f3, 3);
- std::this_thread::sleep_for(ms(300));
- Clock::time_point t0 = Clock::now();
- assert(*f.get() == 3);
- Clock::time_point t1 = Clock::now();
- assert(t1-t0 < ms(100));
+ auto checkVoid = [](std::future<void>& f) { f.get(); return true; };
+ test<void>(checkVoid, DPID, f2);
+ test<void>(checkVoid, false, std::launch::async, f2);
+ test<void>(checkVoid, true, std::launch::deferred, f2);
+ test<void>(checkVoid, DPID, std::launch::any, f2);
}
-
{
- std::future<std::unique_ptr<int>> f =
- std::async(f4, std::unique_ptr<int>(new int(3)));
- std::this_thread::sleep_for(ms(300));
- Clock::time_point t0 = Clock::now();
- assert(*f.get() == 3);
- Clock::time_point t1 = Clock::now();
- assert(t1-t0 < ms(100));
+ using Ret = std::unique_ptr<int>;
+ auto checkUPtr = [](std::future<Ret>& f) { return *f.get() == 3; };
+ test<Ret>(checkUPtr, DPID, f3, 3);
+ test<Ret>(checkUPtr, DPID, f4, std::unique_ptr<int>(new int(3)));
}
-
{
std::future<void> f = std::async(f5, 3);
std::this_thread::sleep_for(ms(300));
try { f.get(); assert (false); } catch ( int ex ) {}
}
-
{
std::future<void> f = std::async(std::launch::deferred, f5, 3);
std::this_thread::sleep_for(ms(300));
try { f.get(); assert (false); } catch ( int ex ) {}
}
-
}
diff --git a/libcxx/test/std/thread/futures/futures.overview/launch.pass.cpp b/libcxx/test/std/thread/futures/futures.overview/launch.pass.cpp
index da54f7ee673..bf75fe4fa2c 100644
--- a/libcxx/test/std/thread/futures/futures.overview/launch.pass.cpp
+++ b/libcxx/test/std/thread/futures/futures.overview/launch.pass.cpp
@@ -15,28 +15,30 @@
// {
// async = 1,
// deferred = 2,
-// any = async | deferred
+// any = async | deferred /* EXTENSION */
// };
#include <future>
#include <cassert>
+#include "test_macros.h"
+
int main()
{
#ifdef _LIBCPP_HAS_NO_STRONG_ENUMS
- static_assert(static_cast<int>(std::launch::any) ==
+ LIBCPP_STATIC_ASSERT(static_cast<int>(std::launch::any) ==
(static_cast<int>(std::launch::async) | static_cast<int>(std::launch::deferred)), "");
#else
- static_assert(std::launch::any == (std::launch::async | std::launch::deferred), "");
+ LIBCPP_STATIC_ASSERT(std::launch::any == (std::launch::async | std::launch::deferred), "");
static_assert(std::launch(0) == (std::launch::async & std::launch::deferred), "");
- static_assert(std::launch::any == (std::launch::async ^ std::launch::deferred), "");
+ LIBCPP_STATIC_ASSERT(std::launch::any == (std::launch::async ^ std::launch::deferred), "");
static_assert(std::launch::deferred == ~std::launch::async, "");
std::launch x = std::launch::async;
x &= std::launch::deferred;
assert(x == std::launch(0));
x = std::launch::async;
x |= std::launch::deferred;
- assert(x == std::launch::any);
+ LIBCPP_ASSERT(x == std::launch::any);
x ^= std::launch::deferred;
assert(x == std::launch::async);
#endif
diff --git a/libcxx/test/support/asan_testing.h b/libcxx/test/support/asan_testing.h
index b1209de2313..85cd08b869e 100644
--- a/libcxx/test/support/asan_testing.h
+++ b/libcxx/test/support/asan_testing.h
@@ -15,7 +15,7 @@
#if TEST_HAS_FEATURE(address_sanitizer)
extern "C" int __sanitizer_verify_contiguous_container
( const void *beg, const void *mid, const void *end );
-
+
template <typename T, typename Alloc>
bool is_contiguous_container_asan_correct ( const std::vector<T, Alloc> &c )
{
OpenPOWER on IntegriCloud