|
54 | 54 | from easybuild.tools.systemtools import get_cpu_architecture, get_cpu_family, get_cpu_features, get_cpu_model
|
55 | 55 | from easybuild.tools.systemtools import get_cpu_speed, get_cpu_vendor, get_gcc_version, get_glibc_version, get_os_type
|
56 | 56 | 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 |
58 | 58 | from easybuild.tools.systemtools import find_library_path, locate_solib, pick_dep_version, pick_system_specific_value
|
59 | 59 |
|
60 | 60 |
|
@@ -1453,6 +1453,34 @@ def test_get_cuda_architectures(self):
|
1453 | 1453 | # Restore original environment
|
1454 | 1454 | modify_env(os.environ, start_env, verbose=False)
|
1455 | 1455 |
|
| 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 | + |
1456 | 1484 |
|
1457 | 1485 | def suite(loader=None):
|
1458 | 1486 | """ returns all the testcases in this module """
|
|
0 commit comments