]> git.proxmox.com Git - rustc.git/blobdiff - src/compiler-rt/test/tsan/mutexset5.cc
Imported Upstream version 1.6.0+dfsg1
[rustc.git] / src / compiler-rt / test / tsan / mutexset5.cc
index ea1255373c64cd12aad78381c3b9f75ada7ce9ee..8ef9af0ced52440f5a37e07b1fc61fa6351de187 100644 (file)
@@ -1,14 +1,12 @@
-// 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;
 pthread_mutex_t mtx2;
 
 void *Thread1(void *x) {
-  sleep(1);
+  barrier_wait(&barrier);
   pthread_mutex_lock(&mtx1);
   Global++;
   pthread_mutex_unlock(&mtx1);
@@ -19,10 +17,12 @@ void *Thread2(void *x) {
   pthread_mutex_lock(&mtx2);
   Global--;
   pthread_mutex_unlock(&mtx2);
+  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]+]]):