[Lldb-commits] [lldb] [lldb-dap] add timeout to spawn_and_wait test utility (PR #174461)
Charles Zablit via lldb-commits
lldb-commits at lists.llvm.org
Mon Jan 5 10:57:50 PST 2026
https://github.com/charles-zablit updated https://github.com/llvm/llvm-project/pull/174461
>From e4f43f5a6e9c2df3c3d582268be365493db01c6b Mon Sep 17 00:00:00 2001
From: Charles Zablit <c_zablit at apple.com>
Date: Mon, 5 Jan 2026 19:33:01 +0100
Subject: [PATCH 1/2] [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()
>From 8532b761ade5004bd860281d9a8bd9fab50a3219 Mon Sep 17 00:00:00 2001
From: Charles Zablit <c_zablit at apple.com>
Date: Mon, 5 Jan 2026 19:57:36 +0100
Subject: [PATCH 2/2] switch to time.time()
---
lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
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 a7d0993ec7c6f..3442f2c7eaf12 100644
--- a/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py
+++ b/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py
@@ -2,7 +2,6 @@
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
@@ -26,14 +25,14 @@ def spawn(self, program, args=None):
)
def spawn_and_wait(self, program, delay):
- SPAWN_AND_WAIT_TIMEOUT = 900
+ SPAWN_AND_WAIT_TIMEOUT_SECONDS = 900.0
time.sleep(delay)
proc = self.spawn(program=program)
- start_time = datetime.now()
+ start_time = time.time()
# 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):
+ elapsed = time.time() - start_time
+ if elapsed >= SPAWN_AND_WAIT_TIMEOUT_SECONDS:
break
time.sleep(0.1)
proc.kill()
More information about the lldb-commits
mailing list