From bcdb5d4c0bc031cbc789942329a6cc84862730a0 Mon Sep 17 00:00:00 2001 From: Frantisek Sumsal Date: Thu, 28 Dec 2023 23:15:42 +0100 Subject: [PATCH 1/3] test: wrap adding a suppression in a method --- test/units/testsuite-21.sh | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/test/units/testsuite-21.sh b/test/units/testsuite-21.sh index 0b0dfc6c83..ed0f88e2b2 100755 --- a/test/units/testsuite-21.sh +++ b/test/units/testsuite-21.sh @@ -21,16 +21,25 @@ 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" -sed -i '/\[org.freedesktop.systemd1\]/aorg.freedesktop.systemd1.Manager:SoftReboot destructive' /etc/dfuzzer.conf -sed -i '/\[org.freedesktop.login1\]/aSleep destructive' /etc/dfuzzer.conf +add_suppression "org.freedesktop.systemd1" "org.freedesktop.systemd1.Manager:SoftReboot destructive" +add_suppression "org.freedesktop.login1" "Sleep destructive" + +cat /etc/dfuzzer.conf # TODO # * check for possibly newly introduced buses? From a66031255ffd3df588db29155dc31b20a47b55bb Mon Sep 17 00:00:00 2001 From: Frantisek Sumsal Date: Thu, 28 Dec 2023 23:42:47 +0100 Subject: [PATCH 2/3] test: avoid starting/stopping unwanted units during fuzzing 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. --- test/units/testsuite-21.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/units/testsuite-21.sh b/test/units/testsuite-21.sh index ed0f88e2b2..7b2013fb51 100755 --- a/test/units/testsuite-21.sh +++ b/test/units/testsuite-21.sh @@ -39,6 +39,13 @@ add_suppression "org.freedesktop.systemd1" "org.freedesktop.systemd1.Manager:Ree 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 + cat /etc/dfuzzer.conf # TODO From 77baca26f5e4696912140e31f8d7076915445a4a Mon Sep 17 00:00:00 2001 From: Frantisek Sumsal Date: Fri, 29 Dec 2023 13:28:05 +0100 Subject: [PATCH 3/3] test: show journal entries matching the test's syslog identifier as well --- test/test-functions | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/test-functions b/test/test-functions index 5af7b8cd91..77da9259d7 100644 --- a/test/test-functions +++ b/test/test-functions @@ -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/