Skip to content

Commit

Permalink
Merge branch 'mr/leger/7-shared-lib-closure-check-does-not-raise-exce…
Browse files Browse the repository at this point in the history
…ption-if-a-shared-lib-is-not-found' into 'master'

Resolve "Shared lib closure check does not raise exception if a shared lib is not found"

Closes #7

See merge request it/e3-core!17
  • Loading branch information
grouigrokon committed Jul 22, 2024
2 parents 502cad9 + 515adf4 commit 69b819f
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 9 deletions.
24 changes: 17 additions & 7 deletions src/e3/anod/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,23 @@ def check_shared_libraries_closure(
# Line looks like:
# `` otherdll.so => /other/otherdll.so (0xabcd)``
name, path = line.strip().split(" => ", 1)

if case_sensitive:
in_ignored = len([k for k in ignored if name.startswith(k)]) > 0
else:
in_ignored = (
len([k for k in ignored if name.lower().startswith(k.lower())])
> 0
)

# Make sure there are no "not found" errors
if "not found" in line.lower():
if not in_ignored:
if lib_file not in errors:
errors[lib_file] = []
errors[lib_file].append(f"\n\t- {name}: {path}")
continue

path = re.sub(" (.*)", "", path)

# Make sure a path is defined, we may have lines like::
Expand All @@ -494,13 +511,6 @@ def check_shared_libraries_closure(
if not path.strip() or not Path(path).exists():
continue

if case_sensitive:
in_ignored = len([k for k in ignored if name.startswith(k)]) > 0
else:
in_ignored = (
len([k for k in ignored if name.lower().startswith(k.lower())])
> 0
)
if os.path.relpath(path, root_dir).startswith("..") and not in_ignored:
if lib_file not in errors:
errors[lib_file] = []
Expand Down
32 changes: 30 additions & 2 deletions tests/tests_e3/anod/spec_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,34 @@
),
),
),
(
(
(
"/usr/bin/ls:\n"
"\tlinux-vdso.so.1 (0xxxx)\n"
"\tlibselinux.so.1 => /lib/x86_64-linux-gnu/libselinux.so.1 (0xxxx)\n"
"\tlibc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0xxxx)\n"
"\tlibpcre2-8.so.0 => not found\n"
"\t/lib64/ld-linux-x86-64.so.2 (0xxxx)\n"
),
["libc.so.6", "libselinux.so.1"],
),
(("- libpcre2-8.so.0: not found"),),
),
(
(
(
"/usr/bin/ls:\n"
"\tlinux-vdso.so.1 (0xxxx)\n"
"\tlibselinux.so.1 => /lib/x86_64-linux-gnu/libselinux.so.1 (0xxxx)\n"
"\tlibc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0xxxx)\n"
"\tlibpcre2-8.so.0 => not found\n"
"\t/lib64/ld-linux-x86-64.so.2 (0xxxx)\n"
),
["libc.so.6", "libselinux.so.1", "libpcre2-8.so.0"],
),
(None,),
),
]


Expand Down Expand Up @@ -173,13 +201,13 @@ def test_spec_check_dll_closure(ldd, arguments: tuple, expected: tuple) -> None:
elif errors:
with pytest.raises(AnodError) as ae:
test_spec.check_shared_libraries_closure(
prefix=None, ignored_libs=None, ldd_output=ldd_output
prefix=None, ignored_libs=ignored, ldd_output=ldd_output
)
assert errors in ae.value.args[0]
else:
# There is an ldd_output, but no errors may be raised on unix hosts.
test_spec.check_shared_libraries_closure(
prefix=None, ignored_libs=None, ldd_output=ldd_output
prefix=None, ignored_libs=ignored, ldd_output=ldd_output
)


Expand Down

0 comments on commit 69b819f

Please sign in to comment.