]> git.ipfire.org Git - thirdparty/systemd.git/commit
tests: ASSERT_SIGNAL: Stop exit codes from masquerading as signals
authorChris Down <chris@chrisdown.name>
Wed, 19 Nov 2025 08:50:38 +0000 (16:50 +0800)
committerChris Down <chris@chrisdown.name>
Wed, 19 Nov 2025 18:40:07 +0000 (02:40 +0800)
commit39adecfcd84250f7e382c220ec7bcb2b0faa5193
tree0f077be6642431a82046ade6d14a204709f4223e
parent408e8d361fc179dd43f3ba91b9691abc52903134
tests: ASSERT_SIGNAL: Stop exit codes from masquerading as signals

When a child process exits normally (si_code == CLD_EXITED),
siginfo.si_status contains the exit code. When it is killed by a signal
(si_code == CLD_KILLED or CLD_DUMPED), si_status contains the signal
number.  However, assert_signal_internal() returns si_status blindly.
This causes exit codes to be misinterpreted as signal numbers.

This allows failing tests to silently pass if their exit code
numerically coincides with the expected signal. For example, a test
expecting SIGABRT (6) would incorrectly pass if the child simply exited
with status 6 instead of being killed by a signal.

Fix this by checking si_code. Only return si_status as a signal number
if the child was actually killed by a signal (CLD_KILLED or CLD_DUMPED).
If the child exited normally (CLD_EXITED), return 0 to indicate that no
signal occurred.
src/shared/tests.c
src/test/test-tests.c