2
2
Test lldb-dap "port" configuration to "attach" request
3
3
"""
4
4
5
- import dap_server
6
5
from lldbsuite .test .decorators import *
7
6
from lldbsuite .test .lldbtest import *
8
- from lldbsuite .test import lldbutil
9
7
from lldbsuite .test import lldbplatformutil
10
8
from lldbgdbserverutils import Pipe
11
9
import 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
19
11
20
12
21
- @skip ("https://github.com/llvm/llvm-project/issues/138803" )
13
+ @skip (bugnumber = "https://github.com/llvm/llvm-project/issues/138803" )
22
14
class TestDAP_attachByPortNum (lldbdap_testcase .DAPTestCaseBase ):
23
- default_timeout = 20
24
-
25
15
def set_and_hit_breakpoint (self , continueToExit = True ):
26
16
self .dap_server .wait_for_stopped ()
27
17
@@ -50,7 +40,7 @@ def get_debug_server_command_line_args(self):
50
40
def get_debug_server_pipe (self ):
51
41
pipe = Pipe (self .getBuildDir ())
52
42
self .addTearDownHook (lambda : pipe .close ())
53
- pipe .finish_connection (self .default_timeout )
43
+ pipe .finish_connection (self .DEFAULT_TIMEOUT )
54
44
return pipe
55
45
56
46
@skipIfWindows
@@ -73,28 +63,33 @@ def test_by_port(self):
73
63
)
74
64
75
65
# 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 )
77
67
# Trim null byte, convert to int
78
68
port = int (port [:- 1 ])
79
69
self .assertIsNotNone (
80
70
port , " Failed to read the port number from debug server pipe"
81
71
)
82
72
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
+ )
84
79
self .set_and_hit_breakpoint (continueToExit = True )
85
- self .process .terminate ()
86
80
87
81
@skipIfWindows
88
82
@skipIfNetBSD
89
- def test_by_port_and_pid (self ):
83
+ def test_fails_if_both_port_and_pid_are_set (self ):
90
84
"""
91
85
Tests attaching to a process by process ID and port number.
92
86
"""
93
87
program = self .build_and_create_debug_adapter_for_attach ()
94
88
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.
98
93
99
94
pid = 1354
100
95
port = 1234
@@ -106,10 +101,9 @@ def test_by_port_and_pid(self):
106
101
sourceInitFile = True ,
107
102
expectFailure = True ,
108
103
)
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
+ )
113
107
114
108
@skipIfWindows
115
109
@skipIfNetBSD
@@ -123,11 +117,10 @@ def test_by_invalid_port(self):
123
117
response = self .attach (
124
118
program = program , gdbRemotePort = port , sourceInitFile = True , expectFailure = True
125
119
)
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
+ )
131
124
132
125
@skipIfWindows
133
126
@skipIfNetBSD
@@ -147,9 +140,7 @@ def test_by_illegal_port(self):
147
140
response = self .attach (
148
141
program = program , gdbRemotePort = port , sourceInitFile = True , expectFailure = True
149
142
)
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