Revert "[lldb][test] Remove compiler version check and use regex" (#124101)
[llvm-project.git] / compiler-rt / test / tsan / libdispatch / groups-norace.c
blobed6311debdc872d69c52b45be5101cd0689aad49
1 // RUN: %clang_tsan %s -o %t
2 // RUN: %run %t 2>&1 | FileCheck %s --implicit-check-not='ThreadSanitizer'
4 #include "dispatch/dispatch.h"
6 #include <stdio.h>
8 long global;
10 int main() {
11 fprintf(stderr, "Hello world.\n");
12 dispatch_semaphore_t done = dispatch_semaphore_create(0);
14 dispatch_queue_t q = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
15 global = 42;
17 dispatch_group_t g = dispatch_group_create();
18 dispatch_group_async(g, q, ^{
19 global = 43;
20 });
21 dispatch_group_wait(g, DISPATCH_TIME_FOREVER);
23 global = 44;
25 dispatch_group_enter(g);
26 dispatch_async(q, ^{
27 global = 45;
28 dispatch_group_leave(g);
29 });
30 dispatch_group_wait(g, DISPATCH_TIME_FOREVER);
32 global = 46;
34 dispatch_group_enter(g);
35 dispatch_async(q, ^{
36 global = 47;
37 dispatch_group_leave(g);
38 });
39 dispatch_group_notify(g, q, ^{
40 global = 48;
42 dispatch_semaphore_signal(done);
43 });
45 dispatch_semaphore_wait(done, DISPATCH_TIME_FOREVER);
46 fprintf(stderr, "Done.\n");
49 // CHECK: Hello world.
50 // CHECK: Done.