Skip to content

Commit

Permalink
Merge pull request systemd#30656 from mrc0mmand/dfuzzer-shenanigans
Browse files Browse the repository at this point in the history
test: avoid starting/stopping unwanted units during fuzzing
  • Loading branch information
yuwata authored Dec 30, 2023
2 parents 73780aa + 77baca2 commit 2d0be46
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
3 changes: 2 additions & 1 deletion test/test-functions
Original file line number Diff line number Diff line change
Expand Up @@ -1840,7 +1840,8 @@ save_journal() {
# Show messages from the testsuite-XX.service or messages with priority "warning" and higher
echo " --- $source_dir ---"
"$JOURNALCTL" --no-pager --no-hostname -o short-monotonic -D "$source_dir" \
_SYSTEMD_UNIT="testsuite-${TESTID:?}.service" + PRIORITY=4 + PRIORITY=3 + PRIORITY=2 + PRIORITY=1 + PRIORITY=0
_SYSTEMD_UNIT="testsuite-${TESTID:?}.service" + SYSLOG_IDENTIFIER="testsuite-$TESTID.sh" + \
PRIORITY=4 + PRIORITY=3 + PRIORITY=2 + PRIORITY=1 + PRIORITY=0

if get_bool "$save"; then
# If we don't have systemd-journal-remote copy all journals from /var/log/journal/
Expand Down
22 changes: 19 additions & 3 deletions test/units/testsuite-21.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,32 @@ at_exit() {
fi
}

add_suppression() {
local interface="${1:?}"
local suppression="${2:?}"

sed -i "\%\[$interface\]%a$suppression" /etc/dfuzzer.conf
}

trap at_exit EXIT

systemctl log-level info

# FIXME: systemd-run doesn't play well with daemon-reexec
# See: https://github.com/systemd/systemd/issues/27204
sed -i '/\[org.freedesktop.systemd1\]/aorg.freedesktop.systemd1.Manager:Reexecute FIXME' /etc/dfuzzer.conf
add_suppression "org.freedesktop.systemd1" "org.freedesktop.systemd1.Manager:Reexecute FIXME"

add_suppression "org.freedesktop.systemd1" "org.freedesktop.systemd1.Manager:SoftReboot destructive"
add_suppression "org.freedesktop.login1" "Sleep destructive"

# Skip calling start and stop methods on unit objects, as doing that is not only time consuming, but it also
# starts/stops units that interfere with the machine state. The actual code paths should be covered (to some
# degree) by the respective method counterparts on the manager object.
for method in Start Stop Restart ReloadOrRestart ReloadOrTryRestart Kill; do
add_suppression "org.freedesktop.systemd1" "org.freedesktop.systemd1.Unit:$method"
done

sed -i '/\[org.freedesktop.systemd1\]/aorg.freedesktop.systemd1.Manager:SoftReboot destructive' /etc/dfuzzer.conf
sed -i '/\[org.freedesktop.login1\]/aSleep destructive' /etc/dfuzzer.conf
cat /etc/dfuzzer.conf

# TODO
# * check for possibly newly introduced buses?
Expand Down

0 comments on commit 2d0be46

Please sign in to comment.