1 //===-- tsan_thread.cpp ---------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file is a part of ThreadSanitizer (TSan), a race detector.
11 //===----------------------------------------------------------------------===//
12 #include "tsan_test_util.h"
13 #include "gtest/gtest.h"
15 TEST_F(ThreadSanitizer
, ThreadSync
) {
26 TEST_F(ThreadSanitizer
, ThreadDetach1
) {
27 ScopedThread
t1(true);
32 TEST_F(ThreadSanitizer
, ThreadDetach2
) {
39 static void *thread_alot_func(void *arg
) {
46 TEST(DISABLED_SLOW_ThreadSanitizer
, ThreadALot
) {
47 const int kThreads
= 70000;
48 const int kAlive
= 1000;
49 pthread_t threads
[kAlive
] = {};
50 for (int i
= 0; i
< kThreads
; i
++) {
51 if (threads
[i
% kAlive
])
52 pthread_join(threads
[i
% kAlive
], 0);
53 pthread_create(&threads
[i
% kAlive
], 0, thread_alot_func
, 0);
55 for (int i
= 0; i
< kAlive
; i
++) {
56 pthread_join(threads
[i
], 0);