[lldb/test] Use realpath consistently for test root file paths.
authorJordan Rupprecht <rupprecht@google.com>
Wed, 5 Aug 2020 18:35:37 +0000 (11:35 -0700)
committerJordan Rupprecht <rupprecht@google.com>
Wed, 5 Aug 2020 18:35:37 +0000 (11:35 -0700)
commitfcb0d8163a4f3090cb85d77b459887cf1f84cc7e
treee493c1b08b0cd84be0f0d3a85b450ebc4391885b
parentf879c9b796210d0b2407d022e216cc4d907818a3
[lldb/test] Use realpath consistently for test root file paths.

LLDB tests assume that tests are in the test tree (the `LLDB_TEST_SRC` env variable, configured by `dotest.py`).
If this assertion doesn't hold, tests fail in strange ways. An early place this goes wrong is in `compute_mydir` which does a simple length-based substring to get the relative path. Later, we use that path to chdir to. If the test file and test tree don't agree in realpath-ness (and therefore length), this will be a cryptic error of chdir-ing to a directory that does not exist.

The actual discrepency is that the places we look for `use_lldb_suite.py` don't use a realpath, but `dotest.py` does (see initialization of `configuration.testdirs`).

It doesn't particularly matter whether we use realpath or abspath to canonicalize things, but many places end up with implicit dependencies on the canonicalized pwd being a realpath, so make them realpath consistently. Also, in the `compute_mydir` method mentioned, raise an error if the path types don't agree.

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D85258
lldb/packages/Python/lldbsuite/__init__.py
lldb/packages/Python/lldbsuite/test/lldbtest.py
lldb/test/API/use_lldb_suite.py