xref: /aosp_15_r20/external/compiler-rt/test/tsan/deflake.bash (revision 7c3d14c8b49c529e04be81a3ce6f5cc23712e4c6)
1*7c3d14c8STreehugger Robot#!/usr/bin/env bash
2*7c3d14c8STreehugger Robot# This script is used to deflake inherently flaky tsan tests.
3*7c3d14c8STreehugger Robot# It is invoked from lit tests as:
4*7c3d14c8STreehugger Robot# %deflake mybinary
5*7c3d14c8STreehugger Robot# which is then substituted by lit to:
6*7c3d14c8STreehugger Robot# $(dirname %s)/deflake.bash mybinary
7*7c3d14c8STreehugger Robot# The script runs the target program up to 10 times,
8*7c3d14c8STreehugger Robot# until it fails (i.e. produces a race report).
9*7c3d14c8STreehugger Robot
10*7c3d14c8STreehugger Robotfor i in $(seq 1 10); do
11*7c3d14c8STreehugger Robot	OUT=`$@ 2>&1`
12*7c3d14c8STreehugger Robot	if [[ $? != 0 ]]; then
13*7c3d14c8STreehugger Robot		echo "$OUT"
14*7c3d14c8STreehugger Robot		exit 0
15*7c3d14c8STreehugger Robot	fi
16*7c3d14c8STreehugger Robotdone
17*7c3d14c8STreehugger Robotexit 1
18