A number of testcases in this bucket such as ThreadSanitizer-powerpc64le :: atomic_free3.cpp are designed to deal with intermittent problems. The expected problem does not exist in all executions of the program being tested. The authors of the tests are aware of the issue. They use a script called deflake.bash which runs the executable up to 10 times to deal with the intermittent nature of the tests. By performing more executions, they increase the chances of having at least one of the executions expose the targeted issue.
On test machines with heavier load, the hard-coded threshold of 10 is not sufficient. The intermittent issue is more likely to be hit when the process is on a quiet machine because its threads gets cycles more often. Thus, on a machine with much more active processes, the condition being checked for is less likely to happen on any given execution.
The purpose of this patch is to parameterize the hard-coded threshold used by the compiler-rt/test/tsan/deflake.bash script. The changes to CMakeLists and LIT configuration files are to enable the users to configure the deflake threshold by specifying a positive integer value via a CMake variable. This will be used in the case that a deflake threshold other than 10 is more desirable for their test environment.
When the cmake-variable is not defined, the existing value of 10 will be used.