[Lldb-commits] [lldb] b2a820f - [lldb][lldb-dap][test] Enable Launch tests

David Spickett via lldb-commits lldb-commits at lists.llvm.org
Thu Aug 29 04:56:05 PDT 2024


Author: David Spickett
Date: 2024-08-29T11:55:35Z
New Revision: b2a820faea960e99123f309d6a7bccb3cd1bcc12

URL: https://github.com/llvm/llvm-project/commit/b2a820faea960e99123f309d6a7bccb3cd1bcc12
DIFF: https://github.com/llvm/llvm-project/commit/b2a820faea960e99123f309d6a7bccb3cd1bcc12.diff

LOG: [lldb][lldb-dap][test] Enable Launch tests

Add Windows include equivalents for includes and shell command.

Added: 
    

Modified: 
    lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py
    lldb/test/API/tools/lldb-dap/launch/main.c

Removed: 
    


################################################################################
diff  --git a/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py b/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py
index dd47a2db8709b9..a16f2da3c4df71 100644
--- a/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py
+++ b/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py
@@ -9,10 +9,10 @@
 import lldbdap_testcase
 import time
 import os
+import re
 
 
 class TestDAP_launch(lldbdap_testcase.DAPTestCaseBase):
-    @skipIfWindows
     def test_default(self):
         """
         Tests the default launch of a simple program. No arguments,
@@ -27,7 +27,6 @@ def test_default(self):
         lines = output.splitlines()
         self.assertIn(program, lines[0], "make sure program path is in first argument")
 
-    @skipIfWindows
     def test_termination(self):
         """
         Tests the correct termination of lldb-dap upon a 'disconnect'
@@ -47,7 +46,6 @@ def test_termination(self):
         # Check the return code
         self.assertEqual(self.dap_server.process.poll(), 0)
 
-    @skipIfWindows
     def test_stopOnEntry(self):
         """
         Tests the default launch of a simple program that stops at the
@@ -66,7 +64,6 @@ def test_stopOnEntry(self):
                         reason, "breakpoint", 'verify stop isn\'t "main" breakpoint'
                     )
 
-    @skipIfWindows
     def test_cwd(self):
         """
         Tests the default launch of a simple program with a current working
@@ -92,7 +89,6 @@ def test_cwd(self):
                 )
         self.assertTrue(found, "verified program working directory")
 
-    @skipIfWindows
     def test_debuggerRoot(self):
         """
         Tests the "debuggerRoot" will change the working directory of
@@ -100,7 +96,10 @@ def test_debuggerRoot(self):
         """
         program = self.getBuildArtifact("a.out")
         program_parent_dir = os.path.realpath(os.path.dirname(os.path.dirname(program)))
-        commands = ["platform shell echo cwd = $PWD"]
+
+        var = "%cd%" if lldbplatformutil.getHostPlatform() == "windows" else "$PWD"
+        commands = [f"platform shell echo cwd = {var}"]
+
         self.build_and_launch(
             program, debuggerRoot=program_parent_dir, initCommands=commands
         )
@@ -114,14 +113,13 @@ def test_debuggerRoot(self):
                 found = True
                 self.assertEqual(
                     program_parent_dir,
-                    line[len(prefix) :],
+                    line.strip()[len(prefix) :],
                     "lldb-dap working dir '%s' == '%s'"
-                    % (program_parent_dir, line[6:]),
+                    % (program_parent_dir, line[len(prefix) :]),
                 )
         self.assertTrue(found, "verified lldb-dap working directory")
         self.continue_to_exit()
 
-    @skipIfWindows
     def test_sourcePath(self):
         """
         Tests the "sourcePath" will set the target.source-map.
@@ -146,7 +144,6 @@ def test_sourcePath(self):
         self.assertTrue(found, 'found "sourcePath" in console output')
         self.continue_to_exit()
 
-    @skipIfWindows
     def test_disableSTDIO(self):
         """
         Tests the default launch of a simple program with STDIO disabled.
