Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / tsan / Darwin / xpc-cancel.mm
blobac7aed08c16c4229ffd6346113d51d8a536932ba
1 // RUN: %clang_tsan %s -o %t -framework Foundation
2 // RUN: %run %t 2>&1 | FileCheck %s
4 // UNSUPPORTED: ios
6 #import <Foundation/Foundation.h>
7 #import <xpc/xpc.h>
9 long global;
11 int main(int argc, const char *argv[]) {
12   fprintf(stderr, "Hello world.\n");
14   dispatch_queue_t server_q = dispatch_queue_create("server.queue", DISPATCH_QUEUE_CONCURRENT);
15   xpc_connection_t server_conn = xpc_connection_create(NULL, server_q);
17   xpc_connection_set_event_handler(server_conn, ^(xpc_object_t client) {
18     if (client == XPC_ERROR_CONNECTION_INTERRUPTED || client == XPC_ERROR_CONNECTION_INVALID) {
19       global = 43;
20       
21       dispatch_async(dispatch_get_main_queue(), ^{
22         CFRunLoopStop(CFRunLoopGetCurrent());
23       });
24     }
25   });
26   xpc_connection_resume(server_conn);
27   
28   global = 42;
29   
30   xpc_connection_cancel(server_conn);
31   
32   CFRunLoopRun();
34   fprintf(stderr, "Done.\n");
37 // CHECK: Hello world.
38 // CHECK-NOT: WARNING: ThreadSanitizer
39 // CHECK: Done.