]> git.proxmox.com Git - rustc.git/blobdiff - src/compiler-rt/test/tsan/mutexset2.cc
Imported Upstream version 1.6.0+dfsg1
[rustc.git] / src / compiler-rt / test / tsan / mutexset2.cc
index 80b690df7b1a84d35a961db33d4180d75d55d7db..2a3e5bb95e875074f9991ba39494c661f90fc1e2 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 mtx;
@@ -10,16 +8,18 @@ void *Thread1(void *x) {
   pthread_mutex_lock(&mtx);
   Global++;
   pthread_mutex_unlock(&mtx);
+  barrier_wait(&barrier);
   return NULL;
 }
 
 void *Thread2(void *x) {
-  sleep(1);
+  barrier_wait(&barrier);
   Global--;
   return NULL;
 }
 
 int main() {
+  barrier_init(&barrier, 2);
   // CHECK: WARNING: ThreadSanitizer: data race
   // CHECK:   Write of size 4 at {{.*}} by thread T2:
   // CHECK:   Previous write of size 4 at {{.*}} by thread T1