@@ -182,7 +179,6 @@ def test_shellExpandArguments_enabled(self):
                     quote_path, line, 'verify "%s" expanded to "%s"' % (glob, program)
                 )
 
-    @skipIfWindows
     def test_shellExpandArguments_disabled(self):
         """
         Tests the default launch of a simple program with shell expansion
@@ -204,7 +200,6 @@ def test_shellExpandArguments_disabled(self):
                     quote_path, line, 'verify "%s" stayed to "%s"' % (glob, glob)
                 )
 
-    @skipIfWindows
     def test_args(self):
         """
         Tests launch of a simple program with arguments
@@ -229,7 +224,6 @@ def test_args(self):
                 'arg[%i] "%s" not in "%s"' % (i + 1, quoted_arg, lines[i]),
             )
 
-    @skipIfWindows
     def test_environment(self):
         """
         Tests launch of a simple program with environment variables
@@ -258,7 +252,6 @@ def test_environment(self):
                 found, '"%s" must exist in program environment (%s)' % (var, lines)
             )
 
-    @skipIfWindows
     @skipIf(
         archs=["arm", "aarch64"]
     )  # failed run https://lab.llvm.org/buildbot/#/builders/96/builds/6933
@@ -344,7 +337,6 @@ def test_commands(self):
         self.verify_commands("exitCommands", output, exitCommands)
         self.verify_commands("terminateCommands", output, terminateCommands)
 
-    @skipIfWindows
     def test_extra_launch_commands(self):
         """
         Tests the "launchCommands" with extra launching settings
@@ -409,7 +401,6 @@ def test_extra_launch_commands(self):
         output = self.get_console(timeout=lldbdap_testcase.DAPTestCaseBase.timeoutval)
         self.verify_commands("exitCommands", output, exitCommands)
 
-    @skipIfWindows
     def test_failing_launch_commands(self):
         """
         Tests "launchCommands" failures prevents a launch.
@@ -418,7 +409,8 @@ def test_failing_launch_commands(self):
         program = self.getBuildArtifact("a.out")
 
         # Run an invalid launch command, in this case a bad path.
-        launchCommands = ['!target create "/bad/path%s"' % (program)]
+        bad_path = os.path.join("bad", "path")
+        launchCommands = ['!target create "%s%s"' % (bad_path, program)]
 
         initCommands = ["target list", "platform list"]
         preRunCommands = ["image list a.out", "image dump sections a.out"]
@@ -447,9 +439,8 @@ def test_failing_launch_commands(self):
         # Verify all "launchCommands" were founc in console output
         # The launch should fail due to the invalid command.
         self.verify_commands("launchCommands", output, launchCommands)
-        self.assertRegex(output, r"bad/path/.*does not exist")
+        self.assertRegex(output, re.escape(bad_path) + r".*does not exist")
 
-    @skipIfWindows
     @skipIfNetBSD  # Hangs on NetBSD as well
     @skipIf(archs=["arm", "aarch64"], oslist=["linux"])
     def test_terminate_commands(self):
@@ -476,7 +467,6 @@ def test_terminate_commands(self):
         )
         self.verify_commands("terminateCommands", output, terminateCommands)
 
-    @skipIfWindows
     def test_version(self):
         """
         Tests that "initialize" response contains the "version" string the same

diff  --git a/lldb/test/API/tools/lldb-dap/launch/main.c b/lldb/test/API/tools/lldb-dap/launch/main.c
index 01e209ac12c665..6370b415807f75 100644
--- a/lldb/test/API/tools/lldb-dap/launch/main.c
+++ b/lldb/test/API/tools/lldb-dap/launch/main.c
@@ -1,6 +1,10 @@
 #include <stdio.h>
 #include <stdlib.h>
+#ifdef _WIN32
+#include <direct.h>
+#else
 #include <unistd.h>
+#endif
 
 int main(int argc, char const *argv[], char const *envp[]) {
   for (int i = 0; i < argc; ++i)


        


More information about the lldb-commits mailing list