runtest --path fails with symlinked ANDROID_BUILD_TOP
While reproducing b/2558977 I found that "runtest --path" did not work
for me because my ANDROID_BUILD_TOP contained a symlink. This is a
local fix to make FindTests use os.path.realpath instead of only half
using os.path.abspath when trying to make canonical paths to compare.
Change-Id: Ief353f52cb80b1798edc3c1233d1e082d9cebc26
diff --git a/testrunner/test_defs/test_walker.py b/testrunner/test_defs/test_walker.py
index 06c4e6d..948d53e 100755
--- a/testrunner/test_defs/test_walker.py
+++ b/testrunner/test_defs/test_walker.py
@@ -65,20 +65,20 @@
if not os.path.exists(path):
logger.Log('%s does not exist' % path)
return []
- abspath = os.path.abspath(path)
+ realpath = os.path.realpath(path)
# ensure path is in ANDROID_BUILD_ROOT
- self._build_top = android_build.GetTop()
- if not self._IsPathInBuildTree(abspath):
+ self._build_top = os.path.realpath(android_build.GetTop())
+ if not self._IsPathInBuildTree(realpath):
logger.Log('%s is not a sub-directory of build root %s' %
(path, self._build_top))
return []
# first, assume path is a parent directory, which specifies to run all
# tests within this directory
- tests = self._FindSubTests(abspath, [])
+ tests = self._FindSubTests(realpath, [])
if not tests:
logger.SilentLog('No tests found within %s, searching upwards' % path)
- tests = self._FindUpstreamTests(abspath)
+ tests = self._FindUpstreamTests(realpath)
return tests
def _IsPathInBuildTree(self, path):