diff --git a/lldb/packages/Python/lldbsuite/__init__.py b/lldb/packages/Python/lldbsuite/__init__.py --- a/lldb/packages/Python/lldbsuite/__init__.py +++ b/lldb/packages/Python/lldbsuite/__init__.py @@ -6,7 +6,8 @@ def find_lldb_root(): - lldb_root = os.path.dirname(inspect.getfile(inspect.currentframe())) + lldb_root = os.path.realpath( + os.path.dirname(inspect.getfile(inspect.currentframe()))) while True: parent = os.path.dirname(lldb_root) if parent == lldb_root: # dirname('/') == '/' diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py b/lldb/packages/Python/lldbsuite/test/lldbtest.py --- a/lldb/packages/Python/lldbsuite/test/lldbtest.py +++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py @@ -496,8 +496,12 @@ mydir = TestBase.compute_mydir(__file__) ''' # /abs/path/to/packages/group/subdir/mytest.py -> group/subdir - rel_prefix = test_file[len(os.environ["LLDB_TEST_SRC"]) + 1:] - return os.path.dirname(rel_prefix) + lldb_test_src = os.environ["LLDB_TEST_SRC"] + if not test_file.startswith(lldb_test_src): + raise Exception( + "Test file '%s' must reside within LLDB_TEST_SRC " + "(which is '%s')." % (test_file, lldb_test_src)) + return os.path.dirname(os.path.relpath(test_file, start=lldb_test_src)) def TraceOn(self): """Returns True if we are in trace mode (tracing detailed test execution).""" diff --git a/lldb/test/API/use_lldb_suite.py b/lldb/test/API/use_lldb_suite.py --- a/lldb/test/API/use_lldb_suite.py +++ b/lldb/test/API/use_lldb_suite.py @@ -4,9 +4,8 @@ def find_lldb_root(): - lldb_root = os.path.dirname( - os.path.abspath(inspect.getfile(inspect.currentframe())) - ) + lldb_root = os.path.realpath( + os.path.dirname(inspect.getfile(inspect.currentframe()))) while True: parent = os.path.dirname(lldb_root) if parent == lldb_root: # dirname('/') == '/'