2
2
Test lldb-dap runInTerminal reverse request
3
3
"""
4
4
5
-
6
- import dap_server
7
- from lldbsuite .test .decorators import *
8
- from lldbsuite .test .lldbtest import *
9
- from lldbsuite .test import lldbutil
5
+ from lldbsuite .test .decorators import skipIfBuildType , skipIfWindows , skipIf , no_match
6
+ from lldbsuite .test .lldbtest import line_number
10
7
import lldbdap_testcase
11
- import time
12
8
import os
13
9
import subprocess
14
- import shutil
15
10
import json
16
- from threading import Thread
17
11
18
12
13
+ @skipIfBuildType (["debug" ])
19
14
class TestDAP_runInTerminal (lldbdap_testcase .DAPTestCaseBase ):
20
- def readPidMessage (self , fifo_file ):
15
+ def read_pid_message (self , fifo_file ):
21
16
with open (fifo_file , "r" ) as file :
22
17
self .assertIn ("pid" , file .readline ())
23
18
24
- def sendDidAttachMessage (self , fifo_file ):
19
+ @staticmethod
20
+ def send_did_attach_message (fifo_file ):
25
21
with open (fifo_file , "w" ) as file :
26
22
file .write (json .dumps ({"kind" : "didAttach" }) + "\n " )
27
23
28
- def readErrorMessage (self , fifo_file ):
24
+ @staticmethod
25
+ def read_error_message (fifo_file ):
29
26
with open (fifo_file , "r" ) as file :
30
27
return file .readline ()
31
28
32
- def isTestSupported (self ):
33
- # For some strange reason, this test fails on python3.6
34
- if not (sys .version_info .major == 3 and sys .version_info .minor >= 7 ):
35
- return False
36
- try :
37
- # We skip this test for debug builds because it takes too long parsing lldb's own
38
- # debug info. Release builds are fine.
39
- # Checking the size of the lldb-dap binary seems to be a decent proxy for a quick
40
- # detection. It should be far less than 1 MB in Release builds.
41
- if os .path .getsize (os .environ ["LLDBDAP_EXEC" ]) < 1000000 :
42
- return True
43
- except :
44
- return False
45
-
46
29
@skipIfWindows
47
30
@skipIf (oslist = ["linux" ], archs = no_match (["x86_64" ]))
48
31
def test_runInTerminal (self ):
49
- if not self .isTestSupported ():
50
- return
51
32
"""
52
33
Tests the "runInTerminal" reverse request. It makes sure that the IDE can
53
34
launch the inferior with the correct environment variables and arguments.
@@ -77,7 +58,7 @@ def test_runInTerminal(self):
77
58
78
59
# We verify we actually stopped inside the loop
79
60
counter = int (self .dap_server .get_local_variable_value ("counter" ))
80
- self .assertGreater (counter , 0 )
61
+ self .assertEqual (counter , 1 )
81
62
82
63
# We verify we were able to set the launch arguments
83
64
argc = int (self .dap_server .get_local_variable_value ("argc" ))
@@ -90,10 +71,10 @@ def test_runInTerminal(self):
90
71
env = self .dap_server .request_evaluate ("foo" )["body" ]["result" ]
91
72
self .assertIn ("bar" , env )
92
73
74
+ self .continue_to_exit ()
75
+
93
76
@skipIf (oslist = ["linux" ], archs = no_match (["x86_64" ]))
94
77
def test_runInTerminalWithObjectEnv (self ):
95
- if not self .isTestSupported ():
96
- return
97
78
"""
98
79
Tests the "runInTerminal" reverse request. It makes sure that the IDE can
99
80
launch the inferior with the correct environment variables using an object.
@@ -113,11 +94,11 @@ def test_runInTerminalWithObjectEnv(self):
113
94
self .assertIn ("FOO" , request_envs )
114
95
self .assertEqual ("BAR" , request_envs ["FOO" ])
115
96
97
+ self .continue_to_exit ()
98
+
116
99
@skipIfWindows
117
100
@skipIf (oslist = ["linux" ], archs = no_match (["x86_64" ]))
118
101
def test_runInTerminalInvalidTarget (self ):
119
- if not self .isTestSupported ():
120
- return
121
102
self .build_and_create_debug_adapter ()
122
103
response = self .launch (
123
104
"INVALIDPROGRAM" ,
@@ -135,8 +116,6 @@ def test_runInTerminalInvalidTarget(self):
135
116
@skipIfWindows
136
117
@skipIf (oslist = ["linux" ], archs = no_match (["x86_64" ]))
137
118
def test_missingArgInRunInTerminalLauncher (self ):
138
- if not self .isTestSupported ():
139
- return
140
119
proc = subprocess .run (
141
120
[self .lldbDAPExec , "--launch-target" , "INVALIDPROGRAM" ],
142
121
capture_output = True ,
@@ -150,8 +129,6 @@ def test_missingArgInRunInTerminalLauncher(self):
150
129
@skipIfWindows
151
130
@skipIf (oslist = ["linux" ], archs = no_match (["x86_64" ]))
152
131
def test_FakeAttachedRunInTerminalLauncherWithInvalidProgram (self ):
153
- if not self .isTestSupported ():
154
- return
155
132
comm_file = os .path .join (self .getBuildDir (), "comm-file" )
156
133
os .mkfifo (comm_file )
157
134
@@ -167,18 +144,16 @@ def test_FakeAttachedRunInTerminalLauncherWithInvalidProgram(self):
167
144
stderr = subprocess .PIPE ,
168
145
)
169
146
170
- self .readPidMessage (comm_file )
171
- self .sendDidAttachMessage (comm_file )
172
- self .assertIn ("No such file or directory" , self .readErrorMessage (comm_file ))
147
+ self .read_pid_message (comm_file )
148
+ self .send_did_attach_message (comm_file )
149
+ self .assertIn ("No such file or directory" , self .read_error_message (comm_file ))
173
150
174
151
_ , stderr = proc .communicate ()
175
152
self .assertIn ("No such file or directory" , stderr )
176
153
177
154
@skipIfWindows
178
155
@skipIf (oslist = ["linux" ], archs = no_match (["x86_64" ]))
179
156
def test_FakeAttachedRunInTerminalLauncherWithValidProgram (self ):
180
- if not self .isTestSupported ():
181
- return
182
157
comm_file = os .path .join (self .getBuildDir (), "comm-file" )
183
158
os .mkfifo (comm_file )
184
159
@@ -195,17 +170,15 @@ def test_FakeAttachedRunInTerminalLauncherWithValidProgram(self):
195
170
stdout = subprocess .PIPE ,
196
171
)
197
172
198
- self .readPidMessage (comm_file )
199
- self .sendDidAttachMessage (comm_file )
173
+ self .read_pid_message (comm_file )
174
+ self .send_did_attach_message (comm_file )
200
175
201
176
stdout , _ = proc .communicate ()
202
177
self .assertIn ("foo" , stdout )
203
178
204
179
@skipIfWindows
205
180
@skipIf (oslist = ["linux" ], archs = no_match (["x86_64" ]))
206
181
def test_FakeAttachedRunInTerminalLauncherAndCheckEnvironment (self ):
207
- if not self .isTestSupported ():
208
- return
209
182
comm_file = os .path .join (self .getBuildDir (), "comm-file" )
210
183
os .mkfifo (comm_file )
211
184
@@ -216,17 +189,15 @@ def test_FakeAttachedRunInTerminalLauncherAndCheckEnvironment(self):
216
189
env = {** os .environ , "FOO" : "BAR" },
217
190
)
218
191
219
- self .readPidMessage (comm_file )
220
- self .sendDidAttachMessage (comm_file )
192
+ self .read_pid_message (comm_file )
193
+ self .send_did_attach_message (comm_file )
221
194
222
195
stdout , _ = proc .communicate ()
223
196
self .assertIn ("FOO=BAR" , stdout )
224
197
225
198
@skipIfWindows
226
199
@skipIf (oslist = ["linux" ], archs = no_match (["x86_64" ]))
227
200
def test_NonAttachedRunInTerminalLauncher (self ):
228
- if not self .isTestSupported ():
229
- return
230
201
comm_file = os .path .join (self .getBuildDir (), "comm-file" )
231
202
os .mkfifo (comm_file )
232
203
@@ -244,7 +215,7 @@ def test_NonAttachedRunInTerminalLauncher(self):
244
215
env = {** os .environ , "LLDB_DAP_RIT_TIMEOUT_IN_MS" : "1000" },
245
216
)
246
217
247
- self .readPidMessage (comm_file )
218
+ self .read_pid_message (comm_file )
248
219
249
220
_ , stderr = proc .communicate ()
250
221
self .assertIn ("Timed out trying to get messages from the debug adapter" , stderr )
0 commit comments