[PATCH] tsan: automatically deflake flaky tests

Dmitry Vyukov dvyukov at google.com
Tue May 27 08:30:15 PDT 2014


allow custom FileCheck args

http://reviews.llvm.org/D3913

Files:
  test/tsan/deflake.bash
  test/tsan/free_race.c
  test/tsan/simple_race.c

Index: test/tsan/free_race.c
===================================================================
--- test/tsan/free_race.c
+++ test/tsan/free_race.c
@@ -1,5 +1,5 @@
 // RUN: %clang_tsan -O1 %s -o %t
-// RUN: not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-NOZUPP
+// RUN: $(dirname %s)/deflake.bash %run %t %s --check-prefix=CHECK-NOZUPP
 // RUN: TSAN_OPTIONS="suppressions=%s.supp print_suppressions=1" %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-SUPP
 
 #include <pthread.h>
Index: test/tsan/deflake.bash
===================================================================
--- test/tsan/deflake.bash
+++ test/tsan/deflake.bash
@@ -0,0 +1,17 @@
+#!/usr/bin/env bash
+# This script is used to deflake inherently flaky tsan tests.
+# It is invoked from lit tests as:
+# $(dirname %s)/deflake.bash %run %t %s [FileCheck args]
+# The script runs the target program up to 10 times,
+# until it produces the necessary output.
+
+BIN=$1
+SRC=$2
+shift
+shift
+
+for i in $(seq 1 10); do
+	echo TRY $i
+	not $BIN 2>&1 | FileCheck $SRC $@ && exit 0
+done
+exit 1
Index: test/tsan/simple_race.c
===================================================================
--- test/tsan/simple_race.c
+++ test/tsan/simple_race.c
@@ -1,4 +1,4 @@
-// RUN: %clang_tsan -O1 %s -o %t && not %run %t 2>&1 | FileCheck %s
+// RUN: %clang_tsan -O1 %s -o %t && $(dirname %s)/deflake.bash %run %t %s
 #include <pthread.h>
 #include <stdio.h>
 #include <unistd.h>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D3913.9840.patch
Type: text/x-patch
Size: 1443 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140527/0b21055b/attachment.bin>


More information about the llvm-commits mailing list