Skip to content

Commit efde68c

Browse files
committed
[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.
1 parent 2e39533 commit efde68c

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lldb/packages/Python/lldbsuite/test/lldbtest.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -722,15 +722,17 @@ def clean_working_directory():
722722

723723
def getSourceDir(self):
724724
"""Return the full path to the current test."""
725-
return os.path.join(configuration.test_src_root, self.mydir)
725+
return os.path.realpath(os.path.join(configuration.test_src_root, self.mydir))
726726

727727
def getBuildDirBasename(self):
728728
return self.__class__.__module__ + "." + self.testMethodName
729729

730730
def getBuildDir(self):
731731
"""Return the full path to the current test."""
732-
return os.path.join(
733-
configuration.test_build_dir, self.mydir, self.getBuildDirBasename()
732+
return os.path.realpath(
733+
os.path.join(
734+
configuration.test_build_dir, self.mydir, self.getBuildDirBasename()
735+
)
734736
)
735737

736738
def makeBuildDir(self):

0 commit comments

Comments
 (0)