37 lines · python
1# REQUIRES: lit-max-individual-test-time2 3# Python has some issues dealing with exceptions when multiprocessing,4# which can cause hangs. Previously this could occur when we encountered5# 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 than9# 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, but13# it should always be significantly less than the hard timeout, which is the14# point where lit would cancel the test.15# DEFINE: %{grace_period}=516# DEFINE: %{hard_timeout}=1517 18# RUN: not %{lit} %{inputs}/timeout-hang/run-nonexistent.txt \19# RUN: --timeout=%{hard_timeout} --param external=0 | %{python} %s %{grace_period}20 21import sys22import re23 24grace_time = float(sys.argv[1])25testing_time = float(re.search(r"Testing Time: (.*)s", sys.stdin.read()).group(1))26 27if testing_time <= grace_time:28 print("Testing finished within the grace period")29 sys.exit(0)30else:31 print(32 "Testing took {}s, which is beyond the grace period of {}s".format(33 testing_time, grace_time34 )35 )36 sys.exit(1)37