blob: f21cfdedbce1d73ce5268fec2b184eb0d3b4c9f8 [file] [log] [blame]
Pirama Arumuga Nainar799172d2016-03-03 15:50:30 -08001// RUN: %clang_tsan %s -o %t -framework Foundation
2// RUN: %run %t 2>&1
3
4#import <Foundation/Foundation.h>
5
6long global;
7
8static const long nIter = 1000;
9
10int main() {
11 NSLog(@"Hello world.");
12
13 global = 42;
14 for (int i = 0; i < nIter; i++) {
15 dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
16 dispatch_sync(dispatch_get_main_queue(), ^{
17 global = i;
18
19 if (i == nIter - 1) {
20 CFRunLoopStop(CFRunLoopGetCurrent());
21 }
22 });
23 });
24 }
25
26 CFRunLoopRun();
27 NSLog(@"Done.");
28}
29
30// CHECK: Hello world.
31// CHECK: Done.
32// CHECK-NOT: WARNING: ThreadSanitizer