Index: test/tsan/deflake.bash =================================================================== --- test/tsan/deflake.bash +++ test/tsan/deflake.bash @@ -0,0 +1,12 @@ +#!/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 +# The script runs the target program up to 10 times, +# until it produces the necessary output. + +for i in $(seq 1 10); do + echo TRY $i + not $1 2>&1 | FileCheck $2 && 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 #include #include