22Test lldb-dap runInTerminal reverse request
33"""
44
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
107import lldbdap_testcase
11- import time
128import os
139import subprocess
14- import shutil
1510import json
16- from threading import Thread
1711
1812
13+ @skipIfBuildType (["debug" ])
1914class TestDAP_runInTerminal (lldbdap_testcase .DAPTestCaseBase ):
20- def readPidMessage (self , fifo_file ):
15+ def read_pid_message (self , fifo_file ):
2116 with open (fifo_file , "r" ) as file :
2217 self .assertIn ("pid" , file .readline ())
2318
24- def sendDidAttachMessage (self , fifo_file ):
19+ @staticmethod
20+ def send_did_attach_message (fifo_file ):
2521 with open (fifo_file , "w" ) as file :
2622 file .write (json .dumps ({"kind" : "didAttach" }) + "\n " )
2723
28- def readErrorMessage (self , fifo_file ):
24+ @staticmethod
25+ def read_error_message (fifo_file ):
2926 with open (fifo_file , "r" ) as file :
3027 return file .readline ()
3128
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-
4629 @skipIfWindows
4730 @skipIf (oslist = ["linux" ], archs = no_match (["x86_64" ]))
4831 def test_runInTerminal (self ):
49- if not self .isTestSupported ():
50- return
5132 """
5233 Tests the "runInTerminal" reverse request. It makes sure that the IDE can
5334 launch the inferior with the correct environment variables and arguments.
@@ -77,7 +58,7 @@ def test_runInTerminal(self):
7758
7859 # We verify we actually stopped inside the loop
7960 counter = int (self .dap_server .get_local_variable_value ("counter" ))
80- self .assertGreater (counter , 0 )
61+ self .assertEqual (counter , 1 )
8162
8263 # We verify we were able to set the launch arguments
8364 argc = int (self .dap_server .get_local_variable_value ("argc" ))
@@ -90,10 +71,10 @@ def test_runInTerminal(self):
9071 env = self .dap_server .request_evaluate ("foo" )["body" ]["result" ]
9172 self .assertIn ("bar" , env )
9273
74+ self .continue_to_exit ()
75+
9376 @skipIf (oslist = ["linux" ], archs = no_match (["x86_64" ]))
9477 def test_runInTerminalWithObjectEnv (self ):
95- if not self .isTestSupported ():
96- return
9778 """
9879 Tests the "runInTerminal" reverse request. It makes sure that the IDE can
9980 launch the inferior with the correct environment variables using an object.
@@ -113,11 +94,11 @@ def test_runInTerminalWithObjectEnv(self):
11394 self .assertIn ("FOO" , request_envs )
11495 self .assertEqual ("BAR" , request_envs ["FOO" ])
11596
97+ self .continue_to_exit ()
98+
11699 @skipIfWindows
117100 @skipIf (oslist = ["linux" ], archs = no_match (["x86_64" ]))
118101 def test_runInTerminalInvalidTarget (self ):
119- if not self .isTestSupported ():
120- return
121102 self .build_and_create_debug_adapter ()
122103 response = self .launch (
123104 "INVALIDPROGRAM" ,
@@ -135,8 +116,6 @@ def test_runInTerminalInvalidTarget(self):
135116 @skipIfWindows
136117 @skipIf (oslist = ["linux" ], archs = no_match (["x86_64" ]))
137118 def test_missingArgInRunInTerminalLauncher (self ):
138- if not self .isTestSupported ():
139- return
140119 proc = subprocess .run (
141120 [self .lldbDAPExec , "--launch-target" , "INVALIDPROGRAM" ],
142121 capture_output = True ,
@@ -150,8 +129,6 @@ def test_missingArgInRunInTerminalLauncher(self):
150129 @skipIfWindows
151130 @skipIf (oslist = ["linux" ], archs = no_match (["x86_64" ]))
152131 def test_FakeAttachedRunInTerminalLauncherWithInvalidProgram (self ):
153- if not self .isTestSupported ():
154- return
155132 comm_file = os .path .join (self .getBuildDir (), "comm-file" )
156133 os .mkfifo (comm_file )
157134
@@ -167,18 +144,16 @@ def test_FakeAttachedRunInTerminalLauncherWithInvalidProgram(self):
167144 stderr = subprocess .PIPE ,
168145 )
169146
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 ))
173150
174151 _ , stderr = proc .communicate ()
175152 self .assertIn ("No such file or directory" , stderr )
176153
177154 @skipIfWindows
178155 @skipIf (oslist = ["linux" ], archs = no_match (["x86_64" ]))
179156 def test_FakeAttachedRunInTerminalLauncherWithValidProgram (self ):
180- if not self .isTestSupported ():
181- return
182157 comm_file = os .path .join (self .getBuildDir (), "comm-file" )
183158 os .mkfifo (comm_file )
184159
@@ -195,17 +170,15 @@ def test_FakeAttachedRunInTerminalLauncherWithValidProgram(self):
195170 stdout = subprocess .PIPE ,
196171 )
197172
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 )
200175
201176 stdout , _ = proc .communicate ()
202177 self .assertIn ("foo" , stdout )
203178
204179 @skipIfWindows
205180 @skipIf (oslist = ["linux" ], archs = no_match (["x86_64" ]))
206181 def test_FakeAttachedRunInTerminalLauncherAndCheckEnvironment (self ):
207- if not self .isTestSupported ():
208- return
209182 comm_file = os .path .join (self .getBuildDir (), "comm-file" )
210183 os .mkfifo (comm_file )
211184
@@ -216,17 +189,15 @@ def test_FakeAttachedRunInTerminalLauncherAndCheckEnvironment(self):
216189 env = {** os .environ , "FOO" : "BAR" },
217190 )
218191
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 )
221194
222195 stdout , _ = proc .communicate ()
223196 self .assertIn ("FOO=BAR" , stdout )
224197
225198 @skipIfWindows
226199 @skipIf (oslist = ["linux" ], archs = no_match (["x86_64" ]))
227200 def test_NonAttachedRunInTerminalLauncher (self ):
228- if not self .isTestSupported ():
229- return
230201 comm_file = os .path .join (self .getBuildDir (), "comm-file" )
231202 os .mkfifo (comm_file )
232203
@@ -244,7 +215,7 @@ def test_NonAttachedRunInTerminalLauncher(self):
244215 env = {** os .environ , "LLDB_DAP_RIT_TIMEOUT_IN_MS" : "1000" },
245216 )
246217
247- self .readPidMessage (comm_file )
218+ self .read_pid_message (comm_file )
248219
249220 _ , stderr = proc .communicate ()
250221 self .assertIn ("Timed out trying to get messages from the debug adapter" , stderr )
0 commit comments