This is an archive of the discontinued LLVM Phabricator instance.

[test] Use realpath consistently for test root file paths.
ClosedPublic

Authored by rupprecht on Aug 4 2020, 4:43 PM.

Details

Summary

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.

Diff Detail

Event Timeline

rupprecht created this revision.Aug 4 2020, 4:43 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 4 2020, 4:43 PM
rupprecht requested review of this revision.Aug 4 2020, 4:43 PM
JDevlieghere added inline comments.Aug 4 2020, 6:49 PM
lldb/packages/Python/lldbsuite/test/lldbtest.py
499–504

While you are here... can you change this to pass the source directory trough the configuration?

rupprecht marked an inline comment as done.Aug 5 2020, 8:54 AM
rupprecht added inline comments.
lldb/packages/Python/lldbsuite/test/lldbtest.py
499–504

Absolutely, but in the spirit of small/isolated changes, split off as D85322.

JDevlieghere accepted this revision.Aug 5 2020, 10:01 AM
This revision is now accepted and ready to land.Aug 5 2020, 10:01 AM
This revision was automatically updated to reflect the committed changes.
rupprecht marked an inline comment as done.