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

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


Author: Jeff Bailey
Date: 2026-04-23T16:46:49+01:00
New Revision: cf2b30aa2acac4b14d68aca9fcc951befe2c38e0

URL: https://github.com/llvm/llvm-project/commit/cf2b30aa2acac4b14d68aca9fcc951befe2c38e0
DIFF: https://github.com/llvm/llvm-project/commit/cf2b30aa2acac4b14d68aca9fcc951befe2c38e0.diff

LOG: [libc] Honor per-test timeout in lit test format (#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.

Added: 
    

Modified: 
    libc/utils/libctest/format.py

Removed: 
    


################################################################################
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