[Lldb-commits] [lldb] [lldb-dap] Make dap tests tolerant of path separator (PR #197942)

Charles Zablit via lldb-commits lldb-commits at lists.llvm.org
Mon May 18 06:24:50 PDT 2026


https://github.com/charles-zablit updated https://github.com/llvm/llvm-project/pull/197942

>From e9d2b70e2fac78dcdc574eef02c8bb9e36ef80ec Mon Sep 17 00:00:00 2001
From: Charles Zablit <c_zablit at apple.com>
Date: Fri, 15 May 2026 16:24:42 +0200
Subject: [PATCH 1/2] [lldb-dap] Make dap tests tolerant of path separator

---
 .../platform/process/launch/TestPlatformProcessLaunch.py | 9 ++++++---
 .../API/tools/lldb-dap/launch/TestDAP_launch_basic.py    | 6 +++++-
 .../lldb-dap/launch/TestDAP_launch_stdio_redirection.py  | 4 +++-
 3 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/lldb/test/API/commands/platform/process/launch/TestPlatformProcessLaunch.py b/lldb/test/API/commands/platform/process/launch/TestPlatformProcessLaunch.py
index 7cbad03eeeead..ddbf984d6aaec 100644
--- a/lldb/test/API/commands/platform/process/launch/TestPlatformProcessLaunch.py
+++ b/lldb/test/API/commands/platform/process/launch/TestPlatformProcessLaunch.py
@@ -17,6 +17,9 @@ def setup(self):
         outfile = lldbutil.append_to_process_working_directory(self, "stdio.log")
         return (exe, outfile)
 
+    def _assert_stdio_log_matches(self, expected, actual):
+        self.assertEqual(expected.replace("\\", "/"), actual.replace("\\", "/"))
+
     def test_process_launch_no_args(self):
         # When there are no extra arguments we just have 0, the program name.
         exe, outfile = self.setup()
@@ -24,7 +27,7 @@ def test_process_launch_no_args(self):
         self.runCmd("continue")
 
         stdio_log = lldbutil.read_file_on_target(self, outfile)
-        self.assertEqual(
+        self._assert_stdio_log_matches(
             dedent(
                 """\
             Got 1 argument(s).
@@ -44,7 +47,7 @@ def test_process_launch_command_args(self):
         self.runCmd("continue")
 
         stdio_log = lldbutil.read_file_on_target(self, outfile)
-        self.assertEqual(
+        self._assert_stdio_log_matches(
             dedent(
                 """\
             Got 4 argument(s).
@@ -67,7 +70,7 @@ def test_process_launch_target_args(self):
         self.runCmd("continue")
 
         stdio_log = lldbutil.read_file_on_target(self, outfile)
-        self.assertEqual(
+        self._assert_stdio_log_matches(
             dedent(
                 """\
             Got 3 argument(s).
diff --git a/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch_basic.py b/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch_basic.py
index 93ae5d05e9d6c..437a9812b51ee 100644
--- a/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch_basic.py
+++ b/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch_basic.py
@@ -20,4 +20,8 @@ def test(self):
         output = self.get_stdout()
         self.assertTrue(output and len(output) > 0, "expect program output")
         lines = output.splitlines()
-        self.assertIn(program, lines[0], "make sure program path is in first argument")
+        self.assertIn(
+            program.replace("\\", "/"),
+            lines[0],
+            "make sure program path is in first argument",
+        )
diff --git a/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch_stdio_redirection.py b/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch_stdio_redirection.py
index 81501702624be..1376e964b97e4 100644
--- a/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch_stdio_redirection.py
+++ b/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch_stdio_redirection.py
@@ -20,5 +20,7 @@ def test(self):
             self.verify_process_exited()
             lines = f.readlines()
             self.assertIn(
-                program, lines[0], "make sure program path is in first argument"
+                program.replace("\\", "/"),
+                lines[0],
+                "make sure program path is in first argument",
             )

>From 07d1c20a0f187540a72aa383506e52989c64906d Mon Sep 17 00:00:00 2001
From: Charles Zablit <c_zablit at apple.com>
Date: Mon, 18 May 2026 15:24:36 +0200
Subject: [PATCH 2/2] denormalize the path instead

---
 .../Plugins/Process/gdb-remote/ProcessGDBRemote.cpp      | 2 +-
 .../platform/process/launch/TestPlatformProcessLaunch.py | 9 +++------
 .../API/tools/lldb-dap/launch/TestDAP_launch_basic.py    | 6 +-----
 .../lldb-dap/launch/TestDAP_launch_stdio_redirection.py  | 4 +---
 4 files changed, 6 insertions(+), 15 deletions(-)

diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index 8f55277f4a788..7c4b5a986940a 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -828,7 +828,7 @@ Status ProcessGDBRemote::DoLaunch(lldb_private::Module *exe_module,
       // make sure to use the actual executable path found in the launch_info...
       Args args = launch_info.GetArguments();
       if (FileSpec exe_file = launch_info.GetExecutableFile())
-        args.ReplaceArgumentAtIndex(0, exe_file.GetPath(false));
+        args.ReplaceArgumentAtIndex(0, exe_file.GetPath(/*denormalize=*/true));
       if (llvm::Error err = m_gdb_comm.LaunchProcess(args)) {
         error = Status::FromErrorStringWithFormatv(
             "Cannot launch '{0}': {1}", args.GetArgumentAtIndex(0),
diff --git a/lldb/test/API/commands/platform/process/launch/TestPlatformProcessLaunch.py b/lldb/test/API/commands/platform/process/launch/TestPlatformProcessLaunch.py
index ddbf984d6aaec..7cbad03eeeead 100644
--- a/lldb/test/API/commands/platform/process/launch/TestPlatformProcessLaunch.py
+++ b/lldb/test/API/commands/platform/process/launch/TestPlatformProcessLaunch.py
@@ -17,9 +17,6 @@ def setup(self):
         outfile = lldbutil.append_to_process_working_directory(self, "stdio.log")
         return (exe, outfile)
 
-    def _assert_stdio_log_matches(self, expected, actual):
-        self.assertEqual(expected.replace("\\", "/"), actual.replace("\\", "/"))
-
     def test_process_launch_no_args(self):
         # When there are no extra arguments we just have 0, the program name.
         exe, outfile = self.setup()
@@ -27,7 +24,7 @@ def test_process_launch_no_args(self):
         self.runCmd("continue")
 
         stdio_log = lldbutil.read_file_on_target(self, outfile)
-        self._assert_stdio_log_matches(
+        self.assertEqual(
             dedent(
                 """\
             Got 1 argument(s).
@@ -47,7 +44,7 @@ def test_process_launch_command_args(self):
         self.runCmd("continue")
 
         stdio_log = lldbutil.read_file_on_target(self, outfile)
-        self._assert_stdio_log_matches(
+        self.assertEqual(
             dedent(
                 """\
             Got 4 argument(s).
@@ -70,7 +67,7 @@ def test_process_launch_target_args(self):
         self.runCmd("continue")
 
         stdio_log = lldbutil.read_file_on_target(self, outfile)
-        self._assert_stdio_log_matches(
+        self.assertEqual(
             dedent(
                 """\
             Got 3 argument(s).
diff --git a/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch_basic.py b/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch_basic.py
index 437a9812b51ee..93ae5d05e9d6c 100644
--- a/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch_basic.py
+++ b/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch_basic.py
@@ -20,8 +20,4 @@ def test(self):
         output = self.get_stdout()
         self.assertTrue(output and len(output) > 0, "expect program output")
         lines = output.splitlines()
-        self.assertIn(
-            program.replace("\\", "/"),
-            lines[0],
-            "make sure program path is in first argument",
-        )
+        self.assertIn(program, lines[0], "make sure program path is in first argument")
diff --git a/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch_stdio_redirection.py b/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch_stdio_redirection.py
index 1376e964b97e4..81501702624be 100644
--- a/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch_stdio_redirection.py
+++ b/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch_stdio_redirection.py
@@ -20,7 +20,5 @@ def test(self):
             self.verify_process_exited()
             lines = f.readlines()
             self.assertIn(
-                program.replace("\\", "/"),
-                lines[0],
-                "make sure program path is in first argument",
+                program, lines[0], "make sure program path is in first argument"
             )



More information about the lldb-commits mailing list