Skip to content

Commit 26fd14a

Browse files
committed
Implement timeout hang test
1 parent 7c953eb commit 26fd14a

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import lit.formats
22

33
config.name = "timeout-hang"
4-
config.suffixes = [".py"]
4+
config.suffixes = [".txt"]
55
config.test_format = lit.formats.ShTest()
66
config.test_source_root = None
77
config.test_exec_root = None
Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,27 @@
11
# REQUIRES: lit-max-individual-test-time
22

3-
# https://github.com/llvm/llvm-project/issues/133914
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.
46

5-
# RUN: not %{lit} %{inputs}/timeout-hang/run-nonexistent.py \
6-
# RUN: --timeout=1 --param external=0 -a
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+
# DEFINE: %{timeout}=1
12+
13+
# RUN: not %{lit} %{inputs}/timeout-hang/run-nonexistent.txt \
14+
# RUN: --timeout=%{timeout} --param external=0 | %{python} %s %{timeout}
15+
16+
import sys
17+
import re
18+
19+
timeout_time = float(sys.argv[1])
20+
testing_time = float(re.search(r'Testing Time: (.*)s', sys.stdin.read()).group(1))
21+
22+
if testing_time < timeout_time:
23+
print("Testing took less than timeout")
24+
sys.exit(0)
25+
else:
26+
print("Testing took as long or longer than timeout")
27+
sys.exit(1)

0 commit comments

Comments
 (0)