[llvm] [utils][tests] Adjust timeout-hang.py tolerances (PR #142089)

Hubert Tong via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 1 13:40:50 PDT 2025


https://github.com/hubert-reinterpretcast updated https://github.com/llvm/llvm-project/pull/142089

>From bb7970e40f226978fa54ffafc807f03b571fcdc2 Mon Sep 17 00:00:00 2001
From: Hubert Tong <hubert.reinterpretcast at gmail.com>
Date: Thu, 29 May 2025 23:41:18 -0400
Subject: [PATCH 1/3] [utils][tests] Adjust timeout-hang.py tolerances

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.
---
 llvm/utils/lit/tests/timeout-hang.py | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/llvm/utils/lit/tests/timeout-hang.py b/llvm/utils/lit/tests/timeout-hang.py
index 486f07983708f..4c4bccd670f73 100644
--- a/llvm/utils/lit/tests/timeout-hang.py
+++ b/llvm/utils/lit/tests/timeout-hang.py
@@ -8,20 +8,21 @@
 # throwing an exception. We expect this to fail immediately, rather than
 # timeout.
 
-# DEFINE: %{timeout}=1
+# DEFINE: %{grace_period}=5
+# DEFINE: %{hard_timeout}=15
 
 # RUN: not %{lit} %{inputs}/timeout-hang/run-nonexistent.txt \
-# RUN: --timeout=%{timeout} --param external=0 | %{python} %s %{timeout}
+# RUN: --timeout=%{hard_timeout} --param external=0 | %{python} %s %{grace_period}
 
 import sys
 import re
 
-timeout_time = float(sys.argv[1])
+grace_time = float(sys.argv[1])
 testing_time = float(re.search(r"Testing Time: (.*)s", sys.stdin.read()).group(1))
 
-if testing_time < timeout_time:
-    print("Testing took less than timeout")
+if testing_time <= grace_time:
+    print("Testing finished within the grace period")
     sys.exit(0)
 else:
-    print("Testing took as long or longer than timeout")
+    print("Testing took {}s, which is beyond the grace period of {}s".format(testing_time, grace_time))
     sys.exit(1)

>From 33588ca25e63630b7fa48dba372da638cb5f8492 Mon Sep 17 00:00:00 2001
From: Hubert Tong <hubert.reinterpretcast at gmail.com>
Date: Fri, 30 May 2025 02:13:06 -0400
Subject: [PATCH 2/3] Fix formatting

---
 llvm/utils/lit/tests/timeout-hang.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/llvm/utils/lit/tests/timeout-hang.py b/llvm/utils/lit/tests/timeout-hang.py
index 4c4bccd670f73..a74fe18f64594 100644
--- a/llvm/utils/lit/tests/timeout-hang.py
+++ b/llvm/utils/lit/tests/timeout-hang.py
@@ -24,5 +24,9 @@
     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))
+    print(
+        "Testing took {}s, which is beyond the grace period of {}s".format(
+            testing_time, grace_time
+        )
+    )
     sys.exit(1)

>From 1f0b3a7ec4be393b599eca41fed19ee5668909d7 Mon Sep 17 00:00:00 2001
From: Hubert Tong <hubert.reinterpretcast at gmail.com>
Date: Sun, 1 Jun 2025 16:40:42 -0400
Subject: [PATCH 3/3] Add code comment to address review

---
 llvm/utils/lit/tests/timeout-hang.py | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/llvm/utils/lit/tests/timeout-hang.py b/llvm/utils/lit/tests/timeout-hang.py
index a74fe18f64594..edb23affad578 100644
--- a/llvm/utils/lit/tests/timeout-hang.py
+++ b/llvm/utils/lit/tests/timeout-hang.py
@@ -8,6 +8,10 @@
 # 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
 



More information about the llvm-commits mailing list