From 76196c43664af87036234c2595499328d73ff50f Mon Sep 17 00:00:00 2001 From: Frederic Leger Date: Wed, 25 Sep 2024 16:33:09 +0200 Subject: [PATCH] Fix shared libraries closure test Some tests are executed on the current interpreter, but with a static list of ignored shared libraries. This list is very host-specific, and fail on nightly GAIA tests. The list of ignored shared libraries is now incomplete, an error should be raised. The test now makes sure that none of the shared libraries reported as errors belong to the list of ignored libraries. Closes #16 --- tests/tests_e3/anod/spec_test.py | 34 ++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/tests/tests_e3/anod/spec_test.py b/tests/tests_e3/anod/spec_test.py index 47a553de..13678b5c 100644 --- a/tests/tests_e3/anod/spec_test.py +++ b/tests/tests_e3/anod/spec_test.py @@ -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", @@ -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(