1// RUN: %clangxx_tsan -O1 %s -o %t
2// RUN: %deflake %env_tsan_opts=force_background_thread=0:verbosity=1:memory_limit_mb=1000 %run %t 2>&1 | FileCheck %s --implicit-check-not "memory flush check"
3// RUN: %deflake %env_tsan_opts=force_background_thread=1:verbosity=1:memory_limit_mb=1000 %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK,THREAD
4// RUN: %deflake %env_tsan_opts=force_background_thread=0:verbosity=1:memory_limit_mb=1000 %run %t 1 2>&1 | FileCheck %s --check-prefixes=CHECK,THREAD
5
6// Fails with: objc[99984]: task_restartable_ranges_register failed (result 0x2e: (os/kern) service not supported)
7// UNSUPPORTED: darwin
8
9#include "test.h"
10
11void *Thread(void *a) { return nullptr; }
12
13int main(int argc, char *argv[]) {
14 if (argc > 1) {
15 pthread_t t;
16 pthread_create(newthread: &t, attr: nullptr, start_routine: Thread, arg: nullptr);
17 void *p;
18 pthread_join(th: t, thread_return: &p);
19 }
20 sleep(seconds: 3);
21 return 1;
22}
23
24// CHECK: Running under ThreadSanitizer
25// THREAD: ThreadSanitizer: memory flush check
26

source code of compiler-rt/test/tsan/force_background_thread.cpp