[Lldb-commits] [lldb] [lldb] Change test paths to resolve symlinks (PR #132053)
David Peixotto via lldb-commits
lldb-commits at lists.llvm.org
Wed Mar 19 09:07:29 PDT 2025
https://github.com/dmpots created https://github.com/llvm/llvm-project/pull/132053
This commit modifes the `getSourceDir()` and `getBuildDir()` functions to use os.path.realpath to resolve symlinks in the Base test class used for API tests.
A few tests were failing when the build and source directories were located under a path that contained a symlink. These failures were because of cases where the symlink would be resolve to its real path in the source code, but the test code would try to match against the path with the symbolic link.
Two failing tests were
TestProcessLaunch.test_target_launch_working_dir_prop
TestSourceManager.test_source_cache_dump_and_clear
The inferior used `TestProcessLaunch` prints out its working directory using the `getcwd` function, which is not allowed to return symbolic links in the path components. When testing against the output from `getcwd` we should resolve the full path to match the expected output.
The `TestSourceManager` test sets a breakpoint on a main-copy.c file that is copied into the build output directory. The source manager resolves this file to its real location. When testing the output from the source cache we need to resolve the expected path to remove symlinks.
>From efde68cf06da2f668f4d2ecd638b826c7f4c5b70 Mon Sep 17 00:00:00 2001
From: David Peixotto <peix at meta.com>
Date: Wed, 19 Mar 2025 08:44:59 -0700
Subject: [PATCH] [lldb] Change test paths to resolve symlinks
This commit modifes the `getSourceDir()` and `getBuildDir()` functions
to use os.path.realpath to resolve symlinks in the Base test class used
for API tests.
A few tests were failing when the build and source directories were
located under a path that contained a symlink. These failures were
because of cases where the symlink would be resolve to its real path
in the source code, but the test code would try to match against
the path with the symbolic link.
Two failing tests were
TestProcessLaunch.test_target_launch_working_dir_prop
TestSourceManager.test_source_cache_dump_and_clear
The inferior used `TestProcessLaunch` prints out its working directory
using the `getcwd` function, which is not allowed to return symbolic
links in the path components. When testing against the output from
`getcwd` we should resolve the full path to match the expected output.
The `TestSourceManager` test sets a breakpoint on a main-copy.c file
that is copied into the build output directory. The source manager
resolves this file to its real location. When testing the output from
the source cache we need to resolve the expected path to remove
symlinks.
---
lldb/packages/Python/lldbsuite/test/lldbtest.py | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index 570c36b5f9622..7ac7aa368cc01 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -722,15 +722,17 @@ def clean_working_directory():
def getSourceDir(self):
"""Return the full path to the current test."""
- return os.path.join(configuration.test_src_root, self.mydir)
+ return os.path.realpath(os.path.join(configuration.test_src_root, self.mydir))
def getBuildDirBasename(self):
return self.__class__.__module__ + "." + self.testMethodName
def getBuildDir(self):
"""Return the full path to the current test."""
- return os.path.join(
- configuration.test_build_dir, self.mydir, self.getBuildDirBasename()
+ return os.path.realpath(
+ os.path.join(
+ configuration.test_build_dir, self.mydir, self.getBuildDirBasename()
+ )
)
def makeBuildDir(self):
More information about the lldb-commits
mailing list