From: Frantisek Sumsal Date: Tue, 3 Oct 2023 14:40:49 +0000 (+0200) Subject: test: spawn the to-be-killed-on-soft-reboot units with --collect X-Git-Tag: v255-rc1~346^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2f397514ad34681d636bf9ff39ea650fc219bd39;p=thirdparty%2Fsystemd.git test: spawn the to-be-killed-on-soft-reboot units with --collect Otherwise they might leave stuff behind if they don't respond fast enough to the first SIGTERM and get SIGKILLEd, which then breaks reusing the unit name further in the test: [ 2993.620849] H testsuite-82.sh[43]: + systemd-run -p Type=exec -p DefaultDependencies=no -p IgnoreOnIsolate=yes --unit=testsuite-82-nosurvive.service sleep infinity [ 2993.628686] H systemd[1]: testsuite-82-nosurvive.service: About to execute: /usr/bin/sleep infinity [ 2993.628886] H systemd[1]: testsuite-82-nosurvive.service: Forked /usr/bin/sleep as 65 [ 2993.629328] H systemd[1]: testsuite-82-nosurvive.service: Changed dead -> start ... [ 2993.699892] H testsuite-82.sh[43]: + systemctl --no-block --check-inhibitors=yes soft-reboot [ 2993.704326] H systemd-logind[41]: The system will soft-reboot now! ... [ 3001.249302] H systemd[1]: Sending SIGKILL to PID 65 (sleep). ... [ 3001.303158] H testsuite-82.sh[136]: + systemd-notify '--status=Second Boot' ... [ 3001.409504] H testsuite-82.sh[136]: + systemd-run -p Type=exec --unit=testsuite-82-nosurvive.service sleep infinity [ 3001.414061] H testsuite-82.sh[165]: Failed to start transient service unit: Unit testsuite-82-nosurvive.service was already loaded or has a fragment file. Spotted in Ubuntu CI. --- diff --git a/test/units/testsuite-82.sh b/test/units/testsuite-82.sh index b57350c79b9..15243ab6a22 100755 --- a/test/units/testsuite-82.sh +++ b/test/units/testsuite-82.sh @@ -75,7 +75,7 @@ elif [ -f /run/testsuite82.touch2 ]; then mount # Restart the unit that is not supposed to survive - systemd-run --service-type=exec --unit=testsuite-82-nosurvive.service sleep infinity + systemd-run --collect --service-type=exec --unit=testsuite-82-nosurvive.service sleep infinity # Now issue the soft reboot. We should be right back soon. touch /run/testsuite82.touch3 @@ -131,7 +131,7 @@ elif [ -f /run/testsuite82.touch ]; then mount --bind / /run/nextroot/original-root # Restart the unit that is not supposed to survive - systemd-run --service-type=exec --unit=testsuite-82-nosurvive.service sleep infinity + systemd-run --collect --service-type=exec --unit=testsuite-82-nosurvive.service sleep infinity # Now issue the soft reboot. We should be right back soon. touch /run/testsuite82.touch2 @@ -170,8 +170,8 @@ EOF # 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, # and will be killed by the final sigterm/sigkill spree. - systemd-run --service-type=notify -p DefaultDependencies=no -p IgnoreOnIsolate=yes --unit=testsuite-82-nosurvive-sigterm.service "$survive_sigterm" - systemd-run --service-type=exec -p DefaultDependencies=no -p IgnoreOnIsolate=yes --unit=testsuite-82-nosurvive.service sleep infinity + systemd-run --collect --service-type=notify -p DefaultDependencies=no -p IgnoreOnIsolate=yes --unit=testsuite-82-nosurvive-sigterm.service "$survive_sigterm" + systemd-run --collect --service-type=exec -p DefaultDependencies=no -p IgnoreOnIsolate=yes --unit=testsuite-82-nosurvive.service sleep infinity # Configure these transient units to survive the soft reboot - they will not conflict with shutdown.target # and it will be ignored on the isolate that happens in the next boot. The first will use argv[0][0] =