summaryrefslogtreecommitdiff
path: root/test/tsan/Darwin
diff options
context:
space:
mode:
authorJulian Lettner <jlettner@apple.com>2019-04-12 23:07:00 +0000
committerJulian Lettner <jlettner@apple.com>2019-04-12 23:07:00 +0000
commit8fa46946cfbe3eb0e23dde603799e9af586fe374 (patch)
treeb2407b138abd575e0f1c162d1ff7949b930424b7 /test/tsan/Darwin
parent27203330a45da31e6db3163eceda5f6038fcc4dc (diff)
downloadcompiler-rt-8fa46946cfbe3eb0e23dde603799e9af586fe374.tar.gz
[TSan][libdispatch] Move libdispatch tests out of Darwin folder
The libdispatch tests are now not tied to Darwin anymore. Move them to their own platform-independent folder. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@358316 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/tsan/Darwin')
-rw-r--r--test/tsan/Darwin/gcd-after.mm42
-rw-r--r--test/tsan/Darwin/gcd-async-norace.mm27
-rw-r--r--test/tsan/Darwin/gcd-async-race.mm37
-rw-r--r--test/tsan/Darwin/gcd-barrier-race.mm47
-rw-r--r--test/tsan/Darwin/gcd-barrier.mm47
-rw-r--r--test/tsan/Darwin/gcd-blocks.mm37
-rw-r--r--test/tsan/Darwin/gcd-fd.mm62
-rw-r--r--test/tsan/Darwin/gcd-groups-norace.mm51
-rw-r--r--test/tsan/Darwin/gcd-io-barrier-race.mm54
-rw-r--r--test/tsan/Darwin/gcd-io-barrier.mm50
-rw-r--r--test/tsan/Darwin/gcd-io-cleanup.mm58
-rw-r--r--test/tsan/Darwin/gcd-io-race.mm53
-rw-r--r--test/tsan/Darwin/gcd-io.mm119
-rw-r--r--test/tsan/Darwin/gcd-serial-queue-norace.mm38
-rw-r--r--test/tsan/Darwin/gcd-source-cancel.mm38
-rw-r--r--test/tsan/Darwin/gcd-source-cancel2.mm41
-rw-r--r--test/tsan/Darwin/gcd-source-event.mm37
-rw-r--r--test/tsan/Darwin/gcd-source-event2.mm40
-rw-r--r--test/tsan/Darwin/gcd-source-registration.mm35
-rw-r--r--test/tsan/Darwin/gcd-source-registration2.mm38
-rw-r--r--test/tsan/Darwin/gcd-sync-norace.mm37
-rw-r--r--test/tsan/Darwin/gcd-sync-race.mm42
-rw-r--r--test/tsan/Darwin/gcd-target-queue-norace.mm41
23 files changed, 0 insertions, 1071 deletions
diff --git a/test/tsan/Darwin/gcd-after.mm b/test/tsan/Darwin/gcd-after.mm
deleted file mode 100644
index 59281e76d..000000000
--- a/test/tsan/Darwin/gcd-after.mm
+++ /dev/null
@@ -1,42 +0,0 @@
-// RUN: %clang_tsan %s -o %t
-// RUN: %run %t 2>&1 | FileCheck %s
-
-#include "dispatch/dispatch.h"
-
-#include <stdio.h>
-
-long my_global;
-long my_global2;
-dispatch_semaphore_t done;
-
-void callback(void *context) {
- my_global2 = 42;
-
- dispatch_semaphore_signal(done);
-}
-
-int main(int argc, const char *argv[]) {
- fprintf(stderr, "start\n");
- done = dispatch_semaphore_create(0);
-
- dispatch_queue_t q = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
-
- my_global = 10;
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(10 * NSEC_PER_MSEC)), q, ^{
- my_global = 42;
-
- dispatch_semaphore_signal(done);
- });
-
- my_global2 = 10;
- dispatch_after_f(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(10 * NSEC_PER_MSEC)), q, NULL, &callback);
-
- dispatch_semaphore_wait(done, DISPATCH_TIME_FOREVER);
- dispatch_semaphore_wait(done, DISPATCH_TIME_FOREVER);
- fprintf(stderr, "done\n");
- return 0;
-}
-
-// CHECK: start
-// CHECK: done
-// CHECK-NOT: WARNING: ThreadSanitizer
diff --git a/test/tsan/Darwin/gcd-async-norace.mm b/test/tsan/Darwin/gcd-async-norace.mm
deleted file mode 100644
index c3b603579..000000000
--- a/test/tsan/Darwin/gcd-async-norace.mm
+++ /dev/null
@@ -1,27 +0,0 @@
-// RUN: %clang_tsan %s -o %t
-// RUN: %run %t 2>&1 | FileCheck %s
-
-#include "dispatch/dispatch.h"
-
-#include <stdio.h>
-
-long global;
-
-int main() {
- fprintf(stderr, "Hello world.\n");
- dispatch_semaphore_t done = dispatch_semaphore_create(0);
-
- global = 42;
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- global = 43;
-
- dispatch_semaphore_signal(done);
- });
-
- dispatch_semaphore_wait(done, DISPATCH_TIME_FOREVER);
- fprintf(stderr, "Done.\n");
-}
-
-// CHECK: Hello world.
-// CHECK: Done.
-// CHECK-NOT: WARNING: ThreadSanitizer
diff --git a/test/tsan/Darwin/gcd-async-race.mm b/test/tsan/Darwin/gcd-async-race.mm
deleted file mode 100644
index ecb2a8007..000000000
--- a/test/tsan/Darwin/gcd-async-race.mm
+++ /dev/null
@@ -1,37 +0,0 @@
-// RUN: %clang_tsan %s -o %t
-// RUN: %deflake %run %t 2>&1 | FileCheck %s
-
-#include "dispatch/dispatch.h"
-
-#include "../test.h"
-
-long global;
-
-int main() {
- fprintf(stderr, "Hello world.\n");
- print_address("addr=", 1, &global);
- dispatch_semaphore_t done = dispatch_semaphore_create(0);
- barrier_init(&barrier, 2);
-
- global = 42;
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- global = 43;
- barrier_wait(&barrier);
- });
-
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- barrier_wait(&barrier);
- global = 44;
-
- dispatch_semaphore_signal(done);
- });
-
- dispatch_semaphore_wait(done, DISPATCH_TIME_FOREVER);
- fprintf(stderr, "Done.\n");
-}
-
-// CHECK: Hello world.
-// CHECK: addr=[[ADDR:0x[0-9,a-f]+]]
-// CHECK: WARNING: ThreadSanitizer: data race
-// CHECK: Location is global 'global' {{(of size 8 )?}}at [[ADDR]] (gcd-async-race.mm.tmp+0x{{[0-9,a-f]+}})
-// CHECK: Done.
diff --git a/test/tsan/Darwin/gcd-barrier-race.mm b/test/tsan/Darwin/gcd-barrier-race.mm
deleted file mode 100644
index 417898a77..000000000
--- a/test/tsan/Darwin/gcd-barrier-race.mm
+++ /dev/null
@@ -1,47 +0,0 @@
-// RUN: %clang_tsan %s -o %t
-// RUN: %deflake %run %t 2>&1 | FileCheck %s
-
-#include "dispatch/dispatch.h"
-
-#include "../test.h"
-
-long global;
-
-int main() {
- 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 q = dispatch_queue_create("my.queue", DISPATCH_QUEUE_CONCURRENT);
- dispatch_queue_t bgq = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
-
- dispatch_barrier_sync(q, ^{
- global = 42;
- });
-
- dispatch_async(bgq, ^{
- dispatch_sync(q, ^{
- global = 43;
- barrier_wait(&barrier);
- });
- });
-
- dispatch_async(bgq, ^{
- dispatch_sync(q, ^{
- barrier_wait(&barrier);
- global = 44;
-
- dispatch_semaphore_signal(done);
- });
- });
-
- dispatch_semaphore_wait(done, DISPATCH_TIME_FOREVER);
- fprintf(stderr, "Done.\n");
-}
-
-// CHECK: Hello world.
-// CHECK: addr=[[ADDR:0x[0-9,a-f]+]]
-// CHECK: WARNING: ThreadSanitizer: data race
-// CHECK: Location is global 'global' {{(of size 8 )?}}at [[ADDR]] (gcd-barrier-race.mm.tmp+0x{{[0-9,a-f]+}})
-// CHECK: Done.
diff --git a/test/tsan/Darwin/gcd-barrier.mm b/test/tsan/Darwin/gcd-barrier.mm
deleted file mode 100644
index 52b115ed3..000000000
--- a/test/tsan/Darwin/gcd-barrier.mm
+++ /dev/null
@@ -1,47 +0,0 @@
-// RUN: %clang_tsan %s -o %t
-// RUN: %run %t 2>&1 | FileCheck %s
-
-#include "dispatch/dispatch.h"
-
-#include "../test.h"
-
-long global;
-
-int main() {
- fprintf(stderr, "Hello world.\n");
- dispatch_semaphore_t done = dispatch_semaphore_create(0);
- barrier_init(&barrier, 2);
-
- dispatch_queue_t q = dispatch_queue_create("my.queue", DISPATCH_QUEUE_CONCURRENT);
- dispatch_queue_t bgq = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
-
- dispatch_async(bgq, ^{
- dispatch_sync(q, ^{
- global = 42;
- });
- barrier_wait(&barrier);
- });
-
- dispatch_async(bgq, ^{
- barrier_wait(&barrier);
- dispatch_barrier_sync(q, ^{
- global = 43;
- });
-
- dispatch_async(bgq, ^{
- barrier_wait(&barrier);
- global = 44;
- });
-
- barrier_wait(&barrier);
-
- dispatch_semaphore_signal(done);
- });
-
- dispatch_semaphore_wait(done, DISPATCH_TIME_FOREVER);
- fprintf(stderr, "Done.\n");
-}
-
-// CHECK: Hello world.
-// CHECK: Done.
-// CHECK-NOT: WARNING: ThreadSanitizer
diff --git a/test/tsan/Darwin/gcd-blocks.mm b/test/tsan/Darwin/gcd-blocks.mm
deleted file mode 100644
index 413b22085..000000000
--- a/test/tsan/Darwin/gcd-blocks.mm
+++ /dev/null
@@ -1,37 +0,0 @@
-// RUN: %clang_tsan %s -o %t
-// RUN: %run %t 2>&1 | FileCheck %s
-
-#include "dispatch/dispatch.h"
-
-#include <stdio.h>
-#include <assert.h>
-
-int main() {
- fprintf(stderr, "start\n");
- dispatch_semaphore_t done = dispatch_semaphore_create(0);
-
- dispatch_queue_t background_q = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
- dispatch_queue_t serial_q = dispatch_queue_create("my.queue", DISPATCH_QUEUE_SERIAL);
- assert(background_q != serial_q);
-
- dispatch_async(background_q, ^{
- __block long block_var = 0;
-
- dispatch_sync(serial_q, ^{
- block_var = 42;
- });
-
- fprintf(stderr, "block_var = %ld\n", block_var);
-
- dispatch_semaphore_signal(done);
- });
-
- dispatch_semaphore_wait(done, DISPATCH_TIME_FOREVER);
- fprintf(stderr, "done\n");
-}
-
-// CHECK: start
-// CHECK: block_var = 42
-// CHECK: done
-// CHECK-NOT: WARNING: ThreadSanitizer
-// CHECK-NOT: CHECK failed
diff --git a/test/tsan/Darwin/gcd-fd.mm b/test/tsan/Darwin/gcd-fd.mm
deleted file mode 100644
index 9a77a3f3c..000000000
--- a/test/tsan/Darwin/gcd-fd.mm
+++ /dev/null
@@ -1,62 +0,0 @@
-// RUN: %clang_tsan %s -o %t
-// RUN: %run %t 2>&1 | FileCheck %s
-
-#include <dispatch/dispatch.h>
-
-#include <stdio.h>
-
-long my_global = 0;
-
-int main(int argc, const char *argv[]) {
- fprintf(stderr, "Hello world.\n");
-
- dispatch_queue_t queue = dispatch_queue_create("my.queue", DISPATCH_QUEUE_SERIAL);
- dispatch_semaphore_t sem = dispatch_semaphore_create(0);
-
- const char *path = tempnam(NULL, "libdispatch-fd-");
-
- dispatch_io_t channel = dispatch_io_create_with_path(DISPATCH_IO_STREAM, path, O_CREAT | O_WRONLY,
- 0666, queue, ^(int error) { });
- dispatch_io_set_high_water(channel, 1);
-
- char buf[1000];
- dispatch_data_t data = dispatch_data_create(buf, sizeof(buf), NULL, DISPATCH_DATA_DESTRUCTOR_DEFAULT);
-
- my_global++;
- dispatch_io_write(channel, 0, data, queue, ^(bool done, dispatch_data_t remainingData, int error) {
- my_global++;
- dispatch_async(queue, ^{
- my_global++;
- if (done) {
- dispatch_semaphore_signal(sem);
- }
- });
- });
-
- dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
- my_global++;
- dispatch_io_close(channel, 0);
- channel = dispatch_io_create_with_path(DISPATCH_IO_STREAM, path, O_RDONLY,
- 0, queue, ^(int error) { });
- dispatch_io_set_high_water(channel, 1);
-
- my_global++;
- dispatch_io_read(channel, 0, SIZE_MAX, queue, ^(bool done, dispatch_data_t remainingData, int error) {
- my_global++;
- dispatch_async(queue, ^{
- my_global++;
- if (done) {
- dispatch_semaphore_signal(sem);
- }
- });
- });
-
- dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
- my_global++;
- fprintf(stderr, "Done.\n");
- return 0;
-}
-
-// CHECK: Hello world.
-// CHECK-NOT: WARNING: ThreadSanitizer
-// CHECK: Done.
diff --git a/test/tsan/Darwin/gcd-groups-norace.mm b/test/tsan/Darwin/gcd-groups-norace.mm
deleted file mode 100644
index 0a8447e3a..000000000
--- a/test/tsan/Darwin/gcd-groups-norace.mm
+++ /dev/null
@@ -1,51 +0,0 @@
-// RUN: %clang_tsan %s -o %t
-// RUN: %run %t 2>&1 | FileCheck %s
-
-#include "dispatch/dispatch.h"
-
-#include <stdio.h>
-
-long global;
-
-int main() {
- 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;
-
- dispatch_group_t g = dispatch_group_create();
- dispatch_group_async(g, q, ^{
- global = 43;
- });
- dispatch_group_wait(g, DISPATCH_TIME_FOREVER);
-
- global = 44;
-
- dispatch_group_enter(g);
- dispatch_async(q, ^{
- global = 45;
- dispatch_group_leave(g);
- });
- dispatch_group_wait(g, DISPATCH_TIME_FOREVER);
-
- global = 46;
-
- dispatch_group_enter(g);
- dispatch_async(q, ^{
- global = 47;
- dispatch_group_leave(g);
- });
- dispatch_group_notify(g, q, ^{
- global = 48;
-
- dispatch_semaphore_signal(done);
- });
-
- dispatch_semaphore_wait(done, DISPATCH_TIME_FOREVER);
- fprintf(stderr, "Done.\n");
-}
-
-// CHECK: Hello world.
-// CHECK: Done.
-// CHECK-NOT: WARNING: ThreadSanitizer
diff --git a/test/tsan/Darwin/gcd-io-barrier-race.mm b/test/tsan/Darwin/gcd-io-barrier-race.mm
deleted file mode 100644
index 150f4037f..000000000
--- a/test/tsan/Darwin/gcd-io-barrier-race.mm
+++ /dev/null
@@ -1,54 +0,0 @@
-// RUN: %clang_tsan %s -o %t
-// RUN: %deflake %run %t 2>&1 | FileCheck %s
-
-#include <dispatch/dispatch.h>
-
-#import "../test.h"
-
-dispatch_queue_t queue;
-dispatch_data_t data;
-dispatch_semaphore_t sem;
-const char *path;
-
-long my_global = 0;
-
-int main(int argc, const char *argv[]) {
- fprintf(stderr, "Hello world.\n");
- print_address("addr=", 1, &my_global);
- barrier_init(&barrier, 2);
-
- queue = dispatch_queue_create("my.queue", DISPATCH_QUEUE_CONCURRENT);
- sem = dispatch_semaphore_create(0);
- path = tempnam(NULL, "libdispatch-io-barrier-race-");
- char buf[1000];
- data = dispatch_data_create(buf, sizeof(buf), NULL, DISPATCH_DATA_DESTRUCTOR_DEFAULT);
-
- dispatch_io_t channel = dispatch_io_create_with_path(DISPATCH_IO_STREAM, path, O_CREAT | O_WRONLY, 0666, queue, ^(int error) { });
- if (! channel) abort();
- dispatch_io_set_high_water(channel, 1);
-
- dispatch_io_write(channel, 0, data, queue, ^(bool done, dispatch_data_t remainingData, int error) {
- if (error) abort();
- my_global = 42;
- barrier_wait(&barrier);
- });
-
- dispatch_io_barrier(channel, ^{
- barrier_wait(&barrier);
- my_global = 43;
-
- dispatch_semaphore_signal(sem);
- });
-
- dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
- dispatch_io_close(channel, 0);
-
- fprintf(stderr, "Done.\n");
- return 0;
-}
-
-// CHECK: Hello world.
-// CHECK: addr=[[ADDR:0x[0-9,a-f]+]]
-// CHECK: WARNING: ThreadSanitizer: data race
-// CHECK: Location is global 'my_global' {{(of size 8 )?}}at [[ADDR]] (gcd-io-barrier-race.mm.tmp+0x{{[0-9,a-f]+}})
-// CHECK: Done.
diff --git a/test/tsan/Darwin/gcd-io-barrier.mm b/test/tsan/Darwin/gcd-io-barrier.mm
deleted file mode 100644
index 849644e44..000000000
--- a/test/tsan/Darwin/gcd-io-barrier.mm
+++ /dev/null
@@ -1,50 +0,0 @@
-// RUN: %clang_tsan %s -o %t
-// RUN: %run %t 2>&1 | FileCheck %s
-
-#include <dispatch/dispatch.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-
-dispatch_queue_t queue;
-dispatch_data_t data;
-dispatch_semaphore_t sem;
-const char *path;
-
-long my_global = 0;
-
-int main(int argc, const char *argv[]) {
- fprintf(stderr, "Hello world.\n");
-
- queue = dispatch_queue_create("my.queue", DISPATCH_QUEUE_CONCURRENT);
- sem = dispatch_semaphore_create(0);
- path = tempnam(NULL, "libdispatch-io-barrier");
- char buf[1000];
- data = dispatch_data_create(buf, sizeof(buf), NULL, DISPATCH_DATA_DESTRUCTOR_DEFAULT);
-
- dispatch_io_t channel = dispatch_io_create_with_path(DISPATCH_IO_STREAM, path, O_CREAT | O_WRONLY, 0666, queue, ^(int error) { });
- if (! channel) abort();
- dispatch_io_set_high_water(channel, 1);
-
- for (int i = 0; i < 1000; i++) {
- dispatch_io_barrier(channel, ^{
- my_global = 42;
- });
- }
-
- dispatch_io_barrier(channel, ^{
- my_global = 43;
-
- dispatch_semaphore_signal(sem);
- });
-
- dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
- dispatch_io_close(channel, 0);
-
- fprintf(stderr, "Done.\n");
- return 0;
-}
-
-// CHECK: Hello world.
-// CHECK-NOT: WARNING: ThreadSanitizer
-// CHECK: Done.
diff --git a/test/tsan/Darwin/gcd-io-cleanup.mm b/test/tsan/Darwin/gcd-io-cleanup.mm
deleted file mode 100644
index 3e1c9d78e..000000000
--- a/test/tsan/Darwin/gcd-io-cleanup.mm
+++ /dev/null
@@ -1,58 +0,0 @@
-// RUN: %clang_tsan %s -o %t
-// RUN: %run %t 2>&1 | FileCheck %s
-
-#include <dispatch/dispatch.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-
-long my_global = 0;
-
-int main(int argc, const char *argv[]) {
- fprintf(stderr, "Hello world.\n");
-
- dispatch_queue_t queue = dispatch_queue_create("my.queue", DISPATCH_QUEUE_CONCURRENT);
- dispatch_semaphore_t sem = dispatch_semaphore_create(0);
- const char *path = tempnam(NULL, "libdispatch-io-cleanup-");
- dispatch_io_t channel;
-
- dispatch_fd_t fd = open(path, O_CREAT | O_WRONLY, 0666);
- my_global++;
- channel = dispatch_io_create(DISPATCH_IO_STREAM, fd, queue, ^(int error) {
- my_global++;
- dispatch_semaphore_signal(sem);
- });
- if (! channel) abort();
- my_global++;
- dispatch_io_close(channel, 0);
- dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
-
- my_global++;
- channel = dispatch_io_create_with_path(DISPATCH_IO_STREAM, path, O_CREAT | O_WRONLY, 0666, queue, ^(int error) {
- my_global++;
- dispatch_semaphore_signal(sem);
- });
- if (! channel) abort();
- my_global++;
- dispatch_io_close(channel, 0);
- dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
-
- my_global++;
- dispatch_io_t other_channel = dispatch_io_create_with_path(DISPATCH_IO_STREAM, path, O_CREAT | O_WRONLY, 0666, queue, ^(int error) { });
- channel = dispatch_io_create_with_io(DISPATCH_IO_STREAM, other_channel, queue, ^(int error) {
- my_global++;
- dispatch_semaphore_signal(sem);
- });
- if (! channel) abort();
- my_global++;
- dispatch_io_close(channel, 0);
- dispatch_io_close(other_channel, 0);
- dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
-
- fprintf(stderr, "Done.\n");
- return 0;
-}
-
-// CHECK: Hello world.
-// CHECK-NOT: WARNING: ThreadSanitizer
-// CHECK: Done.
diff --git a/test/tsan/Darwin/gcd-io-race.mm b/test/tsan/Darwin/gcd-io-race.mm
deleted file mode 100644
index 7d7f60385..000000000
--- a/test/tsan/Darwin/gcd-io-race.mm
+++ /dev/null
@@ -1,53 +0,0 @@
-// RUN: %clang_tsan %s -o %t
-// RUN: %deflake %run %t 2>&1 | FileCheck %s
-
-// REQUIRES: disabled
-
-#import "../test.h"
-
-dispatch_queue_t queue;
-dispatch_data_t data;
-dispatch_semaphore_t sem;
-const char *path;
-
-long my_global = 0;
-
-int main(int argc, const char *argv[]) {
- fprintf(stderr, "Hello world.\n");
- print_address("addr=", 1, &my_global);
- barrier_init(&barrier, 2);
-
- queue = dispatch_queue_create("my.queue", DISPATCH_QUEUE_CONCURRENT);
- sem = dispatch_semaphore_create(0);
- path = tempnam(NULL, "libdispatch-io-race");
- char buf[1000];
- data = dispatch_data_create(buf, sizeof(buf), NULL, DISPATCH_DATA_DESTRUCTOR_DEFAULT);
-
- dispatch_io_t channel = dispatch_io_create_with_path(DISPATCH_IO_STREAM, path, O_CREAT | O_WRONLY, 0666, queue, ^(int error) { });
- if (! channel) abort();
- dispatch_io_set_high_water(channel, 1);
-
- dispatch_io_write(channel, 0, data, queue, ^(bool done, dispatch_data_t remainingData, int error) {
- my_global = 42;
- barrier_wait(&barrier);
- });
-
- dispatch_io_write(channel, 0, data, queue, ^(bool done, dispatch_data_t remainingData, int error) {
- barrier_wait(&barrier);
- my_global = 42;
-
- dispatch_semaphore_signal(sem);
- });
-
- dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
- dispatch_io_close(channel, 0);
-
- fprintf(stderr, "Done.\n");
- return 0;
-}
-
-// CHECK: Hello world.
-// CHECK: addr=[[ADDR:0x[0-9,a-f]+]]
-// CHECK: WARNING: ThreadSanitizer: data race
-// CHECK: Location is global 'my_global' {{(of size 8 )?}}at [[ADDR]] (gcd-io-race.mm.tmp+0x{{[0-9,a-f]+}})
-// CHECK: Done.
diff --git a/test/tsan/Darwin/gcd-io.mm b/test/tsan/Darwin/gcd-io.mm
deleted file mode 100644
index 6302e743d..000000000
--- a/test/tsan/Darwin/gcd-io.mm
+++ /dev/null
@@ -1,119 +0,0 @@
-// RUN: %clang_tsan %s -o %t
-// RUN: %run %t 2>&1 | FileCheck %s
-
-#include <dispatch/dispatch.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-
-dispatch_queue_t queue;
-dispatch_data_t data;
-dispatch_semaphore_t sem;
-const char *path;
-
-long my_global = 0;
-
-void test_dispatch_io_write() {
- dispatch_io_t channel = dispatch_io_create_with_path(DISPATCH_IO_STREAM, path, O_CREAT | O_WRONLY, 0666, queue, ^(int error) { });
- if (! channel) abort();
- dispatch_io_set_high_water(channel, 1);
-
- my_global++;
- dispatch_io_write(channel, 0, data, queue, ^(bool done, dispatch_data_t remainingData, int error) {
- if (error) abort();
- my_global++;
- dispatch_async(queue, ^{
- my_global++;
- if (done) {
- dispatch_semaphore_signal(sem);
- }
- });
- });
-
- dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
- my_global++;
- dispatch_io_close(channel, 0);
-}
-
-void test_dispatch_write() {
- dispatch_fd_t fd = open(path, O_CREAT | O_WRONLY, 0666);
- if (fd == -1) abort();
-
- my_global++;
- dispatch_write(fd, data, queue, ^(dispatch_data_t data, int error) {
- if (error) abort();
- my_global++;
- dispatch_async(queue, ^{
- my_global++;
-
- dispatch_semaphore_signal(sem);
- });
- });
-
- dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
- my_global++;
- close(fd);
-}
-
-void test_dispatch_io_read() {
- dispatch_io_t channel = dispatch_io_create_with_path(DISPATCH_IO_STREAM, path, O_RDONLY,
- 0, queue, ^(int error) { });
- dispatch_io_set_high_water(channel, 1);
-
- my_global++;
- dispatch_io_read(channel, 0, SIZE_MAX, queue, ^(bool done, dispatch_data_t remainingData, int error) {
- if (error) abort();
- my_global++;
- dispatch_async(queue, ^{
- my_global++;
- if (done) {
- dispatch_semaphore_signal(sem);
- }
- });
- });
-
- dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
- my_global++;
- dispatch_io_close(channel, 0);
-}
-
-void test_dispatch_read() {
- dispatch_fd_t fd = open(path, O_RDONLY, 0);
- if (fd == -1) abort();
-
- my_global++;
- dispatch_read(fd, SIZE_MAX, queue, ^(dispatch_data_t data, int error) {
- if (error) abort();
- my_global++;
- dispatch_async(queue, ^{
- my_global++;
- dispatch_semaphore_signal(sem);
- });
- });
-
- dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
- my_global++;
- close(fd);
-}
-
-int main(int argc, const char *argv[]) {
- fprintf(stderr, "Hello world.\n");
-
- queue = dispatch_queue_create("my.queue", DISPATCH_QUEUE_SERIAL);
- sem = dispatch_semaphore_create(0);
- path = tempnam(NULL, "libdispatch-io-");
- char buf[1000];
- data = dispatch_data_create(buf, sizeof(buf), NULL, DISPATCH_DATA_DESTRUCTOR_DEFAULT);
-
- test_dispatch_io_write();
- test_dispatch_write();
- test_dispatch_io_read();
- test_dispatch_read();
-
- fprintf(stderr, "Done.\n");
- return 0;
-}
-
-// CHECK: Hello world.
-// CHECK-NOT: WARNING: ThreadSanitizer
-// CHECK: Done.
diff --git a/test/tsan/Darwin/gcd-serial-queue-norace.mm b/test/tsan/Darwin/gcd-serial-queue-norace.mm
deleted file mode 100644
index 17fb5f1c7..000000000
--- a/test/tsan/Darwin/gcd-serial-queue-norace.mm
+++ /dev/null
@@ -1,38 +0,0 @@
-// RUN: %clang_tsan %s -o %t
-// RUN: %run %t 2>&1 | FileCheck %s
-
-#include "dispatch/dispatch.h"
-
-#include <stdio.h>
-
-long global;
-
-int main() {
- 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);
-
- global = 42;
- for (int i = 0; i < 10; i++) {
- dispatch_async(q1, ^{
- for (int i = 0; i < 100; i++) {
- dispatch_sync(q2, ^{
- global++;
- });
- }
- });
- }
-
- dispatch_barrier_async(q1, ^{
- dispatch_semaphore_signal(done);
- });
-
- dispatch_semaphore_wait(done, DISPATCH_TIME_FOREVER);
- fprintf(stderr, "Done.\n");
-}
-
-// CHECK: Hello world.
-// CHECK: Done.
-// CHECK-NOT: WARNING: ThreadSanitizer
diff --git a/test/tsan/Darwin/gcd-source-cancel.mm b/test/tsan/Darwin/gcd-source-cancel.mm
deleted file mode 100644
index bc7282d31..000000000
--- a/test/tsan/Darwin/gcd-source-cancel.mm
+++ /dev/null
@@ -1,38 +0,0 @@
-// RUN: %clang_tsan %s -o %t
-// RUN: %run %t 2>&1 | FileCheck %s
-
-#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);
-
- dispatch_source_t source =
- dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue);
-
- dispatch_source_set_timer(source, dispatch_walltime(NULL, 0), 1e9, 5);
-
- global = 42;
-
- dispatch_source_set_cancel_handler(source, ^{
- fprintf(stderr, "global = %ld\n", global);
-
- dispatch_semaphore_signal(done);
- });
-
- dispatch_resume(source);
- dispatch_cancel(source);
-
- dispatch_semaphore_wait(done, DISPATCH_TIME_FOREVER);
-
- return 0;
-}
-
-// CHECK: global = 42
-// CHECK-NOT: WARNING: ThreadSanitizer
diff --git a/test/tsan/Darwin/gcd-source-cancel2.mm b/test/tsan/Darwin/gcd-source-cancel2.mm
deleted file mode 100644
index 8ec2732dc..000000000
--- a/test/tsan/Darwin/gcd-source-cancel2.mm
+++ /dev/null
@@ -1,41 +0,0 @@
-// RUN: %clang_tsan %s -o %t
-// RUN: %run %t 2>&1 | FileCheck %s
-
-#include "dispatch/dispatch.h"
-
-#include <stdio.h>
-
-long global;
-dispatch_semaphore_t done;
-
-void handler(void *arg) {
- fprintf(stderr, "global = %ld\n", global);
-
- 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);
-
- dispatch_source_t source =
- dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue);
-
- dispatch_source_set_timer(source, dispatch_walltime(NULL, 0), 1e9, 5);
-
- global = 42;
-
- dispatch_source_set_cancel_handler_f(source, &handler);
-
- dispatch_resume(source);
- dispatch_cancel(source);
-
- dispatch_semaphore_wait(done, DISPATCH_TIME_FOREVER);
-
- return 0;
-}
-
-// CHECK: global = 42
-// CHECK-NOT: WARNING: ThreadSanitizer
diff --git a/test/tsan/Darwin/gcd-source-event.mm b/test/tsan/Darwin/gcd-source-event.mm
deleted file mode 100644
index f07dd1ea7..000000000
--- a/test/tsan/Darwin/gcd-source-event.mm
+++ /dev/null
@@ -1,37 +0,0 @@
-// RUN: %clang_tsan %s -o %t
-// RUN: %run %t 2>&1 | FileCheck %s
-
-#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);
-
- dispatch_source_t source =
- dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue);
-
- dispatch_source_set_timer(source, dispatch_walltime(NULL, 0), 1e9, 5);
-
- global = 42;
-
- dispatch_source_set_event_handler(source, ^{
- fprintf(stderr, "global = %ld\n", global);
-
- dispatch_semaphore_signal(done);
- });
-
- dispatch_resume(source);
-
- dispatch_semaphore_wait(done, DISPATCH_TIME_FOREVER);
-
- return 0;
-}
-
-// CHECK: global = 42
-// CHECK-NOT: WARNING: ThreadSanitizer
diff --git a/test/tsan/Darwin/gcd-source-event2.mm b/test/tsan/Darwin/gcd-source-event2.mm
deleted file mode 100644
index 5c2b6b72c..000000000
--- a/test/tsan/Darwin/gcd-source-event2.mm
+++ /dev/null
@@ -1,40 +0,0 @@
-// RUN: %clang_tsan %s -o %t
-// RUN: %run %t 2>&1 | FileCheck %s
-
-#include "dispatch/dispatch.h"
-
-#include <stdio.h>
-
-long global;
-dispatch_semaphore_t done;
-
-void handler(void *arg) {
- fprintf(stderr, "global = %ld\n", global);
-
- 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);
-
- dispatch_source_t source =
- dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue);
-
- dispatch_source_set_timer(source, dispatch_walltime(NULL, 0), 1e9, 5);
-
- global = 42;
-
- dispatch_source_set_event_handler_f(source, &handler);
-
- dispatch_resume(source);
-
- dispatch_semaphore_wait(done, DISPATCH_TIME_FOREVER);
-
- return 0;
-}
-
-// CHECK: global = 42
-// CHECK-NOT: WARNING: ThreadSanitizer
diff --git a/test/tsan/Darwin/gcd-source-registration.mm b/test/tsan/Darwin/gcd-source-registration.mm
deleted file mode 100644
index 296c0055b..000000000
--- a/test/tsan/Darwin/gcd-source-registration.mm
+++ /dev/null
@@ -1,35 +0,0 @@
-// RUN: %clang_tsan %s -o %t
-// RUN: %run %t 2>&1 | FileCheck %s
-
-#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);
-
- dispatch_source_t source =
- dispatch_source_create(DISPATCH_SOURCE_TYPE_SIGNAL, SIGHUP, 0, queue);
-
- global = 42;
-
- dispatch_source_set_registration_handler(source, ^{
- fprintf(stderr, "global = %ld\n", global);
-
- dispatch_semaphore_signal(done);
- });
-
- dispatch_resume(source);
-
- dispatch_semaphore_wait(done, DISPATCH_TIME_FOREVER);
-
- return 0;
-}
-
-// CHECK: global = 42
-// CHECK-NOT: WARNING: ThreadSanitizer
diff --git a/test/tsan/Darwin/gcd-source-registration2.mm b/test/tsan/Darwin/gcd-source-registration2.mm
deleted file mode 100644
index 1e51f6f36..000000000
--- a/test/tsan/Darwin/gcd-source-registration2.mm
+++ /dev/null
@@ -1,38 +0,0 @@
-// RUN: %clang_tsan %s -o %t
-// RUN: %run %t 2>&1 | FileCheck %s
-
-#include "dispatch/dispatch.h"
-
-#include <stdio.h>
-
-long global;
-dispatch_semaphore_t done;
-
-void handler(void *arg) {
- fprintf(stderr, "global = %ld\n", global);
-
- 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);
-
- dispatch_source_t source =
- dispatch_source_create(DISPATCH_SOURCE_TYPE_SIGNAL, SIGHUP, 0, queue);
-
- global = 42;
-
- dispatch_source_set_registration_handler_f(source, handler);
-
- dispatch_resume(source);
-
- dispatch_semaphore_wait(done, DISPATCH_TIME_FOREVER);
-
- return 0;
-}
-
-// CHECK: global = 42
-// CHECK-NOT: WARNING: ThreadSanitizer
diff --git a/test/tsan/Darwin/gcd-sync-norace.mm b/test/tsan/Darwin/gcd-sync-norace.mm
deleted file mode 100644
index 38d9be384..000000000
--- a/test/tsan/Darwin/gcd-sync-norace.mm
+++ /dev/null
@@ -1,37 +0,0 @@
-// RUN: %clang_tsan %s -o %t
-// RUN: %run %t 2>&1 | FileCheck %s
-
-#include "dispatch/dispatch.h"
-
-#include <stdio.h>
-
-long global;
-
-static const long nIter = 1000;
-
-int main() {
- 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(serial_q, ^{
- global = i;
-
- if (i == nIter - 1) {
- dispatch_semaphore_signal(done);
- }
- });
- });
- }
-
- dispatch_semaphore_wait(done, DISPATCH_TIME_FOREVER);
- fprintf(stderr, "Done.\n");
-}
-
-// CHECK: Hello world.
-// CHECK: Done.
-// CHECK-NOT: WARNING: ThreadSanitizer
diff --git a/test/tsan/Darwin/gcd-sync-race.mm b/test/tsan/Darwin/gcd-sync-race.mm
deleted file mode 100644
index 5ee7761d0..000000000
--- a/test/tsan/Darwin/gcd-sync-race.mm
+++ /dev/null
@@ -1,42 +0,0 @@
-// RUN: %clang_tsan %s -o %t
-// RUN: %deflake %run %t 2>&1 | FileCheck %s
-
-#include "dispatch/dispatch.h"
-#include "../test.h"
-
-long global;
-
-int main() {
- 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);
- dispatch_queue_t q2 = dispatch_queue_create("my.queue2", DISPATCH_QUEUE_CONCURRENT);
-
- global = 42;
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- dispatch_sync(q1, ^{
- global = 43;
- barrier_wait(&barrier);
- });
- });
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- dispatch_sync(q2, ^{
- barrier_wait(&barrier);
- global = 44;
-
- dispatch_semaphore_signal(done);
- });
- });
-
- dispatch_semaphore_wait(done, DISPATCH_TIME_FOREVER);
- fprintf(stderr, "Done.\n");
-}
-
-// CHECK: Hello world.
-// CHECK: addr=[[ADDR:0x[0-9,a-f]+]]
-// CHECK: WARNING: ThreadSanitizer: data race
-// CHECK: Location is global 'global' {{(of size 8 )?}}at [[ADDR]] (gcd-sync-race.mm.tmp+0x{{[0-9,a-f]+}})
-// CHECK: Done.
diff --git a/test/tsan/Darwin/gcd-target-queue-norace.mm b/test/tsan/Darwin/gcd-target-queue-norace.mm
deleted file mode 100644
index b5361c81f..000000000
--- a/test/tsan/Darwin/gcd-target-queue-norace.mm
+++ /dev/null
@@ -1,41 +0,0 @@
-// RUN: %clang_tsan %s -o %t
-// RUN: %run %t 2>&1 | FileCheck %s
-
-#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);
- dispatch_set_target_queue(q1, target_queue);
- dispatch_set_target_queue(q2, target_queue);
-
- for (int i = 0; i < 100000; i++) {
- dispatch_async(q1, ^{
- global++;
-
- if (global == 200000) {
- dispatch_semaphore_signal(done);
- }
- });
- dispatch_async(q2, ^{
- global++;
-
- if (global == 200000) {
- dispatch_semaphore_signal(done);
- }
- });
- }
-
- dispatch_semaphore_wait(done, DISPATCH_TIME_FOREVER);
- fprintf(stderr, "Done.\n");
- return 0;
-}
-
-// CHECK-NOT: WARNING: ThreadSanitizer
-// CHECK: Done.