Skip to content
Snippets Groups Projects
Commit bb77b2db authored by Simon McVittie's avatar Simon McVittie
Browse files

tests: Adjust assertions about LD_LIBRARY_PATH and ld.so.conf


Instead of being overly specific, let's assert that what we want to be
true is true. We want to see /overrides/lib/MULTIARCH in either the
ld.so.conf or the LD_LIBRARY_PATH, and /overrides/lib/MULTIARCH/aliases
in the LD_LIBRARY_PATH specifically.

If /overrides is not a symbolic link, then we want to find exactly
/overrides/lib/MULTIARCH in those places. If it is a symbolic link, then
we might see either /overrides/lib/MULTIARCH or
/usr/lib/pressure-vessel/overrides/lib/MULTIARCH; which one of those
we get is an implementation detail, but it must exist.

Signed-off-by: default avatarSimon McVittie <smcv@collabora.com>
parent 7bb9fdb6
Branches
Tags
1 merge request!357Fix test failures with --no-copy-runtime
This commit is part of merge request !357. Comments created here will be created in the context of that merge request.
......@@ -170,8 +170,13 @@ class TestInsideRuntime(BaseTest):
'LD_LIBRARY_PATH: %r', os.environ.get('LD_LIBRARY_PATH')
)
search = set() # type: typing.Set[str]
with open('/etc/ld.so.conf', 'r') as reader:
for line in reader:
if line.startswith('/'):
search.add(line.rstrip('\n'))
logger.info('/etc/ld.so.conf: %r', line)
if os.environ.get('TEST_INSIDE_RUNTIME_IS_SCOUT'):
......@@ -186,23 +191,56 @@ class TestInsideRuntime(BaseTest):
self.assertIsNotNone(os.environ.get('LD_LIBRARY_PATH'))
parts = os.environ.get('LD_LIBRARY_PATH', '').split(':')
ldlp = os.environ.get('LD_LIBRARY_PATH', '').split(':')
search |= set(ldlp)
if os.getenv('TEST_INSIDE_RUNTIME_IS_COPY'):
for path in parts:
# Only the aliases directories get into the LD_LIBRARY_PATH,
# not the directories containing SONAMEs
for path in ldlp:
self.assertTrue(path.endswith('/aliases'))
else:
if (
'HOST_LD_LINUX_SO_REALPATH' in os.environ
and Path('/usr/lib/i386-linux-gnu').is_dir()
):
self.assertIn('/overrides/lib/i386-linux-gnu', parts)
if (
'HOST_LD_LINUX_X86_64_SO_REALPATH' in os.environ
and Path('/usr/lib/x86_64-linux-gnu').is_dir()
):
self.assertIn('/overrides/lib/x86_64-linux-gnu', parts)
if (
'HOST_LD_LINUX_SO_REALPATH' in os.environ
and Path('/usr/lib/i386-linux-gnu').is_dir()
):
check_dir = '/overrides/lib/i386-linux-gnu'
if not Path('/overrides').is_symlink():
self.assertIn(check_dir, search)
self.assertIn(check_dir + '/aliases', ldlp)
self.assertTrue(Path(check_dir).is_dir())
self.assertTrue(Path(check_dir, 'aliases').is_dir())
if check_dir not in search:
check_dir = '/usr/lib/pressure-vessel' + check_dir
self.assertTrue(Path(check_dir).is_dir())
self.assertTrue(Path(check_dir, 'aliases').is_dir())
self.assertIn(check_dir, search)
self.assertIn(check_dir + '/aliases', ldlp)
if (
'HOST_LD_LINUX_X86_64_SO_REALPATH' in os.environ
and Path('/usr/lib/x86_64-linux-gnu').is_dir()
):
check_dir = '/overrides/lib/x86_64-linux-gnu'
if not Path('/overrides').is_symlink():
self.assertIn(check_dir, search)
self.assertIn(check_dir + '/aliases', ldlp)
self.assertTrue(Path(check_dir).is_dir())
self.assertTrue(Path(check_dir, 'aliases').is_dir())
if check_dir not in search:
check_dir = '/usr/lib/pressure-vessel' + check_dir
self.assertTrue(Path(check_dir).is_dir())
self.assertTrue(Path(check_dir, 'aliases').is_dir())
self.assertIn(check_dir, search)
self.assertIn(check_dir + '/aliases', ldlp)
def test_overrides(self) -> None:
if os.getenv('TEST_INSIDE_RUNTIME_IS_COPY'):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment