tests: Adapt to glib 2.87.0#633
Merged
ppisar merged 1 commit intofedora-modularity:mainfrom Jan 14, 2026
Merged
Conversation
Collaborator
Author
|
The new way of running tests in a subprocess does work on old glib. I will implement a fallback. |
After upgrading glib from 2.86.1 to 2.87.0, tests which expect catching
SIGTRAP started to fail like this:
[...]/redhat-linux-build/modulemd/component_module
TAP version 14
# random seed: R02S501b6bd02413a2980133f197dab99416
1..6
# Start of modulemd tests
# Start of v2 tests
# Start of component tests
# Start of module tests
not ok /modulemd/v2/component/module/construct - libmodulemd-FATAL-CRITICAL: modulemd_component_set_key: assertion 'name' failed
Bail out!
Aborted (core dumped) LD_LIBRARY_PATH=/home/test/libmodulemd-devel/redhat-linux-build/modulemd MESON_BUILD_ROOT=/home/test/libmodulemd-devel/redhat-linux-build TEST_DATA_PATH=/home/test/libmodulemd-devel/modulemd/tests/test_data UBSAN_OPTIONS=halt_on_error=1:abort_on_error=1:print_summary=1:print_stacktrace=1 MSAN_OPTIONS=halt_on_error=1:abort_on_error=1:print_summary=1:print_stacktrace=1 LC_ALL=C MESON_TEST_ITERATION=1 MESON_SOURCE_ROOT=/home/test/libmodulemd-devel MALLOC_PERTURB_=115 ASAN_OPTIONS=halt_on_error=1:abort_on_error=1:print_summary=1 /home/test/libmodulemd-devel/redhat-linux-build/modulemd/component_module
The tests passed a NULL pointer to libmodulemd object constructors and
checked that glib raised a SIGTRAP signal. The new glib fixed
<https://gitlab.gnome.org/GNOME/glib/-/issues/3790> and as a side
effect changed how the process is terminated: If the process runs
under a debugger, a breakpoint trap is invoked or SIGTRAP raised,
depending on the architecture. If the process does not run under
a debugger, abort() is called, which raises SIGABRT and then after
returning to glib SIGABRT disposition is reset and SIGABRT raised
again to finally terminate the process. That means that catching
signals is pointless because the process will be terminated
nevertheless.
This patch adapts the tests by using a glib-sanctioned way of checking
whether a process terminated abnormally instead of depending on
a way a particular glib version implements.
This patch moves the trapping subtests into standalone tests because
g_test_trap_subprocess() cannot handle multiple subtests in a single
test function. It also removes pointless checks for a return value of
a function which has just exited the process.
The same goes for Python tests (with
G_DEBUG=fatal-warnings,fatal-criticals) which originally went as far
as checking whether and which signal was raised. This patch makes the
Python tests passing regardless of G_DEBUG setting.
Implementation note: Python does not support annoymous block and
context managers are not compatible with fork, hence this patch moves
the blocks into named callables to be exectuted in a subprocess.
Implementation note: Glib provides G_TEST_SUBPROCESS_DEFAULT constant
since 2.74. This patch adds a fallback definition instead of
hard-coding 0 literal.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2423153
Collaborator
Author
|
Now it builds everywhere. Mandriva has again (still?) broken dependencies in its packages. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
After upgrading glib from 2.86.1 to 2.87.0, tests which expect catching SIGTRAP started to fail like this:
The tests passed a NULL pointer to libmodulemd object constructors and checked that glib raised a SIGTRAP signal. The new glib fixed https://gitlab.gnome.org/GNOME/glib/-/issues/3790 and as a side effect changed how the process is terminated: If the process runs under a debugger, a breakpoint trap is invoked or SIGTRAP raised, depending on the architecture. If the process does not run under a debugger, abort() is called, which raises SIGABRT and then after returning to glib SIGABRT disposition is reset and SIGABRT raised again to finally terminate the process. That means that catching signals is pointless because the process will be terminated nevertheless.
This patch adapts the tests by using a glib-sanctioned way of checking whether a process terminated abnormally instead of depending on a way a particular glib version implements.
This patch moves the trapping subtests into standalone tests because g_test_trap_subprocess() cannot handle multiple subtests in a single test function. It also removes pointless checks for a return value of a function which has just exited the process.
The same goes for Python tests (with
G_DEBUG=fatal-warnings,fatal-criticals) which originally went as far as checking whether and which signal was raised. This patch makes the Python tests passing regardless of G_DEBUG setting.
Implementation note: Python does not support annoymous block and context managers are not compatible with fork, hence this patch moves the blocks into named callables to be exectuted in a subprocess.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2423153