Skip to content

Commit 1d657f2

Browse files
committed
add test for get_linked_libs_raw
1 parent 4646ae1 commit 1d657f2

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

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)