Skip to content

Commit 4c0a6ca

Browse files
authored
Merge pull request #4975 from Flamefire/rpath-check-fix
Fix f-string in rpath check and skip check for linked libs on symlinks
2 parents b86526e + 1d657f2 commit 4c0a6ca

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

easybuild/framework/easyblock.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3831,7 +3831,7 @@ def sanity_check_rpath(self, rpath_dirs=None, check_readelf_rpath=None):
38313831
out = get_linked_libs_raw(path)
38323832

38333833
if out is None:
3834-
msg = "Failed to determine dynamically linked libraries for {path}, "
3834+
msg = f"Failed to determine dynamically linked libraries for {path}, "
38353835
msg += "so skipping it in RPATH sanity check"
38363836
self.log.debug(msg)
38373837
else:

easybuild/tools/systemtools.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,6 +1118,9 @@ def get_linked_libs_raw(path):
11181118
or None for other types of files.
11191119
"""
11201120

1121+
if os.path.islink(path):
1122+
_log.debug(f"{path} is a symbolic link, so skipping check for linked libs")
1123+
return None
11211124
res = run_shell_cmd("file %s" % path, fail_on_error=False, hidden=True, output_file=False, stream_output=False)
11221125
if res.exit_code != EasyBuildExit.SUCCESS:
11231126
fail_msg = "Failed to run 'file %s': %s" % (path, res.output)

test/framework/systemtools.py

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
from easybuild.tools.systemtools import get_cpu_architecture, get_cpu_family, get_cpu_features, get_cpu_model
5555
from easybuild.tools.systemtools import get_cpu_speed, get_cpu_vendor, get_gcc_version, get_glibc_version, get_os_type
5656
from easybuild.tools.systemtools import get_os_name, get_os_version, get_platform_name, get_shared_lib_ext
57-
from easybuild.tools.systemtools import get_system_info, get_total_memory
57+
from easybuild.tools.systemtools import get_system_info, get_total_memory, get_linked_libs_raw
5858
from easybuild.tools.systemtools import find_library_path, locate_solib, pick_dep_version, pick_system_specific_value
5959

6060

@@ -1453,6 +1453,34 @@ def test_get_cuda_architectures(self):
14531453
# Restore original environment
14541454
modify_env(os.environ, start_env, verbose=False)
14551455

1456+
def test_get_linked_libs_raw(self):
1457+
"""
1458+
Test get_linked_libs_raw function.
1459+
"""
1460+
bin_ls = which('ls')
1461+
linked_libs_out = get_linked_libs_raw(bin_ls)
1462+
os_type = get_os_type()
1463+
if os_type == LINUX:
1464+
libname = 'libc.so.6'
1465+
elif os_type == DARWIN:
1466+
libname = 'libSystem.B.dylib'
1467+
else:
1468+
self.fail(f"Unknown OS: {os_type}")
1469+
1470+
# check whether expected pattern is found
1471+
self.assertIn(libname, linked_libs_out)
1472+
1473+
# when specified path is a symlink or a non-binary file, None is the result
1474+
symlinked_ls = os.path.join(self.test_prefix, 'ls')
1475+
symlink(bin_ls, symlinked_ls)
1476+
res = get_linked_libs_raw(symlinked_ls)
1477+
self.assertEqual(res, None)
1478+
1479+
txt_file = os.path.join(self.test_prefix, 'test.txt')
1480+
write_file(txt_file, 'not-a-binary')
1481+
res = get_linked_libs_raw(txt_file)
1482+
self.assertEqual(res, None)
1483+
14561484

14571485
def suite(loader=None):
14581486
""" returns all the testcases in this module """

0 commit comments

Comments
 (0)