https://github.com/charles-zablit created 
https://github.com/llvm/llvm-project/pull/174461

This is a follow up to https://github.com/llvm/llvm-project/pull/172879.

This patch adds a timeout to the `TestDAP_attach.spawn_and_wait` method. The 
helper method was previously relying on the per test lit timeout, which does 
not work if `psutil` is not installed. The timeout is now enforced whether or 
not `psutil` is installed.



>From e4f43f5a6e9c2df3c3d582268be365493db01c6b Mon Sep 17 00:00:00 2001
From: Charles Zablit <[email protected]>
Date: Mon, 5 Jan 2026 19:33:01 +0100
Subject: [PATCH] [lldb-dap] add timeout to spawn_and_wait test utility

---
 lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py 
b/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py
index 00facfbc60ad5..a7d0993ec7c6f 100644
--- a/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py
+++ b/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py
@@ -2,6 +2,7 @@
 Test lldb-dap attach request
 """
 
+from datetime import datetime, timedelta
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test import lldbutil
@@ -25,10 +26,15 @@ def spawn(self, program, args=None):
         )
 
     def spawn_and_wait(self, program, delay):
+        SPAWN_AND_WAIT_TIMEOUT = 900
         time.sleep(delay)
         proc = self.spawn(program=program)
-        # Wait for either the process to exit or the event to be set
+        start_time = datetime.now()
+        # Wait for either the process to exit or the event to be set.
         while proc.poll() is None and not self.spawn_event.is_set():
+            elapsed = datetime.now() - start_time
+            if elapsed >= timedelta(seconds=SPAWN_AND_WAIT_TIMEOUT):
+                break
             time.sleep(0.1)
         proc.kill()
         proc.wait()

_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to