Author: Raphael Isemann
Date: 2026-06-18T07:38:54+01:00
New Revision: 8199e9fa55270686b5ad8bb490fbf414736b027c

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

LOG: [lldb][test] Speed up ProcessAttach test (#201530)

ProcessAttach is our slowest test and runs for about 70s. We spend 60s
in the autocontinue test waiting for the target program to terminate.

The reason we wait for the program is that our autocontinue test is not
running its command in async mode, and we wait after the attach for the
next breakpoint or the program terminates.

This patch makes the attach and autocontinue run in async mode so we
don't wait for the program to finish. This reduces the test time from
70s to about 10s.

It also replaces the assertTrue call that was supposed to be an
assertEqual, which made the test succeed even though the inferior
process already terminated.

Added: 
    

Modified: 
    lldb/test/API/commands/process/attach/TestProcessAttach.py

Removed: 
    


################################################################################
diff  --git a/lldb/test/API/commands/process/attach/TestProcessAttach.py 
b/lldb/test/API/commands/process/attach/TestProcessAttach.py
index 14dfb40805b39..5abcf69d0acba 100644
--- a/lldb/test/API/commands/process/attach/TestProcessAttach.py
+++ b/lldb/test/API/commands/process/attach/TestProcessAttach.py
@@ -49,13 +49,36 @@ def test_attach_to_process_by_id_autocontinue(self):
         # Spawn a new process
         popen = self.spawnSubprocess(exe)
 
+        # Don't wait for the continue to finish.
+        self.setAsync(True)
         self.runCmd("process attach -c -p " + str(popen.pid))
 
         target = self.dbg.GetSelectedTarget()
 
+        # Start listening to process events.
         process = target.GetProcess()
         self.assertTrue(process, PROCESS_IS_VALID)
-        self.assertTrue(process.GetState(), lldb.eStateRunning)
+        broadcaster = process.GetBroadcaster()
+        listener = self.dbg.GetListener()
+        state = process.GetState()
+        self.assertEqual(
+            state, lldb.eStateStopped, "The attach stopped before continuing"
+        )
+
+        # Listen for events until we see the process continue.
+        event = lldb.SBEvent()
+        got_running = False
+        got_event = False
+        timeout = 180
+        while listener.WaitForEventForBroadcaster(timeout, broadcaster, event):
+            state = process.GetState()
+            got_event = True
+            if state == lldb.eStateRunning:
+                got_running = True
+                break
+
+        self.assertTrue(got_event, "Didn't receive any events after attaching")
+        self.assertTrue(got_running, "Process didn't auto-continue")
 
     @skipIfWindows  # This is flakey on Windows AND when it fails, it hangs: 
llvm.org/pr48806
     def test_attach_to_process_from_
diff erent_dir_by_id(self):


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

Reply via email to