diff options
-rw-r--r-- | compiler-rt/test/tsan/Darwin/gcd-groups-norace.mm | 18 | ||||
-rw-r--r-- | compiler-rt/test/tsan/Darwin/gcd-serial-queue-norace.mm | 18 | ||||
-rw-r--r-- | compiler-rt/test/tsan/Darwin/gcd-source-cancel.mm | 14 | ||||
-rw-r--r-- | compiler-rt/test/tsan/Darwin/gcd-source-cancel2.mm | 15 | ||||
-rw-r--r-- | compiler-rt/test/tsan/Darwin/gcd-source-event.mm | 14 | ||||
-rw-r--r-- | compiler-rt/test/tsan/Darwin/gcd-source-event2.mm | 15 | ||||
-rw-r--r-- | compiler-rt/test/tsan/Darwin/gcd-source-registration.mm | 14 | ||||
-rw-r--r-- | compiler-rt/test/tsan/Darwin/gcd-source-registration2.mm | 15 | ||||
-rw-r--r-- | compiler-rt/test/tsan/Darwin/gcd-sync-norace.mm | 19 | ||||
-rw-r--r-- | compiler-rt/test/tsan/Darwin/gcd-sync-race.mm | 18 | ||||
-rw-r--r-- | compiler-rt/test/tsan/Darwin/gcd-target-queue-norace.mm | 20 |
11 files changed, 97 insertions, 83 deletions
diff --git a/compiler-rt/test/tsan/Darwin/gcd-groups-norace.mm b/compiler-rt/test/tsan/Darwin/gcd-groups-norace.mm index e8501692fe8..0a8447e3aaa 100644 --- a/compiler-rt/test/tsan/Darwin/gcd-groups-norace.mm +++ b/compiler-rt/test/tsan/Darwin/gcd-groups-norace.mm @@ -1,15 +1,15 @@ -// RUN: %clang_tsan %s -o %t -framework Foundation +// RUN: %clang_tsan %s -o %t // RUN: %run %t 2>&1 | FileCheck %s -#import <Foundation/Foundation.h> +#include "dispatch/dispatch.h" -#import "../test.h" +#include <stdio.h> long global; int main() { - NSLog(@"Hello world."); - NSLog(@"addr=%p\n", &global); + fprintf(stderr, "Hello world.\n"); + dispatch_semaphore_t done = dispatch_semaphore_create(0); dispatch_queue_t q = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); global = 42; @@ -39,13 +39,11 @@ int main() { dispatch_group_notify(g, q, ^{ global = 48; - dispatch_sync(dispatch_get_main_queue(), ^{ - CFRunLoopStop(CFRunLoopGetCurrent()); - }); + dispatch_semaphore_signal(done); }); - CFRunLoopRun(); - NSLog(@"Done."); + dispatch_semaphore_wait(done, DISPATCH_TIME_FOREVER); + fprintf(stderr, "Done.\n"); } // CHECK: Hello world. diff --git a/compiler-rt/test/tsan/Darwin/gcd-serial-queue-norace.mm b/compiler-rt/test/tsan/Darwin/gcd-serial-queue-norace.mm index 8754b618df2..17fb5f1c73b 100644 --- a/compiler-rt/test/tsan/Darwin/gcd-serial-queue-norace.mm +++ b/compiler-rt/test/tsan/Darwin/gcd-serial-queue-norace.mm @@ -1,15 +1,15 @@ -// RUN: %clang_tsan %s -o %t -framework Foundation +// RUN: %clang_tsan %s -o %t // RUN: %run %t 2>&1 | FileCheck %s -#import <Foundation/Foundation.h> +#include "dispatch/dispatch.h" -#import "../test.h" +#include <stdio.h> long global; int main() { - NSLog(@"Hello world."); - NSLog(@"addr=%p\n", &global); + fprintf(stderr, "Hello world.\n"); + dispatch_semaphore_t done = dispatch_semaphore_create(0); dispatch_queue_t q1 = dispatch_queue_create("my.queue1", DISPATCH_QUEUE_CONCURRENT); dispatch_queue_t q2 = dispatch_queue_create("my.queue2", DISPATCH_QUEUE_SERIAL); @@ -26,13 +26,11 @@ int main() { } dispatch_barrier_async(q1, ^{ - dispatch_sync(dispatch_get_main_queue(), ^{ - CFRunLoopStop(CFRunLoopGetCurrent()); - }); + dispatch_semaphore_signal(done); }); - CFRunLoopRun(); - NSLog(@"Done."); + dispatch_semaphore_wait(done, DISPATCH_TIME_FOREVER); + fprintf(stderr, "Done.\n"); } // CHECK: Hello world. diff --git a/compiler-rt/test/tsan/Darwin/gcd-source-cancel.mm b/compiler-rt/test/tsan/Darwin/gcd-source-cancel.mm index 8aa6f106932..bc7282d319a 100644 --- a/compiler-rt/test/tsan/Darwin/gcd-source-cancel.mm +++ b/compiler-rt/test/tsan/Darwin/gcd-source-cancel.mm @@ -1,11 +1,15 @@ -// RUN: %clang_tsan %s -o %t -framework Foundation +// RUN: %clang_tsan %s -o %t // RUN: %run %t 2>&1 | FileCheck %s -#import <Foundation/Foundation.h> +#include "dispatch/dispatch.h" + +#include <stdio.h> long global; int main(int argc, const char *argv[]) { + dispatch_semaphore_t done = dispatch_semaphore_create(0); + dispatch_queue_t queue = dispatch_queue_create("my.queue", DISPATCH_QUEUE_CONCURRENT); @@ -19,15 +23,13 @@ int main(int argc, const char *argv[]) { dispatch_source_set_cancel_handler(source, ^{ fprintf(stderr, "global = %ld\n", global); - dispatch_sync(dispatch_get_main_queue(), ^{ - CFRunLoopStop(CFRunLoopGetCurrent()); - }); + dispatch_semaphore_signal(done); }); dispatch_resume(source); dispatch_cancel(source); - CFRunLoopRun(); + dispatch_semaphore_wait(done, DISPATCH_TIME_FOREVER); return 0; } diff --git a/compiler-rt/test/tsan/Darwin/gcd-source-cancel2.mm b/compiler-rt/test/tsan/Darwin/gcd-source-cancel2.mm index 92b31d7d0da..8ec2732dc60 100644 --- a/compiler-rt/test/tsan/Darwin/gcd-source-cancel2.mm +++ b/compiler-rt/test/tsan/Darwin/gcd-source-cancel2.mm @@ -1,19 +1,22 @@ -// RUN: %clang_tsan %s -o %t -framework Foundation +// RUN: %clang_tsan %s -o %t // RUN: %run %t 2>&1 | FileCheck %s -#import <Foundation/Foundation.h> +#include "dispatch/dispatch.h" + +#include <stdio.h> long global; +dispatch_semaphore_t done; void handler(void *arg) { fprintf(stderr, "global = %ld\n", global); - dispatch_sync(dispatch_get_main_queue(), ^{ - CFRunLoopStop(CFRunLoopGetCurrent()); - }); + dispatch_semaphore_signal(done); } int main(int argc, const char *argv[]) { + done = dispatch_semaphore_create(0); + dispatch_queue_t queue = dispatch_queue_create("my.queue", DISPATCH_QUEUE_CONCURRENT); @@ -29,7 +32,7 @@ int main(int argc, const char *argv[]) { dispatch_resume(source); dispatch_cancel(source); - CFRunLoopRun(); + dispatch_semaphore_wait(done, DISPATCH_TIME_FOREVER); return 0; } diff --git a/compiler-rt/test/tsan/Darwin/gcd-source-event.mm b/compiler-rt/test/tsan/Darwin/gcd-source-event.mm index e707b655100..f07dd1ea7b9 100644 --- a/compiler-rt/test/tsan/Darwin/gcd-source-event.mm +++ b/compiler-rt/test/tsan/Darwin/gcd-source-event.mm @@ -1,11 +1,15 @@ -// RUN: %clang_tsan %s -o %t -framework Foundation +// RUN: %clang_tsan %s -o %t // RUN: %run %t 2>&1 | FileCheck %s -#import <Foundation/Foundation.h> +#include "dispatch/dispatch.h" + +#include <stdio.h> long global; int main(int argc, const char *argv[]) { + dispatch_semaphore_t done = dispatch_semaphore_create(0); + dispatch_queue_t queue = dispatch_queue_create("my.queue", DISPATCH_QUEUE_CONCURRENT); @@ -19,14 +23,12 @@ int main(int argc, const char *argv[]) { dispatch_source_set_event_handler(source, ^{ fprintf(stderr, "global = %ld\n", global); - dispatch_sync(dispatch_get_main_queue(), ^{ - CFRunLoopStop(CFRunLoopGetCurrent()); - }); + dispatch_semaphore_signal(done); }); dispatch_resume(source); - CFRunLoopRun(); + dispatch_semaphore_wait(done, DISPATCH_TIME_FOREVER); return 0; } diff --git a/compiler-rt/test/tsan/Darwin/gcd-source-event2.mm b/compiler-rt/test/tsan/Darwin/gcd-source-event2.mm index b10e4741a3f..5c2b6b72cdc 100644 --- a/compiler-rt/test/tsan/Darwin/gcd-source-event2.mm +++ b/compiler-rt/test/tsan/Darwin/gcd-source-event2.mm @@ -1,19 +1,22 @@ -// RUN: %clang_tsan %s -o %t -framework Foundation +// RUN: %clang_tsan %s -o %t // RUN: %run %t 2>&1 | FileCheck %s -#import <Foundation/Foundation.h> +#include "dispatch/dispatch.h" + +#include <stdio.h> long global; +dispatch_semaphore_t done; void handler(void *arg) { fprintf(stderr, "global = %ld\n", global); - dispatch_sync(dispatch_get_main_queue(), ^{ - CFRunLoopStop(CFRunLoopGetCurrent()); - }); + dispatch_semaphore_signal(done); } int main(int argc, const char *argv[]) { + done = dispatch_semaphore_create(0); + dispatch_queue_t queue = dispatch_queue_create("my.queue", DISPATCH_QUEUE_CONCURRENT); @@ -28,7 +31,7 @@ int main(int argc, const char *argv[]) { dispatch_resume(source); - CFRunLoopRun(); + dispatch_semaphore_wait(done, DISPATCH_TIME_FOREVER); return 0; } diff --git a/compiler-rt/test/tsan/Darwin/gcd-source-registration.mm b/compiler-rt/test/tsan/Darwin/gcd-source-registration.mm index d6d339f94db..296c0055b15 100644 --- a/compiler-rt/test/tsan/Darwin/gcd-source-registration.mm +++ b/compiler-rt/test/tsan/Darwin/gcd-source-registration.mm @@ -1,11 +1,15 @@ -// RUN: %clang_tsan %s -o %t -framework Foundation +// RUN: %clang_tsan %s -o %t // RUN: %run %t 2>&1 | FileCheck %s -#import <Foundation/Foundation.h> +#include "dispatch/dispatch.h" + +#include <stdio.h> long global; int main(int argc, const char *argv[]) { + dispatch_semaphore_t done = dispatch_semaphore_create(0); + dispatch_queue_t queue = dispatch_queue_create("my.queue", DISPATCH_QUEUE_CONCURRENT); @@ -17,14 +21,12 @@ int main(int argc, const char *argv[]) { dispatch_source_set_registration_handler(source, ^{ fprintf(stderr, "global = %ld\n", global); - dispatch_sync(dispatch_get_main_queue(), ^{ - CFRunLoopStop(CFRunLoopGetCurrent()); - }); + dispatch_semaphore_signal(done); }); dispatch_resume(source); - CFRunLoopRun(); + dispatch_semaphore_wait(done, DISPATCH_TIME_FOREVER); return 0; } diff --git a/compiler-rt/test/tsan/Darwin/gcd-source-registration2.mm b/compiler-rt/test/tsan/Darwin/gcd-source-registration2.mm index 63657873cae..1e51f6f36b8 100644 --- a/compiler-rt/test/tsan/Darwin/gcd-source-registration2.mm +++ b/compiler-rt/test/tsan/Darwin/gcd-source-registration2.mm @@ -1,19 +1,22 @@ -// RUN: %clang_tsan %s -o %t -framework Foundation +// RUN: %clang_tsan %s -o %t // RUN: %run %t 2>&1 | FileCheck %s -#import <Foundation/Foundation.h> +#include "dispatch/dispatch.h" + +#include <stdio.h> long global; +dispatch_semaphore_t done; void handler(void *arg) { fprintf(stderr, "global = %ld\n", global); - dispatch_sync(dispatch_get_main_queue(), ^{ - CFRunLoopStop(CFRunLoopGetCurrent()); - }); + dispatch_semaphore_signal(done); } int main(int argc, const char *argv[]) { + done = dispatch_semaphore_create(0); + dispatch_queue_t queue = dispatch_queue_create("my.queue", DISPATCH_QUEUE_CONCURRENT); @@ -26,7 +29,7 @@ int main(int argc, const char *argv[]) { dispatch_resume(source); - CFRunLoopRun(); + dispatch_semaphore_wait(done, DISPATCH_TIME_FOREVER); return 0; } diff --git a/compiler-rt/test/tsan/Darwin/gcd-sync-norace.mm b/compiler-rt/test/tsan/Darwin/gcd-sync-norace.mm index 18bf9732079..38d9be384c3 100644 --- a/compiler-rt/test/tsan/Darwin/gcd-sync-norace.mm +++ b/compiler-rt/test/tsan/Darwin/gcd-sync-norace.mm @@ -1,30 +1,35 @@ -// RUN: %clang_tsan %s -o %t -framework Foundation +// RUN: %clang_tsan %s -o %t // RUN: %run %t 2>&1 | FileCheck %s -#import <Foundation/Foundation.h> +#include "dispatch/dispatch.h" + +#include <stdio.h> long global; static const long nIter = 1000; int main() { - NSLog(@"Hello world."); + fprintf(stderr, "Hello world.\n"); + dispatch_semaphore_t done = dispatch_semaphore_create(0); + + dispatch_queue_t serial_q = dispatch_queue_create("my.queue", DISPATCH_QUEUE_SERIAL); global = 42; for (int i = 0; i < nIter; i++) { dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ - dispatch_sync(dispatch_get_main_queue(), ^{ + dispatch_sync(serial_q, ^{ global = i; if (i == nIter - 1) { - CFRunLoopStop(CFRunLoopGetCurrent()); + dispatch_semaphore_signal(done); } }); }); } - CFRunLoopRun(); - NSLog(@"Done."); + dispatch_semaphore_wait(done, DISPATCH_TIME_FOREVER); + fprintf(stderr, "Done.\n"); } // CHECK: Hello world. diff --git a/compiler-rt/test/tsan/Darwin/gcd-sync-race.mm b/compiler-rt/test/tsan/Darwin/gcd-sync-race.mm index b7f3266dc09..5ee7761d076 100644 --- a/compiler-rt/test/tsan/Darwin/gcd-sync-race.mm +++ b/compiler-rt/test/tsan/Darwin/gcd-sync-race.mm @@ -1,15 +1,15 @@ -// RUN: %clang_tsan %s -o %t -framework Foundation +// RUN: %clang_tsan %s -o %t // RUN: %deflake %run %t 2>&1 | FileCheck %s -#import <Foundation/Foundation.h> - -#import "../test.h" +#include "dispatch/dispatch.h" +#include "../test.h" long global; int main() { - NSLog(@"Hello world."); + fprintf(stderr, "Hello world.\n"); print_address("addr=", 1, &global); + dispatch_semaphore_t done = dispatch_semaphore_create(0); barrier_init(&barrier, 2); dispatch_queue_t q1 = dispatch_queue_create("my.queue1", DISPATCH_QUEUE_CONCURRENT); @@ -27,14 +27,12 @@ int main() { barrier_wait(&barrier); global = 44; - dispatch_sync(dispatch_get_main_queue(), ^{ - CFRunLoopStop(CFRunLoopGetCurrent()); - }); + dispatch_semaphore_signal(done); }); }); - CFRunLoopRun(); - NSLog(@"Done."); + dispatch_semaphore_wait(done, DISPATCH_TIME_FOREVER); + fprintf(stderr, "Done.\n"); } // CHECK: Hello world. diff --git a/compiler-rt/test/tsan/Darwin/gcd-target-queue-norace.mm b/compiler-rt/test/tsan/Darwin/gcd-target-queue-norace.mm index fbfa65806bd..b5361c81f60 100644 --- a/compiler-rt/test/tsan/Darwin/gcd-target-queue-norace.mm +++ b/compiler-rt/test/tsan/Darwin/gcd-target-queue-norace.mm @@ -1,11 +1,14 @@ -// RUN: %clang_tsan %s -o %t -framework Foundation +// RUN: %clang_tsan %s -o %t // RUN: %run %t 2>&1 | FileCheck %s -#import <Foundation/Foundation.h> +#include "dispatch/dispatch.h" + +#include <stdio.h> long global; int main(int argc, const char *argv[]) { + dispatch_semaphore_t done = dispatch_semaphore_create(0); dispatch_queue_t target_queue = dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL); dispatch_queue_t q1 = dispatch_queue_create(NULL, DISPATCH_QUEUE_CONCURRENT); dispatch_queue_t q2 = dispatch_queue_create(NULL, DISPATCH_QUEUE_CONCURRENT); @@ -17,25 +20,22 @@ int main(int argc, const char *argv[]) { global++; if (global == 200000) { - dispatch_sync(dispatch_get_main_queue(), ^{ - CFRunLoopStop(CFRunLoopGetCurrent()); - }); + dispatch_semaphore_signal(done); } }); dispatch_async(q2, ^{ global++; if (global == 200000) { - dispatch_sync(dispatch_get_main_queue(), ^{ - CFRunLoopStop(CFRunLoopGetCurrent()); - }); + dispatch_semaphore_signal(done); } }); } - CFRunLoopRun(); - NSLog(@"Done."); + dispatch_semaphore_wait(done, DISPATCH_TIME_FOREVER); + fprintf(stderr, "Done.\n"); return 0; } // CHECK-NOT: WARNING: ThreadSanitizer +// CHECK: Done. |