[compiler-rt] r209900 - tsan: add a test from data-race-test suite:

Dmitry Vyukov dvyukov at google.com
Fri May 30 07:27:32 PDT 2014


Author: dvyukov
Date: Fri May 30 09:27:31 2014
New Revision: 209900

URL: http://llvm.org/viewvc/llvm-project?rev=209900&view=rev
Log:
tsan: add a test from data-race-test suite:
https://code.google.com/p/data-race-test/source/browse/trunk/unittest/racecheck_unittest.cc


Added:
    compiler-rt/trunk/test/tsan/race_on_puts.cc

Added: compiler-rt/trunk/test/tsan/race_on_puts.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/race_on_puts.cc?rev=209900&view=auto
==============================================================================
--- compiler-rt/trunk/test/tsan/race_on_puts.cc (added)
+++ compiler-rt/trunk/test/tsan/race_on_puts.cc Fri May 30 09:27:31 2014
@@ -0,0 +1,29 @@
+// RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s
+#include <pthread.h>
+#include <stdio.h>
+#include <unistd.h>
+
+char s[] = "abracadabra";
+
+void *Thread0(void *p) {
+  puts(s);
+  return 0;
+}
+
+void *Thread1(void *p) {
+  s[3] = 'z';
+  return 0;
+}
+
+int main() {
+  pthread_t th[2];
+  pthread_create(&th[0], 0, Thread0, 0);
+  pthread_create(&th[1], 0, Thread1, 0);
+  pthread_join(th[0], 0);
+  pthread_join(th[1], 0);
+  fprintf(stderr, "DONE");
+}
+
+// CHECK: WARNING: ThreadSanitizer: data race
+// CHECK: DONE
+





More information about the llvm-commits mailing list