]> git.proxmox.com Git - rustc.git/blobdiff - src/compiler-rt/test/tsan/mutexset6.cc
Imported Upstream version 1.6.0+dfsg1
[rustc.git] / src / compiler-rt / test / tsan / mutexset6.cc
index a42a743645d50afdc853fdd544836b56924fbd42..f4251db6970e8ed92fc4a176d2f69f84ca7e1644 100644 (file)
@@ -1,7 +1,5 @@
-// RUN: %clangxx_tsan -O1 %s -o %t && not %run %t 2>&1 | FileCheck %s
-#include <pthread.h>
-#include <stdio.h>
-#include <unistd.h>
+// RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s
+#include "test.h"
 
 int Global;
 pthread_mutex_t mtx1;
@@ -9,7 +7,7 @@ pthread_spinlock_t mtx2;
 pthread_rwlock_t mtx3;
 
 void *Thread1(void *x) {
-  sleep(1);
+  barrier_wait(&barrier);
   pthread_mutex_lock(&mtx1);
   Global++;
   pthread_mutex_unlock(&mtx1);
@@ -24,10 +22,12 @@ void *Thread2(void *x) {
   Global--;
   pthread_spin_unlock(&mtx2);
   pthread_rwlock_unlock(&mtx3);
+  barrier_wait(&barrier);
   return NULL;
 }
 
 int main() {
+  barrier_init(&barrier, 2);
   // CHECK: WARNING: ThreadSanitizer: data race
   // CHECK:   Write of size 4 at {{.*}} by thread T1
   // CHECK:                          (mutexes: write [[M1:M[0-9]+]]):