[libc-commits] [libc] [libc] Honor per-test timeout in lit test format (PR #193772)

Jeff Bailey via libc-commits libc-commits at lists.llvm.org
Thu Apr 23 08:25:23 PDT 2026


https://github.com/kaladron created https://github.com/llvm/llvm-project/pull/193772

The custom LibcTest format did not pass litConfig.maxIndividualTestTime to executeCommand. This caused --timeout to be silently ignored, so hanging tests like fdiv_test on AMDGPU blocked the entire suite until the buildbot watchdog killed the process after 1200s.

Added timeout propagation and handling of ExecuteCommandTimeoutException to return lit.Test.TIMEOUT. This follows the same pattern used by the GoogleTest format in googletest.py.

>From 1b299bf24655e9499a3f9bd4841cdb1b756d6d24 Mon Sep 17 00:00:00 2001
From: Jeff Bailey <jbailey at raspberryginger.com>
Date: Thu, 23 Apr 2026 15:12:42 +0000
Subject: [PATCH] [libc] Honor per-test timeout in lit test format

The custom LibcTest format did not pass litConfig.maxIndividualTestTime
to executeCommand. This caused --timeout to be silently ignored, so
hanging tests like fdiv_test on AMDGPU blocked the entire suite until
the buildbot watchdog killed the process after 1200s.

Added timeout propagation and handling of ExecuteCommandTimeoutException
to return lit.Test.TIMEOUT. This follows the same pattern used by the
GoogleTest format in googletest.py.
---
 libc/utils/libctest/format.py | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/libc/utils/libctest/format.py b/libc/utils/libctest/format.py
index cc38b4f17aca9..1285818cb6380 100644
--- a/libc/utils/libctest/format.py
+++ b/libc/utils/libctest/format.py
@@ -129,6 +129,9 @@ def execute(self, test, litConfig):
 
         If a sidecar <executable>.params file exists, it supplies the
         command-line arguments and environment variables for the test.
+
+        Honors litConfig.maxIndividualTestTime (set via --timeout) to
+        kill tests that exceed the per-test time limit.
         """
 
         test_path = test.getSourcePath()
@@ -166,6 +169,8 @@ def execute(self, test, litConfig):
         env["PWD"] = exec_dir
         env.update(extra_env)
 
+        timeout = litConfig.maxIndividualTestTime
+
         test_cmd_template = getattr(test.config, "libc_test_cmd", "")
         if test_cmd_template:
             if "@BINARY@" in test_cmd_template:
@@ -188,13 +193,17 @@ def execute(self, test, litConfig):
                 )
             if not cmd_args:
                 cmd_args = [test_path]
+        else:
+            cmd_args = [test_path] + test_args
 
+        try:
             out, err, exit_code = lit.util.executeCommand(
-                cmd_args, cwd=exec_dir, env=env
+                cmd_args, cwd=exec_dir, env=env, timeout=timeout
             )
-        else:
-            out, err, exit_code = lit.util.executeCommand(
-                [test_path] + test_args, cwd=exec_dir, env=env
+        except lit.util.ExecuteCommandTimeoutException as e:
+            return (
+                lit.Test.TIMEOUT,
+                f"{e.out}\n--\n" f"Reached timeout of {timeout} seconds",
             )
 
         if not exit_code:



More information about the libc-commits mailing list