[clang-format] Rename ExportBlockIndentation -> IndentExportBlock (#123493)
[llvm-project.git] / compiler-rt / test / tsan / deflake.bash
blob5a88174a7ce1491fe177638acb54e0cf274ade0a
1 #!/usr/bin/env bash
2 # This script is used to deflake inherently flaky tsan tests.
3 # It is invoked from lit tests as:
4 # %deflake $THRESHOLD mybinary
5 # which is then substituted by lit to:
6 # $(dirname %s)/deflake.bash $THRESHOLD mybinary
7 # - When TSAN_TEST_DEFLAKE_THRESHOLD is defined to a positive integer value,
8 # THRESHOLD will be the defined value.
9 # - When TSAN_TEST_DEFLAKE_THRESHOLD is not defined, THRESHOLD will be 10.
10 # The script runs the target program up to $THRESHOLD times,
11 # until it fails (i.e. produces a race report).
13 THRESHOLD="${1}"
14 shift
16 # Early exit if $THRESHOLD is not a non-negative integer
17 [[ "${THRESHOLD}" =~ ^[0-9]+$ ]] || exit 1
19 while (( THRESHOLD-- )); do
20 OUT=`$@ 2>&1`
21 if [[ $? != 0 ]]; then
22 echo "$OUT"
23 exit 0
25 done
26 exit 1