22Test lldb-dap "port" configuration to "attach" request
33"""
44
5- import dap_server
65from lldbsuite .test .decorators import *
76from lldbsuite .test .lldbtest import *
8- from lldbsuite .test import lldbutil
97from lldbsuite .test import lldbplatformutil
108from lldbgdbserverutils import Pipe
119import lldbdap_testcase
12- import os
13- import shutil
14- import subprocess
15- import tempfile
16- import threading
17- import sys
18- import socket
10+ import lldb
1911
2012
21- @skip ("https://github.com/llvm/llvm-project/issues/138803" )
13+ @skip (bugnumber = "https://github.com/llvm/llvm-project/issues/138803" )
2214class TestDAP_attachByPortNum (lldbdap_testcase .DAPTestCaseBase ):
23- default_timeout = 20
24-
2515 def set_and_hit_breakpoint (self , continueToExit = True ):
2616 self .dap_server .wait_for_stopped ()
2717
@@ -50,7 +40,7 @@ def get_debug_server_command_line_args(self):
5040 def get_debug_server_pipe (self ):
5141 pipe = Pipe (self .getBuildDir ())
5242 self .addTearDownHook (lambda : pipe .close ())
53- pipe .finish_connection (self .default_timeout )
43+ pipe .finish_connection (self .DEFAULT_TIMEOUT )
5444 return pipe
5545
5646 @skipIfWindows
@@ -73,28 +63,33 @@ def test_by_port(self):
7363 )
7464
7565 # Read the port number from the debug server pipe.
76- port = pipe .read (10 , self .default_timeout )
66+ port = pipe .read (10 , self .DEFAULT_TIMEOUT )
7767 # Trim null byte, convert to int
7868 port = int (port [:- 1 ])
7969 self .assertIsNotNone (
8070 port , " Failed to read the port number from debug server pipe"
8171 )
8272
83- self .attach (program = program , gdbRemotePort = port , sourceInitFile = True )
73+ self .attach (
74+ program = program ,
75+ gdbRemotePort = port ,
76+ sourceInitFile = True ,
77+ stopOnEntry = True ,
78+ )
8479 self .set_and_hit_breakpoint (continueToExit = True )
85- self .process .terminate ()
8680
8781 @skipIfWindows
8882 @skipIfNetBSD
89- def test_by_port_and_pid (self ):
83+ def test_fails_if_both_port_and_pid_are_set (self ):
9084 """
9185 Tests attaching to a process by process ID and port number.
9286 """
9387 program = self .build_and_create_debug_adapter_for_attach ()
9488
95- # It is not necessary to launch "lldb-server" to obtain the actual port and pid for attaching.
96- # However, when providing the port number and pid directly, "lldb-dap" throws an error message, which is expected.
97- # So, used random pid and port numbers here.
89+ # It is not necessary to launch "lldb-server" to obtain the actual port
90+ # and pid for attaching. However, when providing the port number and pid
91+ # directly, "lldb-dap" throws an error message, which is expected. So,
92+ # used random pid and port numbers here.
9893
9994 pid = 1354
10095 port = 1234
@@ -106,10 +101,9 @@ def test_by_port_and_pid(self):
106101 sourceInitFile = True ,
107102 expectFailure = True ,
108103 )
109- if not (response and response ["success" ]):
110- self .assertFalse (
111- response ["success" ], "The user can't specify both pid and port"
112- )
104+ self .assertFalse (
105+ response ["success" ], "The user can't specify both pid and port"
106+ )
113107
114108 @skipIfWindows
115109 @skipIfNetBSD
@@ -123,11 +117,10 @@ def test_by_invalid_port(self):
123117 response = self .attach (
124118 program = program , gdbRemotePort = port , sourceInitFile = True , expectFailure = True
125119 )
126- if not (response and response ["success" ]):
127- self .assertFalse (
128- response ["success" ],
129- "The user can't attach with invalid port (%s)" % port ,
130- )
120+ self .assertFalse (
121+ response ["success" ],
122+ "The user can't attach with invalid port (%s)" % port ,
123+ )
131124
132125 @skipIfWindows
133126 @skipIfNetBSD
@@ -147,9 +140,7 @@ def test_by_illegal_port(self):
147140 response = self .attach (
148141 program = program , gdbRemotePort = port , sourceInitFile = True , expectFailure = True
149142 )
150- if not (response and response ["success" ]):
151- self .assertFalse (
152- response ["success" ],
153- "The user can't attach with illegal port (%s)" % port ,
154- )
155- self .process .terminate ()
143+ self .assertFalse (
144+ response ["success" ],
145+ "The user can't attach with illegal port (%s)" % port ,
146+ )
0 commit comments