diff options
Diffstat (limited to 'test/tsan/Darwin/libcxx-future.mm')
-rw-r--r-- | test/tsan/Darwin/libcxx-future.mm | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/test/tsan/Darwin/libcxx-future.mm b/test/tsan/Darwin/libcxx-future.mm new file mode 100644 index 000000000..f004d7b38 --- /dev/null +++ b/test/tsan/Darwin/libcxx-future.mm @@ -0,0 +1,30 @@ +// RUN: %clangxx_tsan %s -o %t +// RUN: %env_tsan_opts=ignore_interceptors_accesses=1 %run %t 2>&1 | FileCheck %s + +#include <iostream> +#include <future> +#include <vector> + +int main(int argc, const char *argv[]) { + fprintf(stderr, "Hello world.\n"); + + auto my_task = [] { return 42; }; + + std::vector<std::thread> threads; + + for (int i = 0; i < 1000; i++) { + std::packaged_task<int(void)> task(my_task); + std::future<int> future = task.get_future(); + threads.push_back(std::thread(std::move(task))); + } + + for (auto &t : threads) { + t.join(); + } + + fprintf(stderr, "Done.\n"); +} + +// CHECK: Hello world. +// CHECK-NOT: WARNING: ThreadSanitizer +// CHECK: Done. |