]> git.proxmox.com Git - rustc.git/blame - src/compiler-rt/test/tsan/Darwin/gcd-async-race.mm
New upstream version 1.12.0+dfsg1
[rustc.git] / src / compiler-rt / test / tsan / Darwin / gcd-async-race.mm
CommitLineData
3157f602 1// RUN: %clang_tsan %s -o %t -framework Foundation
5bcae85e 2// RUN: %env_tsan_opts=ignore_interceptors_accesses=1 %deflake %run %t 2>&1 | FileCheck %s
3157f602
XL
3
4#import <Foundation/Foundation.h>
5
6#import "../test.h"
7
8long global;
9
10int main() {
11 NSLog(@"Hello world.");
5bcae85e 12 print_address("addr=", 1, &global);
3157f602
XL
13 barrier_init(&barrier, 2);
14
15 global = 42;
16 dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
17 global = 43;
18 barrier_wait(&barrier);
19 });
20
21 dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
22 barrier_wait(&barrier);
23 global = 44;
24
25 dispatch_sync(dispatch_get_main_queue(), ^{
26 CFRunLoopStop(CFRunLoopGetCurrent());
27 });
28 });
29
30 CFRunLoopRun();
31 NSLog(@"Done.");
32}
33
34// CHECK: Hello world.
35// CHECK: addr=[[ADDR:0x[0-9,a-f]+]]
36// CHECK: WARNING: ThreadSanitizer: data race
5bcae85e 37// CHECK: Location is global 'global' {{(of size 8 )?}}at [[ADDR]] (gcd-async-race.mm.tmp+0x{{[0-9,a-f]+}})
3157f602 38// CHECK: Done.