tests: Adapt to glib 2.87.0 #633
Merged
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