]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: re-enable journal checks for varlink-idl and so on 38809/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 3 Sep 2025 21:01:52 +0000 (06:01 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 4 Sep 2025 10:50:28 +0000 (19:50 +0900)
Previously, we have checked journal after TEST-XX-YYYYY.sh, but it was
forgotten when we switched to mkosi.
This re-enable the check but through ExecStartPost=, and drops unnecessary
workarounds for end.service. Then, this drops unnecessary end.service
and testsuite.target.

test/test.service.in
test/units/TEST-13-NSPAWN.machined.sh
test/units/TEST-21-DFUZZER.sh
test/units/TEST-82-SOFTREBOOT.sh
test/units/TEST-88-UPGRADE.sh
test/units/end.service [deleted file]
test/units/post.sh [moved from test/units/end.sh with 94% similarity]
test/units/testsuite.target [deleted file]

index 0d0dccdb7549a7e1acc4a84d582213011b7bf48c..7d1a5ecc996a2c0ad7bc02ca74f2a05ce54f7b47 100644 (file)
@@ -8,6 +8,7 @@ After=basic.target network.target @after@
 [Service]
 ExecStartPre=rm -f /failed /testok
 ExecStart=@command@
+ExecStartPost=/usr/lib/systemd/tests/testdata/units/post.sh
 Type=oneshot
 MemoryAccounting=@memory-accounting@
 Environment=SYSTEMD_PAGER= @env@
index d466662f966595f766d08b87f3474df8b3597101..76db239f916a2d0a2d189abd249f56b1aa89fb57 100755 (executable)
@@ -379,7 +379,7 @@ varlinkctl call /run/systemd/machine/io.systemd.Machine io.systemd.Machine.List
 
 # test io.systemd.Machine.Open
 
-# Reducing log level here is to work-around check in end.service (end.sh). Read https://github.com/systemd/systemd/pull/34867 for more details
+# Reducing log level here is to work-around check in post.sh. Read https://github.com/systemd/systemd/pull/34867 for more details
 systemctl service-log-level systemd-machined info
 (! varlinkctl call /run/systemd/machine/io.systemd.Machine io.systemd.Machine.Open '{"name": ".host"}')
 (! varlinkctl call /run/systemd/machine/io.systemd.Machine io.systemd.Machine.Open '{"name": ".host", "mode": ""}')
index 449c2d8b9d8c4bfb66a9779bf7660e76c9b5214b..fdf0e8054976d717c800841bd43a009f4b0c3249 100755 (executable)
@@ -14,24 +14,6 @@ if [[ ! -v ASAN_OPTIONS && ! -v UBSAN_OPTIONS && "${TEST_RUN_DFUZZER:-0}" == "0"
     exit 77
 fi
 
-# Save the end.service state before we start fuzzing, as it might get changed
-# on the fly by one of the fuzzers
-systemctl list-jobs | grep -F 'end.service' && SHUTDOWN_AT_EXIT=1 || SHUTDOWN_AT_EXIT=0
-
-# shellcheck disable=SC2317
-at_exit() {
-    set +e
-    # We have to call the end.service/poweroff explicitly even if it's specified on
-    # the kernel cmdline via systemd.wants=end.service, since dfuzzer calls
-    # org.freedesktop.systemd1.Manager.ClearJobs() which drops the service
-    # from the queue
-    if [[ $SHUTDOWN_AT_EXIT -ne 0 ]] && ! systemctl poweroff; then
-        # PID1 is down let's try to save the journal
-        journalctl --sync      # journal can be down as well so let's ignore exit codes here
-        systemctl -ff poweroff # sync() and reboot(RB_POWER_OFF)
-    fi
-}
-
 add_suppression() {
     local interface="${1:?}"
     local suppression="${2:?}"
@@ -39,8 +21,6 @@ add_suppression() {
     sed -i "\%\[$interface\]%a$suppression" /etc/dfuzzer.conf
 }
 
-trap at_exit EXIT
-
 systemctl log-level info
 
 # Skip calling start and stop methods on unit objects, as doing that is not only time consuming, but it also
index e0bf27342bc581585c9d1bda5fed9341ffc17636..65d0e030b869b75c0143130c7401cd341a49f092 100755 (executable)
@@ -6,19 +6,6 @@ set -o pipefail
 # shellcheck source=test/units/util.sh
 . "$(dirname "$0")"/util.sh
 
-at_exit() {
-    # Since the soft-reboot drops the enqueued end.service, we won't shutdown
-    # the test VM if the test fails and have to wait for the watchdog to kill
-    # us (which may take quite a long time). Let's just forcibly kill the machine
-    # instead to save CI resources.
-    if [[ $? -ne 0 ]]; then
-        echo >&2 "Test failed, shutting down the machine..."
-        systemctl poweroff -ff
-    fi
-}
-
-trap at_exit EXIT
-
 # Because this test tests soft-reboot, we have to get rid of the symlink we put at
 # /run/nextroot to allow rebooting into the previous snapshot if the test fails for
 # the duration of the test. However, let's make sure we put the symlink back in place
@@ -272,7 +259,7 @@ exec -a @sleep sleep infinity
 EOF
     chmod +x "$survive_argv"
     # This sets DefaultDependencies=no so that they remain running until the very end, and
-    # IgnoreOnIsolate=yes so that they aren't stopped via the "testsuite.target" isolation we do on next boot,
+    # IgnoreOnIsolate=yes so that they aren't stopped via isolation on next boot,
     # and will be killed by the final sigterm/sigkill spree.
     systemd-run --collect --service-type=notify -p DefaultDependencies=no -p IgnoreOnIsolate=yes --unit=TEST-82-SOFTREBOOT-nosurvive-sigterm.service "$survive_sigterm"
     systemd-run --collect --service-type=exec -p DefaultDependencies=no -p IgnoreOnIsolate=yes -p SetCredential=gone:hoge --unit=TEST-82-SOFTREBOOT-nosurvive.service sleep infinity
index 9185725b3d674b142cb9b690ef10f5e2b238477d..603efea98030cfa351e6a8f8e66cd34f49d92aaa 100755 (executable)
@@ -72,6 +72,8 @@ check_sd() {
 
 # Copy the unit in /run so systemd finds it after the downgrade
 cp /usr/lib/systemd/tests/testdata/units/TEST-88-UPGRADE.service /run/systemd/system
+# Also backup post.sh
+cp /usr/lib/systemd/tests/testdata/units/post.sh /tmp/.
 
 now=$(date +%s)
 after_2h=$((now + 3600 * 2))
@@ -105,4 +107,8 @@ dnf -y upgrade --disablerepo '*' "$pkgdir"/devel/*.rpm
 # TODO: sanity checks
 check_sd
 
+# Restore post.sh
+mkdir -p /usr/lib/systemd/tests/testdata/units
+mv /tmp/post.sh /usr/lib/systemd/tests/testdata/units/.
+
 touch /testok
diff --git a/test/units/end.service b/test/units/end.service
deleted file mode 100644 (file)
index 50a68b9..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-# SPDX-License-Identifier: LGPL-2.1-or-later
-[Unit]
-Description=End the test
-After=testsuite.target
-OnFailure=poweroff.target
-OnFailureJobMode=replace-irreversibly
-
-[Service]
-Type=oneshot
-ExecStart=/usr/lib/systemd/tests/testdata/units/end.sh
-TimeoutStartSec=5m
similarity index 94%
rename from test/units/end.sh
rename to test/units/post.sh
index cc1d7ee11ebbdfb95f984228b3b4fba726a1750b..9fd50fffaa6a89808cb8cd9f6ee6927d447db86c 100755 (executable)
@@ -1,6 +1,5 @@
 #!/usr/bin/env bash
 # SPDX-License-Identifier: LGPL-2.1-or-later
-
 set -eux
 set -o pipefail
 
@@ -12,6 +11,3 @@ set -o pipefail
 # Check if sd-executor doesn't complain about not being able to (de)serialize stuff
 (! journalctl -q -o short-monotonic --grep "[F]ailed to parse serialized line" >>/failed)
 (! journalctl -q -o short-monotonic --grep "[F]ailed to (de)?serialize \w+" >>/failed)
-
-systemctl poweroff --no-block
-exit 0
diff --git a/test/units/testsuite.target b/test/units/testsuite.target
deleted file mode 100644 (file)
index 6bcbfec..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-# SPDX-License-Identifier: LGPL-2.1-or-later
-[Unit]
-Description=Testsuite target
-Requires=multi-user.target
-After=multi-user.target
-Conflicts=rescue.target
-AllowIsolate=yes