Skip to content

Commit

Permalink
fix broken tests after symlinking lib -> lib64 before postinstallcmds
Browse files Browse the repository at this point in the history
  • Loading branch information
boegel committed Feb 7, 2024
1 parent 571b94d commit c578613
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions test/framework/toy_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -2414,7 +2414,7 @@ def test_sanity_check_paths_lib64(self):

# modify test easyconfig: move lib/libtoy.a to lib64/libtoy.a
ectxt = re.sub(r"\s*'files'.*", "'files': ['bin/toy', ('lib/libtoy.a', 'lib/libfoo.a')],", ectxt)
postinstallcmd = "mkdir %(installdir)s/lib64 && mv %(installdir)s/lib/libtoy.a %(installdir)s/lib64/libtoy.a"
postinstallcmd = "mkdir -p %(installdir)s/lib64 && mv %(installdir)s/lib/libtoy.a %(installdir)s/lib64/libtoy.a"
ectxt = re.sub("postinstallcmds.*", "postinstallcmds = ['%s']" % postinstallcmd, ectxt)

test_ec = os.path.join(self.test_prefix, 'toy-0.0.eb')
Expand Down Expand Up @@ -3829,7 +3829,6 @@ def test_toy_build_lib_lib64_symlink(self):
toy_ec = os.path.join(test_ecs, 't', 'toy', 'toy-0.0.eb')

test_ec_txt = read_file(toy_ec)
test_ec_txt += "\npostinstallcmds += ['mv %(installdir)s/lib %(installdir)s/lib64']"

test_ec = os.path.join(self.test_prefix, 'test.eb')
write_file(test_ec, test_ec_txt)
Expand All @@ -3842,30 +3841,30 @@ def test_toy_build_lib_lib64_symlink(self):
lib_path = os.path.join(toy_installdir, 'lib')
lib64_path = os.path.join(toy_installdir, 'lib64')

# lib64 subdir exists, is not a symlink
self.assertExists(lib64_path)
self.assertTrue(os.path.isdir(lib64_path))
self.assertFalse(os.path.islink(lib64_path))

# lib subdir is a symlink to lib64 subdir
# lib subdir exists, is not a symlink
self.assertExists(lib_path)
self.assertTrue(os.path.isdir(lib_path))
self.assertTrue(os.path.islink(lib_path))
self.assertTrue(os.path.samefile(lib_path, lib64_path))
self.assertFalse(os.path.islink(lib_path))

# lib64 subdir is a symlink to lib subdir
self.assertExists(lib64_path)
self.assertTrue(os.path.isdir(lib64_path))
self.assertTrue(os.path.islink(lib64_path))
self.assertTrue(os.path.samefile(lib64_path, lib_path))

# lib symlink should point to a relative path
self.assertFalse(os.path.isabs(os.readlink(lib_path)))
# lib64 symlink should point to a relative path
self.assertFalse(os.path.isabs(os.readlink(lib64_path)))

# cleanup and try again with --disable-lib-lib64-symlink
remove_dir(self.test_installpath)
with self.mocked_stdout_stderr():
self._test_toy_build(ec_file=test_ec, extra_args=['--disable-lib-lib64-symlink'])
self._test_toy_build(ec_file=test_ec, extra_args=['--disable-lib64-lib-symlink'])

self.assertExists(lib64_path)
self.assertNotExists(lib_path)
self.assertNotIn('lib', os.listdir(toy_installdir))
self.assertTrue(os.path.isdir(lib64_path))
self.assertFalse(os.path.islink(lib64_path))
self.assertExists(lib_path)
self.assertNotExists(lib64_path)
self.assertNotIn('lib64', os.listdir(toy_installdir))
self.assertTrue(os.path.isdir(lib_path))
self.assertFalse(os.path.islink(lib_path))

def test_toy_build_sanity_check_linked_libs(self):
"""Test sanity checks for banned/requires libraries."""
Expand Down

0 comments on commit c578613

Please sign in to comment.