Skip to content

Commit

Permalink
Merge branch 'mr/leger/master/fix-dll-closure-may-contain-system-libr…
Browse files Browse the repository at this point in the history
…aries' into 'master'

Fix shared libraries closure test

Closes #16

See merge request it/e3-core!44
  • Loading branch information
grouigrokon committed Sep 25, 2024
2 parents 38ce4dc + 76196c4 commit 589c18f
Showing 1 changed file with 28 additions and 6 deletions.
34 changes: 28 additions & 6 deletions tests/tests_e3/anod/spec_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,12 @@
(
None,
[
"libc.so.6",
"libstdc++.so.6",
"libstdc++.so.6",
"libgcc_s.so.1",
"libpthread.so.0",
"libdl.so.2",
"libm.so.6",
# Windows ignored Dlls.
"ADVAPI32.dll",
"CRYPTBASE.DLL",
"Comctl32.dll",
"FreeImage.dll",
Expand Down Expand Up @@ -195,9 +192,34 @@ def test_spec_check_dll_closure(ldd, arguments: tuple, expected: tuple) -> None:
lib_path: Path = Path(
exe_path.parent.parent, "lib" if sys.platform != "win32" else ""
)
test_spec.check_shared_libraries_closure(
prefix=str(lib_path), ignored_libs=ignored, ldd_output=None
)
try:
test_spec.check_shared_libraries_closure(
prefix=str(lib_path), ignored_libs=ignored, ldd_output=None
)
except AnodError as ae:
# As the list of shared libraries used by the interpreter varies
# from a host to another, we may catch exceptions. In that case,
# just make sure the libraries listed in the ignored list do not
# appear in the error message.
if len(ae.messages) > 0:
error_messages: list[str] = ae.messages[0].splitlines()
culprit_dlls: list[str] = []
dll_name: str
for msg in error_messages:
if msg.strip().startswith("- "):
dll_name = msg.strip()[2:].split(":")[0].strip()
if dll_name not in culprit_dlls:
culprit_dlls.append(dll_name)
# Check that none of the dlls listed in the error message
# actually belongs to the ignored dlls.
for culprit_dll in culprit_dlls:
if culprit_dll in ignored:
raise Exception(
f"Shared library {culprit_dll} is listed in the "
"dll closure errors, while it should be ignored"
) from ae
else:
raise ae
elif errors:
with pytest.raises(AnodError) as ae:
test_spec.check_shared_libraries_closure(
Expand Down

0 comments on commit 589c18f

Please sign in to comment.