[libc-commits] [libc] [libc][test] Add timeout with diagnostics to LibcTest (PR #202307)

via libc-commits libc-commits at lists.llvm.org
Mon Jun 8 03:08:58 PDT 2026


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {darker}-->


:warning: Python code formatter, darker found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
darker --check --diff -r origin/main...HEAD libc/utils/libctest/format.py
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from darker here.
</summary>

``````````diff
--- format.py	2026-06-08 10:04:16.000000 +0000
+++ format.py	2026-06-08 10:08:21.710631 +0000
@@ -120,58 +120,85 @@
 
         return None
 
     def _run_diagnostics(self, pid):
         import subprocess
+
         diag_out = []
         diag_out.append(f"--- Process {pid} diagnostics ---")
-        
+
         # wchan
         diag_out.append("--- wchan ---")
         try:
             with open(f"/proc/{pid}/wchan", "r") as f:
                 diag_out.append(f.read().strip())
         except Exception as e:
             diag_out.append(f"Failed to read wchan: {e}")
-            
+
         # stack
         diag_out.append("--- stack ---")
         try:
             with open(f"/proc/{pid}/stack", "r") as f:
                 diag_out.append(f.read())
         except Exception as e:
             diag_out.append(f"Failed to read stack: {e}")
 
         # lldb
         diag_out.append("--- LLDB Backtrace ---")
-        lldb_cmd = ["lldb", "-p", str(pid), "--batch", "-o", "thread backtrace all", "-o", "quit"]
-        try:
-            out = subprocess.check_output(lldb_cmd, stderr=subprocess.STDOUT, text=True, timeout=10)
+        lldb_cmd = [
+            "lldb",
+            "-p",
+            str(pid),
+            "--batch",
+            "-o",
+            "thread backtrace all",
+            "-o",
+            "quit",
+        ]
+        try:
+            out = subprocess.check_output(
+                lldb_cmd, stderr=subprocess.STDOUT, text=True, timeout=10
+            )
             diag_out.append(out)
         except Exception as e:
             diag_out.append(f"Failed to run lldb: {e}")
-            
+
             # gdb fallback
             diag_out.append("--- GDB Backtrace ---")
-            gdb_cmd = ["gdb", "-p", str(pid), "--batch", "-ex", "thread apply all bt", "-ex", "quit"]
+            gdb_cmd = [
+                "gdb",
+                "-p",
+                str(pid),
+                "--batch",
+                "-ex",
+                "thread apply all bt",
+                "-ex",
+                "quit",
+            ]
             try:
-                out = subprocess.check_output(gdb_cmd, stderr=subprocess.STDOUT, text=True, timeout=10)
+                out = subprocess.check_output(
+                    gdb_cmd, stderr=subprocess.STDOUT, text=True, timeout=10
+                )
                 diag_out.append(out)
             except Exception as e2:
                 diag_out.append(f"Failed to run gdb: {e2}")
 
         # strace
         diag_out.append("--- Strace (2 seconds) ---")
         strace_cmd = ["timeout", "2", "strace", "-p", str(pid)]
         try:
-            out = subprocess.check_output(strace_cmd, stderr=subprocess.STDOUT, text=True)
+            out = subprocess.check_output(
+                strace_cmd, stderr=subprocess.STDOUT, text=True
+            )
             diag_out.append(out)
         except subprocess.CalledProcessError as e:
             if e.returncode == 124:
                 diag_out.append(e.output)
             else:
-                diag_out.append(f"Strace failed with exit code {e.returncode}: {e.output}")
+                diag_out.append(
+                    f"Strace failed with exit code {e.returncode}: {e.output}"
+                )
         except Exception as e:
             diag_out.append(f"Failed to run strace: {e}")
 
         return "\n".join(diag_out)
 

``````````

</details>


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


More information about the libc-commits mailing list