[Lldb-commits] [lldb] [lldb] Change test paths to resolve symlinks (PR #132053)
via lldb-commits
lldb-commits at lists.llvm.org
Wed Mar 19 09:08:08 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-lldb
Author: David Peixotto (dmpots)
<details>
<summary>Changes</summary>
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/132053.diff
1 Files Affected:
- (modified) lldb/packages/Python/lldbsuite/test/lldbtest.py (+5-3)
``````````diff
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):
``````````
</details>
https://github.com/llvm/llvm-project/pull/132053
More information about the lldb-commits
mailing list