Skip to content

Commit ec85f0f

Browse files
committed
Adjust the naming of the test dap_server.DebugAdaptorServer to be more consistent.
1 parent d710b9b commit ec85f0f

File tree

3 files changed

+34
-32
lines changed

3 files changed

+34
-32
lines changed

lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1155,25 +1155,27 @@ def __init__(
11551155
self,
11561156
executable=None,
11571157
launch=True,
1158-
connect=None,
1158+
port=None,
1159+
unix_socket=None,
11591160
init_commands=[],
11601161
log_file=None,
11611162
env=None,
11621163
):
11631164
self.process = None
11641165
if launch:
11651166
self.process = DebugAdaptorServer.launch(
1166-
executable, connect=connect, log_file=log_file, env=env
1167+
executable, port=port, unix_socket=unix_socket, log_file=log_file, env=env
11671168
)
11681169

1169-
if connect:
1170-
if isinstance(connect, str) and connect.startswith("/"):
1171-
s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
1172-
s.connect(connect)
1173-
else:
1174-
port = int(connect)
1175-
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
1176-
s.connect(("127.0.0.1", port))
1170+
if port:
1171+
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
1172+
s.connect(("127.0.0.1", port))
1173+
DebugCommunication.__init__(
1174+
self, s.makefile("rb"), s.makefile("wb"), init_commands, log_file
1175+
)
1176+
elif unix_socket:
1177+
s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
1178+
s.connect(unix_socket)
11771179
DebugCommunication.__init__(
11781180
self, s.makefile("rb"), s.makefile("wb"), init_commands, log_file
11791181
)
@@ -1196,7 +1198,7 @@ def terminate(self):
11961198

