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