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

via libc-commits libc-commits at lists.llvm.org
Thu Apr 23 08:47:17 PDT 2026


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libc

Author: Jeff Bailey (kaladron)

<details>
<summary>Changes</summary>

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.

---
Full diff: https://github.com/llvm/llvm-project/pull/193772.diff


1 Files Affected:

- (modified) libc/utils/libctest/format.py (+13-4) 


``````````diff
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:

``````````

</details>


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


More information about the libc-commits mailing list