11971199
@classmethod
11981200
def launch(
1199-
cls, executable: str, /, connect=None, log_file=None, env=None
1201+
cls, executable: str, /, port=None, unix_socket=None, log_file=None, env=None
12001202
) -> subprocess.Popen:
12011203
adaptor_env = os.environ.copy()
12021204
if env:
@@ -1206,13 +1208,12 @@ def launch(
12061208
adaptor_env["LLDBDAP_LOG"] = log_file
12071209

12081210
args = [executable]
1209-
if connect:
1210-
if isinstance(connect, str) and connect.startswith("/"):
1211-
args.append("--unix-socket")
1212-
args.append(connect)
1213-
else:
1214-
args.append("--port")
1215-
args.append(str(connect))
1211+
if port:
1212+
args.append("--port")
1213+
args.append(str(port))
1214+
elif unix_socket:
1215+
args.append("--unix-socket")
1216+
args.append(unix_socket)
12161217

12171218
proc = subprocess.Popen(
12181219
args,
@@ -1222,7 +1223,7 @@ def launch(
12221223
env=adaptor_env,
12231224
)
12241225

1225-
if connect:
1226+
if port or unix_socket:
12261227
# Wait for the server to startup.
12271228
time.sleep(0.1)
12281229

lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class DAPTestCaseBase(TestBase):
1313
timeoutval = 10 * (10 if ('ASAN_OPTIONS' in os.environ) else 1)
1414
NO_DEBUG_INFO_TESTCASE = True
1515

16-
def create_debug_adaptor(self, env=None, launch=True, connect=None):
16+
def create_debug_adaptor(self, env=None, launch=True, port=None, unix_socket=None):
1717
"""Create the Visual Studio Code debug adaptor"""
1818
self.assertTrue(
1919
is_exe(self.lldbDAPExec), "lldb-dap must exist and be executable"
@@ -22,18 +22,19 @@ def create_debug_adaptor(self, env=None, launch=True, connect=None):
2222
self.dap_server = dap_server.DebugAdaptorServer(
2323
executable=self.lldbDAPExec,
2424
launch=launch,
25-
connect=connect,
25+
port=port,
26+
unix_socket=unix_socket,
2627
init_commands=self.setUpCommands(),
2728
log_file=log_file_path,
2829
env=env,
2930
)
3031

3132
def build_and_create_debug_adaptor(
32-
self, lldbDAPEnv=None, lldbDAPLaunch=True, lldbDAPConnect=None
33+
self, lldbDAPEnv=None, lldbDAPLaunch=True, lldbDAPPort=None, lldbDAPUnixSocket=None
3334
):
3435
self.build()
3536
self.create_debug_adaptor(
36-
lldbDAPEnv, launch=lldbDAPLaunch, connect=lldbDAPConnect
37+
lldbDAPEnv, launch=lldbDAPLaunch, port=lldbDAPPort, unix_socket=lldbDAPUnixSocket
3738
)
3839

3940
def set_source_breakpoints(self, source_path, lines, data=None):
@@ -481,13 +482,14 @@ def build_and_launch(
481482
customThreadFormat=None,
482483
launchCommands=None,
483484
expectFailure=False,
484-
lldbDAPConnect=None,
485+
lldbDAPPort=None,
486+
lldbDAPUnixSocket=None,
485487
lldbDAPLaunch=True,
486488
):
487489
"""Build the default Makefile target, create the DAP debug adaptor,
488490
and launch the process.
489491
"""
490-
self.build_and_create_debug_adaptor(lldbDAPEnv, lldbDAPLaunch, lldbDAPConnect)
492+
self.build_and_create_debug_adaptor(lldbDAPEnv=lldbDAPEnv, lldbDAPLaunch=lldbDAPLaunch, lldbDAPPort=lldbDAPPort, lldbDAPUnixSocket=lldbDAPUnixSocket)
491493
self.assertTrue(os.path.exists(program), "executable must exist")
492494

493495
return self.launch(

lldb/test/API/tools/lldb-dap/server/TestDAP_server.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@
1212

1313

1414
class TestDAP_server(lldbdap_testcase.DAPTestCaseBase):
15-
def do_test_server(self, connect):
15+
def do_test_server(self, port=None, unix_socket=None):
1616
log_file_path = self.getBuildArtifact("dap.txt")
17-
print("connect", connect)
1817
server = dap_server.DebugAdaptorServer.launch(
19-
self.lldbDAPExec, connect=connect, log_file=log_file_path
18+
self.lldbDAPExec, port=port, unix_socket=unix_socket, log_file=log_file_path
2019
)
2120

2221
def cleanup():
@@ -31,7 +30,7 @@ def cleanup():
3130
breakpoint_line = line_number(source, "// breakpoint")
3231

3332
# Initial connection over the port.
34-
self.create_debug_adaptor(launch=False, connect=connect)
33+
self.create_debug_adaptor(launch=False, port=port, unix_socket=unix_socket)
3534
self.launch(
3635
program,
3736
disconnectAutomatically=False,
@@ -44,7 +43,7 @@ def cleanup():
4443
self.dap_server.request_disconnect()
4544

4645
# Second connection over the port.
47-
self.create_debug_adaptor(launch=False, connect=connect)
46+
self.create_debug_adaptor(launch=False, port=port, unix_socket=unix_socket)
4847
self.launch(program)
4948
self.set_source_breakpoints(source, [breakpoint_line])
5049
self.continue_to_next_stop()
@@ -57,11 +56,11 @@ def test_server_port(self):
5756
Test launching a binary with a lldb-dap in server mode on a specific port.
5857
"""
5958
port = pickrandomport()
60-
self.do_test_server(port)
59+
self.do_test_server(port=port)
6160

6261
def test_server_unix_socket(self):
6362
"""
6463
Test launching a binary with a lldb-dap in server mode on a unix socket.
6564
"""
6665
dir = tempfile.gettempdir()
67-
self.do_test_server(dir + "/dap-connection-" + str(os.getpid()))
66+
self.do_test_server(unix_socket=dir + "/dap-connection-" + str(os.getpid()))

0 commit comments

Comments
 (0)