Skip to content

Commit b2a820f

Browse files
committed
[lldb][lldb-dap][test] Enable Launch tests
Add Windows include equivalents for includes and shell command.
1 parent 2a28df6 commit b2a820f

File tree

2 files changed

+14
-20
lines changed

2 files changed

+14
-20
lines changed

lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
import lldbdap_testcase
1010
import time
1111
import os
12+
import re
1213

1314

1415
class TestDAP_launch(lldbdap_testcase.DAPTestCaseBase):
15-
@skipIfWindows
1616
def test_default(self):
1717
"""
1818
Tests the default launch of a simple program. No arguments,
@@ -27,7 +27,6 @@ def test_default(self):
2727
lines = output.splitlines()
2828
self.assertIn(program, lines[0], "make sure program path is in first argument")
2929

30-
@skipIfWindows
3130
def test_termination(self):
3231
"""
3332
Tests the correct termination of lldb-dap upon a 'disconnect'
@@ -47,7 +46,6 @@ def test_termination(self):
4746
# Check the return code
4847
self.assertEqual(self.dap_server.process.poll(), 0)
4948

50-
@skipIfWindows
5149
def test_stopOnEntry(self):
5250
"""
5351
Tests the default launch of a simple program that stops at the
@@ -66,7 +64,6 @@ def test_stopOnEntry(self):
6664
reason, "breakpoint", 'verify stop isn\'t "main" breakpoint'
6765
)
6866

69-
@skipIfWindows
7067
def test_cwd(self):
7168
"""
7269
Tests the default launch of a simple program with a current working
@@ -92,15 +89,17 @@ def test_cwd(self):
9289
)
9390
self.assertTrue(found, "verified program working directory")
9491

95-
@skipIfWindows
9692
def test_debuggerRoot(self):
9793
"""
9894
Tests the "debuggerRoot" will change the working directory of
9995
the lldb-dap debug adaptor.
10096
"""
10197
program = self.getBuildArtifact("a.out")
10298
program_parent_dir = os.path.realpath(os.path.dirname(os.path.dirname(program)))
103-
commands = ["platform shell echo cwd = $PWD"]
99+
100+
var = "%cd%" if lldbplatformutil.getHostPlatform() == "windows" else "$PWD"
101+
commands = [f"platform shell echo cwd = {var}"]
102+
104103
self.build_and_launch(
105104
program, debuggerRoot=program_parent_dir, initCommands=commands
106105
)
@@ -114,14 +113,13 @@ def test_debuggerRoot(self):
114113
found = True
115114
self.assertEqual(
116115
program_parent_dir,
117-
line[len(prefix) :],
116+
line.strip()[len(prefix) :],
118117
"lldb-dap working dir '%s' == '%s'"
119-
% (program_parent_dir, line[6:]),
118+
% (program_parent_dir, line[len(prefix) :]),
120119
)
121120
self.assertTrue(found, "verified lldb-dap working directory")
122121
self.continue_to_exit()
123122

124-
@skipIfWindows
125123
def test_sourcePath(self):
126124
"""
127125
Tests the "sourcePath" will set the target.source-map.
@@ -146,7 +144,6 @@ def test_sourcePath(self):
146144
self.assertTrue(found, 'found "sourcePath" in console output')
147145
self.continue_to_exit()
148146

149-
@skipIfWindows
150147
def test_disableSTDIO(self):
151148
"""
152149
Tests the default launch of a simple program with STDIO disabled.
@@ -182,7 +179,6 @@ def test_shellExpandArguments_enabled(self):
182179
quote_path, line, 'verify "%s" expanded to "%s"' % (glob, program)
183180
)
184181

185-
@skipIfWindows
186182
def test_shellExpandArguments_disabled(self):
187183
"""
188184
Tests the default launch of a simple program with shell expansion
@@ -204,7 +200,6 @@ def test_shellExpandArguments_disabled(self):
204200
quote_path, line, 'verify "%s" stayed to "%s"' % (glob, glob)
205201
)
206202

207-
@skipIfWindows
208203
def test_args(self):
209204
"""
210205
Tests launch of a simple program with arguments
@@ -229,7 +224,6 @@ def test_args(self):
229224
'arg[%i] "%s" not in "%s"' % (i + 1, quoted_arg, lines[i]),
230225
)
231226

232-
@skipIfWindows
233227
def test_environment(self):
234228
"""
235229
Tests launch of a simple program with environment variables
@@ -258,7 +252,6 @@ def test_environment(self):
258252
found, '"%s" must exist in program environment (%s)' % (var, lines)
259253
)
260254

261-
@skipIfWindows
262255
@skipIf(
263256
archs=["arm", "aarch64"]
264257
) # failed run https://lab.llvm.org/buildbot/#/builders/96/builds/6933
@@ -344,7 +337,6 @@ def test_commands(self):
344337
self.verify_commands("exitCommands", output, exitCommands)
345338
self.verify_commands("terminateCommands", output, terminateCommands)
346339

347-
@skipIfWindows
348340
def test_extra_launch_commands(self):
349341
"""
350342
Tests the "launchCommands" with extra launching settings
@@ -409,7 +401,6 @@ def test_extra_launch_commands(self):
409401
output = self.get_console(timeout=lldbdap_testcase.DAPTestCaseBase.timeoutval)
410402
self.verify_commands("exitCommands", output, exitCommands)
411403

412-
@skipIfWindows
413404
def test_failing_launch_commands(self):
414405
"""
415406
Tests "launchCommands" failures prevents a launch.
@@ -418,7 +409,8 @@ def test_failing_launch_commands(self):
418409
program = self.getBuildArtifact("a.out")
419410

420411
# Run an invalid launch command, in this case a bad path.
421-
launchCommands = ['!target create "/bad/path%s"' % (program)]
412+
bad_path = os.path.join("bad", "path")
413+
launchCommands = ['!target create "%s%s"' % (bad_path, program)]
422414

423415
initCommands = ["target list", "platform list"]
424416
preRunCommands = ["image list a.out", "image dump sections a.out"]
@@ -447,9 +439,8 @@ def test_failing_launch_commands(self):
447439
# Verify all "launchCommands" were founc in console output
448440
# The launch should fail due to the invalid command.
449441
self.verify_commands("launchCommands", output, launchCommands)
450-
self.assertRegex(output, r"bad/path/.*does not exist")
442+
self.assertRegex(output, re.escape(bad_path) + r".*does not exist")
451443

452-
@skipIfWindows
453444
@skipIfNetBSD # Hangs on NetBSD as well
454445
@skipIf(archs=["arm", "aarch64"], oslist=["linux"])
455446
def test_terminate_commands(self):
@@ -476,7 +467,6 @@ def test_terminate_commands(self):
476467
)
477468
self.verify_commands("terminateCommands", output, terminateCommands)
478469

479-
@skipIfWindows
480470
def test_version(self):
481471
"""
482472
Tests that "initialize" response contains the "version" string the same

lldb/test/API/tools/lldb-dap/launch/main.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
#include <stdio.h>
22
#include <stdlib.h>
3+
#ifdef _WIN32
4+
#include <direct.h>
5+
#else
36
#include <unistd.h>
7+
#endif
48

59
int main(int argc, char const *argv[], char const *envp[]) {
610
for (int i = 0; i < argc; ++i)

0 commit comments

Comments
 (0)