summaryrefslogtreecommitdiff
path: root/test/tsan/Darwin
diff options
context:
space:
mode:
authorJulian Lettner <jlettner@apple.com>2019-04-06 01:41:40 +0000
committerJulian Lettner <jlettner@apple.com>2019-04-06 01:41:40 +0000
commit761390f20ad424b7f9793ff56e58634f78925002 (patch)
treed08e2c265e2ff05f5b6072ec64b4262a557d943d /test/tsan/Darwin
parentdb1a2496faed9556011204ea0dbafb8407366236 (diff)
downloadcompiler-rt-761390f20ad424b7f9793ff56e58634f78925002.tar.gz
[TSan][libdispatch] Remove Darwin-only version of fully-ported tests
Remove 10 tests that already have a copy in tsan/libdispatch, without dependencies on Darwin-specifis. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@357832 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/tsan/Darwin')
-rw-r--r--test/tsan/Darwin/dispatch_main.mm38
-rw-r--r--test/tsan/Darwin/dispatch_once_deadlock.mm41
-rw-r--r--test/tsan/Darwin/gcd-apply-race.mm30
-rw-r--r--test/tsan/Darwin/gcd-apply.mm48
-rw-r--r--test/tsan/Darwin/gcd-groups-destructor.mm43
-rw-r--r--test/tsan/Darwin/gcd-groups-leave.mm56
-rw-r--r--test/tsan/Darwin/gcd-groups-stress.mm43
-rw-r--r--test/tsan/Darwin/gcd-once.mm55
-rw-r--r--test/tsan/Darwin/gcd-semaphore-norace.mm29
-rw-r--r--test/tsan/Darwin/gcd-suspend.mm45
10 files changed, 0 insertions, 428 deletions
diff --git a/test/tsan/Darwin/dispatch_main.mm b/test/tsan/Darwin/dispatch_main.mm
deleted file mode 100644
index f4c1e44bc..000000000
--- a/test/tsan/Darwin/dispatch_main.mm
+++ /dev/null
@@ -1,38 +0,0 @@
-// Check that we don't crash when dispatch_main calls pthread_exit which
-// quits the main thread.
-
-// RUN: %clang_tsan %s -o %t -framework Foundation
-// RUN: %run %t 2>&1 | FileCheck %s
-
-#import <Foundation/Foundation.h>
-
-int main() {
- fprintf(stderr,"Hello world");
-
- dispatch_queue_t q = dispatch_queue_create("my.queue", DISPATCH_QUEUE_SERIAL);
-
- dispatch_async(q, ^{
- fprintf(stderr,"1");
- });
-
- dispatch_async(q, ^{
- fprintf(stderr,"2");
- });
-
- dispatch_async(q, ^{
- fprintf(stderr,"3");
-
- dispatch_async(dispatch_get_main_queue(), ^{
- fprintf(stderr,"Done.");
- sleep(1);
- exit(0);
- });
- });
-
- dispatch_main();
-}
-
-// CHECK: Hello world
-// CHECK: Done.
-// CHECK-NOT: WARNING: ThreadSanitizer
-// CHECK-NOT: CHECK failed
diff --git a/test/tsan/Darwin/dispatch_once_deadlock.mm b/test/tsan/Darwin/dispatch_once_deadlock.mm
deleted file mode 100644
index e109f64a8..000000000
--- a/test/tsan/Darwin/dispatch_once_deadlock.mm
+++ /dev/null
@@ -1,41 +0,0 @@
-// Check that calling dispatch_once from a report callback works.
-
-// RUN: %clang_tsan %s -o %t -framework Foundation
-// RUN: not %run %t 2>&1 | FileCheck %s
-
-#import <Foundation/Foundation.h>
-#import <pthread.h>
-
-long g = 0;
-long h = 0;
-void f() {
- static dispatch_once_t onceToken;
- dispatch_once(&onceToken, ^{
- g++;
- });
- h++;
-}
-
-extern "C" void __tsan_on_report() {
- fprintf(stderr, "Report.\n");
- f();
-}
-
-int main() {
- fprintf(stderr, "Hello world.\n");
-
- f();
-
- pthread_mutex_t mutex = {0};
- pthread_mutex_lock(&mutex);
-
- fprintf(stderr, "g = %ld.\n", g);
- fprintf(stderr, "h = %ld.\n", h);
- fprintf(stderr, "Done.\n");
-}
-
-// CHECK: Hello world.
-// CHECK: Report.
-// CHECK: g = 1
-// CHECK: h = 2
-// CHECK: Done.
diff --git a/test/tsan/Darwin/gcd-apply-race.mm b/test/tsan/Darwin/gcd-apply-race.mm
deleted file mode 100644
index a7bf663a9..000000000
--- a/test/tsan/Darwin/gcd-apply-race.mm
+++ /dev/null
@@ -1,30 +0,0 @@
-// RUN: %clang_tsan %s -o %t -framework Foundation
-// RUN: %deflake %run %t 2>&1 | FileCheck %s
-
-#import <Foundation/Foundation.h>
-
-#import "../test.h"
-
-long global;
-
-int main(int argc, const char *argv[]) {
- barrier_init(&barrier, 2);
- fprintf(stderr, "start\n");
-
- // Warm up GCD (workaround for macOS Sierra where dispatch_apply might run single-threaded).
- dispatch_sync(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ });
-
- dispatch_queue_t q = dispatch_queue_create("my.queue", DISPATCH_QUEUE_CONCURRENT);
- dispatch_apply(2, q, ^(size_t i) {
- global = i;
- barrier_wait(&barrier);
- });
-
- fprintf(stderr, "done\n");
- return 0;
-}
-
-// CHECK: start
-// CHECK: WARNING: ThreadSanitizer: data race
-// CHECK: Location is global 'global'
-// CHECK: done
diff --git a/test/tsan/Darwin/gcd-apply.mm b/test/tsan/Darwin/gcd-apply.mm
deleted file mode 100644
index d9d256203..000000000
--- a/test/tsan/Darwin/gcd-apply.mm
+++ /dev/null
@@ -1,48 +0,0 @@
-// RUN: %clang_tsan %s -o %t -framework Foundation
-// RUN: %run %t 2>&1 | FileCheck %s
-
-#import <Foundation/Foundation.h>
-
-#import "../test.h"
-
-long global;
-long array[2];
-
-void callback(void *context, size_t i) {
- long n = global;
- array[i] = n + i;
- barrier_wait(&barrier);
-}
-
-int main(int argc, const char *argv[]) {
- barrier_init(&barrier, 2);
- fprintf(stderr, "start\n");
-
- // Warm up GCD (workaround for macOS Sierra where dispatch_apply might run single-threaded).
- dispatch_sync(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ });
-
- dispatch_queue_t q = dispatch_queue_create("my.queue", DISPATCH_QUEUE_CONCURRENT);
-
- global = 42;
-
- dispatch_apply(100, q, ^(size_t i) {
- long n = global;
- array[i] = n + i;
- barrier_wait(&barrier);
- });
-
- for (int i = 0; i < 100; i++) {
- fprintf(stderr, "array[%d] = %ld\n", i, array[i]);
- }
-
- global = 43;
-
- dispatch_apply_f(100, q, NULL, &callback);
-
- fprintf(stderr, "done\n");
- return 0;
-}
-
-// CHECK: start
-// CHECK: done
-// CHECK-NOT: WARNING: ThreadSanitizer
diff --git a/test/tsan/Darwin/gcd-groups-destructor.mm b/test/tsan/Darwin/gcd-groups-destructor.mm
deleted file mode 100644
index 05c65c04b..000000000
--- a/test/tsan/Darwin/gcd-groups-destructor.mm
+++ /dev/null
@@ -1,43 +0,0 @@
-// RUN: %clangxx_tsan %s -o %t -framework Foundation
-// RUN: %run %t 2>&1 | FileCheck %s
-
-#import <Foundation/Foundation.h>
-
-#import <memory>
-#import <stdatomic.h>
-
-_Atomic(long) destructor_counter = 0;
-
-struct MyStruct {
- virtual ~MyStruct() {
- usleep(10000);
- atomic_fetch_add_explicit(&destructor_counter, 1, memory_order_relaxed);
- }
-};
-
-int main(int argc, const char *argv[]) {
- fprintf(stderr, "Hello world.\n");
-
- dispatch_queue_t q = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
- dispatch_group_t g = dispatch_group_create();
-
- for (int i = 0; i < 100; i++) {
- std::shared_ptr<MyStruct> shared(new MyStruct());
-
- dispatch_group_async(g, q, ^{
- shared.get(); // just to make sure the object is captured by the block
- });
- }
-
- dispatch_group_wait(g, DISPATCH_TIME_FOREVER);
-
- if (destructor_counter != 100) {
- abort();
- }
-
- fprintf(stderr, "Done.\n");
-}
-
-// CHECK: Hello world.
-// CHECK-NOT: WARNING: ThreadSanitizer
-// CHECK: Done.
diff --git a/test/tsan/Darwin/gcd-groups-leave.mm b/test/tsan/Darwin/gcd-groups-leave.mm
deleted file mode 100644
index 49fd8e210..000000000
--- a/test/tsan/Darwin/gcd-groups-leave.mm
+++ /dev/null
@@ -1,56 +0,0 @@
-// RUN: %clang_tsan %s -o %t -framework Foundation
-// RUN: %run %t 2>&1 | FileCheck %s
-
-#import <Foundation/Foundation.h>
-
-#import "../test.h"
-
-dispatch_semaphore_t sem;
-
-long global;
-long global2;
-
-void callback(void *context) {
- global2 = 48;
- barrier_wait(&barrier);
-
- dispatch_semaphore_signal(sem);
-}
-
-int main() {
- fprintf(stderr, "Hello world.\n");
- barrier_init(&barrier, 2);
-
- dispatch_queue_t q = dispatch_queue_create("my.queue", DISPATCH_QUEUE_CONCURRENT);
- dispatch_group_t g = dispatch_group_create();
- sem = dispatch_semaphore_create(0);
-
- dispatch_group_enter(g);
- dispatch_async(q, ^{
- global = 47;
- dispatch_group_leave(g);
- barrier_wait(&barrier);
- });
- dispatch_group_notify(g, q, ^{
- global = 48;
- barrier_wait(&barrier);
-
- dispatch_semaphore_signal(sem);
- });
- dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
-
- dispatch_group_enter(g);
- dispatch_async(q, ^{
- global2 = 47;
- dispatch_group_leave(g);
- barrier_wait(&barrier);
- });
- dispatch_group_notify_f(g, q, NULL, &callback);
- dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
-
- fprintf(stderr, "Done.\n");
-}
-
-// CHECK: Hello world.
-// CHECK-NOT: WARNING: ThreadSanitizer
-// CHECK: Done.
diff --git a/test/tsan/Darwin/gcd-groups-stress.mm b/test/tsan/Darwin/gcd-groups-stress.mm
deleted file mode 100644
index cfe4deb0a..000000000
--- a/test/tsan/Darwin/gcd-groups-stress.mm
+++ /dev/null
@@ -1,43 +0,0 @@
-// RUN: %clang_tsan %s -o %t -framework Foundation
-// RUN: %run %t 2>&1 | FileCheck %s
-
-#import <Foundation/Foundation.h>
-
-void notify_callback(void *context) {
- // Do nothing.
-}
-
-int main() {
- NSLog(@"Hello world.");
-
- dispatch_queue_t q = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
-
- for (int i = 0; i < 300000; i++) {
- dispatch_group_t g = dispatch_group_create();
- dispatch_group_enter(g);
- dispatch_async(q, ^{
- dispatch_group_leave(g);
- });
- dispatch_group_notify(g, q, ^{
- // Do nothing.
- });
- dispatch_release(g);
- }
-
- for (int i = 0; i < 300000; i++) {
- dispatch_group_t g = dispatch_group_create();
- dispatch_group_enter(g);
- dispatch_async(q, ^{
- dispatch_group_leave(g);
- });
- dispatch_group_notify_f(g, q, NULL, &notify_callback);
- dispatch_release(g);
- }
-
- NSLog(@"Done.");
-}
-
-// CHECK: Hello world.
-// CHECK: Done.
-// CHECK-NOT: WARNING: ThreadSanitizer
-// CHECK-NOT: CHECK failed
diff --git a/test/tsan/Darwin/gcd-once.mm b/test/tsan/Darwin/gcd-once.mm
deleted file mode 100644
index 70e588aaf..000000000
--- a/test/tsan/Darwin/gcd-once.mm
+++ /dev/null
@@ -1,55 +0,0 @@
-// RUN: %clang_tsan %s -o %t -framework Foundation
-// RUN: %run %t 2>&1 | FileCheck %s
-
-#import <Foundation/Foundation.h>
-
-#import "../test.h"
-
-static const long kNumThreads = 4;
-
-long global;
-long global2;
-
-static dispatch_once_t once_token;
-static dispatch_once_t once_token2;
-
-void f(void *) {
- global2 = 42;
- usleep(100000);
-}
-
-void *Thread(void *a) {
- barrier_wait(&barrier);
-
- dispatch_once(&once_token, ^{
- global = 42;
- usleep(100000);
- });
- long x = global;
-
- dispatch_once_f(&once_token2, NULL, f);
- long x2 = global2;
-
- fprintf(stderr, "global = %ld\n", x);
- fprintf(stderr, "global2 = %ld\n", x2);
- return 0;
-}
-
-int main() {
- fprintf(stderr, "Hello world.\n");
- barrier_init(&barrier, kNumThreads);
-
- pthread_t t[kNumThreads];
- for (int i = 0; i < kNumThreads; i++) {
- pthread_create(&t[i], 0, Thread, 0);
- }
- for (int i = 0; i < kNumThreads; i++) {
- pthread_join(t[i], 0);
- }
-
- fprintf(stderr, "Done.\n");
-}
-
-// CHECK: Hello world.
-// CHECK: Done.
-// CHECK-NOT: WARNING: ThreadSanitizer
diff --git a/test/tsan/Darwin/gcd-semaphore-norace.mm b/test/tsan/Darwin/gcd-semaphore-norace.mm
deleted file mode 100644
index fd5d14655..000000000
--- a/test/tsan/Darwin/gcd-semaphore-norace.mm
+++ /dev/null
@@ -1,29 +0,0 @@
-// RUN: %clang_tsan %s -o %t -framework Foundation
-// RUN: %run %t 2>&1 | FileCheck %s
-
-#import <Foundation/Foundation.h>
-
-long global;
-
-int main() {
- NSLog(@"Hello world.");
-
- global = 42;
-
- dispatch_semaphore_t sem = dispatch_semaphore_create(0);
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-
- global = 43;
- dispatch_semaphore_signal(sem);
- });
-
- dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
- global = 44;
-
- NSLog(@"Done.");
- return 0;
-}
-
-// CHECK: Hello world.
-// CHECK: Done.
-// CHECK-NOT: WARNING: ThreadSanitizer
diff --git a/test/tsan/Darwin/gcd-suspend.mm b/test/tsan/Darwin/gcd-suspend.mm
deleted file mode 100644
index 561e7c0b7..000000000
--- a/test/tsan/Darwin/gcd-suspend.mm
+++ /dev/null
@@ -1,45 +0,0 @@
-// RUN: %clang_tsan %s -o %t -framework Foundation
-// RUN: %run %t 2>&1 | FileCheck %s
-
-#import <Foundation/Foundation.h>
-
-long my_global = 0;
-
-int main(int argc, const char *argv[]) {
- fprintf(stderr, "Hello world.\n");
-
- dispatch_queue_t q1 = dispatch_queue_create("queue1", NULL);
- dispatch_queue_t q2 = dispatch_queue_create("queue2", NULL);
- dispatch_group_t g = dispatch_group_create();
-
- dispatch_sync(q1, ^{
- dispatch_suspend(q1);
- dispatch_async(q2, ^{
- my_global++;
- dispatch_resume(q1);
- });
- });
-
- dispatch_sync(q1, ^{
- my_global++;
- });
-
- dispatch_sync(q1, ^{
- dispatch_suspend(q1);
- dispatch_group_enter(g);
- dispatch_async(q1,^{ my_global++; });
- dispatch_async(q1,^{ my_global++; });
- dispatch_async(q1,^{ my_global++; dispatch_group_leave(g); });
- my_global++;
- dispatch_resume(q1);
- });
-
- dispatch_group_wait(g, DISPATCH_TIME_FOREVER);
-
- fprintf(stderr, "Done.\n");
- return 0;
-}
-
-// CHECK: Hello world.
-// CHECK-NOT: WARNING: ThreadSanitizer
-// CHECK: Done.