Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion easybuild/framework/easyblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -3804,7 +3804,7 @@ def sanity_check_rpath(self, rpath_dirs=None, check_readelf_rpath=None):
out = get_linked_libs_raw(path)

if out is None:
msg = "Failed to determine dynamically linked libraries for {path}, "
msg = f"Failed to determine dynamically linked libraries for {path}, "
msg += "so skipping it in RPATH sanity check"
self.log.debug(msg)
else:
Expand Down
3 changes: 3 additions & 0 deletions easybuild/tools/systemtools.py
Original file line number Diff line number Diff line change
Expand Up @@ -1118,6 +1118,9 @@ def get_linked_libs_raw(path):
or None for other types of files.
"""

if os.path.islink(path):
_log.debug(f"{path} is a symbolic link, so skipping check for linked libs")
return None
res = run_shell_cmd("file %s" % path, fail_on_error=False, hidden=True, output_file=False, stream_output=False)
if res.exit_code != EasyBuildExit.SUCCESS:
fail_msg = "Failed to run 'file %s': %s" % (path, res.output)
Expand Down
30 changes: 29 additions & 1 deletion test/framework/systemtools.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
from easybuild.tools.systemtools import get_cpu_architecture, get_cpu_family, get_cpu_features, get_cpu_model
from easybuild.tools.systemtools import get_cpu_speed, get_cpu_vendor, get_gcc_version, get_glibc_version, get_os_type
from easybuild.tools.systemtools import get_os_name, get_os_version, get_platform_name, get_shared_lib_ext
from easybuild.tools.systemtools import get_system_info, get_total_memory
from easybuild.tools.systemtools import get_system_info, get_total_memory, get_linked_libs_raw
from easybuild.tools.systemtools import find_library_path, locate_solib, pick_dep_version, pick_system_specific_value


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

def test_get_linked_libs_raw(self):
"""
Test get_linked_libs_raw function.
"""
bin_ls = which('ls')
linked_libs_out = get_linked_libs_raw(bin_ls)
os_type = get_os_type()
if os_type == LINUX:
libname = 'libc.so.6'
elif os_type == DARWIN:
libname = 'libSystem.B.dylib'
else:
self.fail(f"Unknown OS: {os_type}")

# check whether expected pattern is found
self.assertIn(libname, linked_libs_out)

# when specified path is a symlink or a non-binary file, None is the result
symlinked_ls = os.path.join(self.test_prefix, 'ls')
symlink(bin_ls, symlinked_ls)
res = get_linked_libs_raw(symlinked_ls)
self.assertEqual(res, None)

txt_file = os.path.join(self.test_prefix, 'test.txt')
write_file(txt_file, 'not-a-binary')
res = get_linked_libs_raw(txt_file)
self.assertEqual(res, None)


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