llvm-project/llvm/utils/lit/tests/timeout-hang.py
Hubert Tong 24f432d33e
[utils][tests] Adjust timeout-hang.py tolerances (#142089)
The subject test sporadically fails on the AIX builder:
https://lab.llvm.org/buildbot/#/builders/64/builds/3921/steps/6/logs/FAIL__lit___timeout-hang_py

This appears to be an environment issue potentially connected to high
load because the problem is not observed on other AIX machines.

This patch separates the "hard" timeout value from the value used to
signal a hang. This allows for a more generous "hard" timeout value,
which allows observation of cases that take longer to finish despite not
hanging.
2025-06-02 20:20:20 -04:00

37 lines
1.3 KiB
Python

# REQUIRES: lit-max-individual-test-time
# Python has some issues dealing with exceptions when multiprocessing,
# which can cause hangs. Previously this could occur when we encountered
# an internal shell exception, and had a timeout set.
# This test runs a lit test that tries to launch a non-existent file,
# throwing an exception. We expect this to fail immediately, rather than
# timeout.
# lit should return immediately once it fails to execute the non-existent file.
# This will take a variable amount of time depending on process scheduling, but
# it should always be significantly less than the hard timeout, which is the
# point where lit would cancel the test.
# DEFINE: %{grace_period}=5
# DEFINE: %{hard_timeout}=15
# RUN: not %{lit} %{inputs}/timeout-hang/run-nonexistent.txt \
# RUN: --timeout=%{hard_timeout} --param external=0 | %{python} %s %{grace_period}
import sys
import re
grace_time = float(sys.argv[1])
testing_time = float(re.search(r"Testing Time: (.*)s", sys.stdin.read()).group(1))
if testing_time <= grace_time:
print("Testing finished within the grace period")
sys.exit(0)
else:
print(
"Testing took {}s, which is beyond the grace period of {}s".format(
testing_time, grace_time
)
)
sys.exit(1)