File: timeout-hang.py

package info (click to toggle)
llvm-toolchain-21 1%3A21.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 2,235,796 kB
  • sloc: cpp: 7,617,614; ansic: 1,433,901; asm: 1,058,726; python: 252,096; f90: 94,671; objc: 70,753; lisp: 42,813; pascal: 18,401; sh: 10,032; ml: 5,111; perl: 4,720; awk: 3,523; makefile: 3,401; javascript: 2,272; xml: 892; fortran: 770
file content (36 lines) | stat: -rw-r--r-- 1,280 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# 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)