diff options
Diffstat (limited to 'test/tsan/sleep_sync.cc')
-rw-r--r-- | test/tsan/sleep_sync.cc | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/test/tsan/sleep_sync.cc b/test/tsan/sleep_sync.cc index c7614e16bf3e..b2c6a1220f42 100644 --- a/test/tsan/sleep_sync.cc +++ b/test/tsan/sleep_sync.cc @@ -1,23 +1,25 @@ // RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s -#include <pthread.h> -#include <unistd.h> +#include "test.h" int X = 0; void MySleep() { - sleep(1); + sleep(1); // the sleep that must appear in the report } void *Thread(void *p) { + barrier_wait(&barrier); MySleep(); // Assume the main thread has done the write. X = 42; return 0; } int main() { + barrier_init(&barrier, 2); pthread_t t; pthread_create(&t, 0, Thread, 0); X = 43; + barrier_wait(&barrier); pthread_join(t, 0); return 0; } |