https://github.com/ashgti created https://github.com/llvm/llvm-project/pull/141981
Trimming unused imports, adjusting the test to use the `DEFAULT_TIMEOUT` instead of a custom timeout and adjusting the flow to stopOnEntry for improving consistency. >From 509b0a5643620b10e77216c7cde591b7e8ccb13d Mon Sep 17 00:00:00 2001 From: John Harrison <harj...@google.com> Date: Thu, 29 May 2025 09:46:08 -0700 Subject: [PATCH] [lldb-dap] Test Gardening, attach tests. Trimming unused imports, adjusting the test to use the `DEFAULT_TIMEOUT` instead of a custom timeout and adjusting the flow to stopOnEntry for improving consistency. --- .../attach/TestDAP_attachByPortNum.py | 61 ++++++++----------- 1 file changed, 26 insertions(+), 35 deletions(-) diff --git a/lldb/test/API/tools/lldb-dap/attach/TestDAP_attachByPortNum.py b/lldb/test/API/tools/lldb-dap/attach/TestDAP_attachByPortNum.py index 7c2b540195d15..edb87a9314d78 100644 --- a/lldb/test/API/tools/lldb-dap/attach/TestDAP_attachByPortNum.py +++ b/lldb/test/API/tools/lldb-dap/attach/TestDAP_attachByPortNum.py @@ -2,26 +2,16 @@ Test lldb-dap "port" configuration to "attach" request """ -import dap_server from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * -from lldbsuite.test import lldbutil from lldbsuite.test import lldbplatformutil from lldbgdbserverutils import Pipe import lldbdap_testcase -import os -import shutil -import subprocess -import tempfile -import threading -import sys -import socket +import lldb -@skip("https://github.com/llvm/llvm-project/issues/138803") +@skip(bugnumber="https://github.com/llvm/llvm-project/issues/138803") class TestDAP_attachByPortNum(lldbdap_testcase.DAPTestCaseBase): - default_timeout = 20 - def set_and_hit_breakpoint(self, continueToExit=True): self.dap_server.wait_for_stopped() @@ -50,7 +40,7 @@ def get_debug_server_command_line_args(self): def get_debug_server_pipe(self): pipe = Pipe(self.getBuildDir()) self.addTearDownHook(lambda: pipe.close()) - pipe.finish_connection(self.default_timeout) + pipe.finish_connection(self.DEFAULT_TIMEOUT) return pipe @skipIfWindows @@ -73,28 +63,33 @@ def test_by_port(self): ) # Read the port number from the debug server pipe. - port = pipe.read(10, self.default_timeout) + port = pipe.read(10, self.DEFAULT_TIMEOUT) # Trim null byte, convert to int port = int(port[:-1]) self.assertIsNotNone( port, " Failed to read the port number from debug server pipe" ) - self.attach(program=program, gdbRemotePort=port, sourceInitFile=True) + self.attach( + program=program, + gdbRemotePort=port, + sourceInitFile=True, + stopOnEntry=True, + ) self.set_and_hit_breakpoint(continueToExit=True) - self.process.terminate() @skipIfWindows @skipIfNetBSD - def test_by_port_and_pid(self): + def test_fails_if_both_port_and_pid_are_set(self): """ Tests attaching to a process by process ID and port number. """ program = self.build_and_create_debug_adapter_for_attach() - # It is not necessary to launch "lldb-server" to obtain the actual port and pid for attaching. - # However, when providing the port number and pid directly, "lldb-dap" throws an error message, which is expected. - # So, used random pid and port numbers here. + # It is not necessary to launch "lldb-server" to obtain the actual port + # and pid for attaching. However, when providing the port number and pid + # directly, "lldb-dap" throws an error message, which is expected. So, + # used random pid and port numbers here. pid = 1354 port = 1234 @@ -106,10 +101,9 @@ def test_by_port_and_pid(self): sourceInitFile=True, expectFailure=True, ) - if not (response and response["success"]): - self.assertFalse( - response["success"], "The user can't specify both pid and port" - ) + self.assertFalse( + response["success"], "The user can't specify both pid and port" + ) @skipIfWindows @skipIfNetBSD @@ -123,11 +117,10 @@ def test_by_invalid_port(self): response = self.attach( program=program, gdbRemotePort=port, sourceInitFile=True, expectFailure=True ) - if not (response and response["success"]): - self.assertFalse( - response["success"], - "The user can't attach with invalid port (%s)" % port, - ) + self.assertFalse( + response["success"], + "The user can't attach with invalid port (%s)" % port, + ) @skipIfWindows @skipIfNetBSD @@ -147,9 +140,7 @@ def test_by_illegal_port(self): response = self.attach( program=program, gdbRemotePort=port, sourceInitFile=True, expectFailure=True ) - if not (response and response["success"]): - self.assertFalse( - response["success"], - "The user can't attach with illegal port (%s)" % port, - ) - self.process.terminate() + self.assertFalse( + response["success"], + "The user can't attach with illegal port (%s)" % port, + ) _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits