diff --git a/test/units/testsuite-13.machinectl.sh b/test/units/testsuite-13.machinectl.sh index 9ca6f5f02bf..50dc716230a 100755 --- a/test/units/testsuite-13.machinectl.sh +++ b/test/units/testsuite-13.machinectl.sh @@ -13,6 +13,7 @@ at_exit() { machinectl status long-running >/dev/null && machinectl kill --signal=KILL long-running mountpoint -q /var/lib/machines && timeout 10 sh -c "while ! umount /var/lib/machines; do sleep .5; done" + [[ -n "${NSPAWN_FRAGMENT:-}" ]] && rm -f "/etc/systemd/nspawn/$NSPAWN_FRAGMENT" "/var/lib/machines/$NSPAWN_FRAGMENT" } trap at_exit EXIT @@ -182,6 +183,24 @@ rm -fr /tmp/container.dir timeout 10 sh -c "while ! machinectl clean --all; do sleep .5; done" +NSPAWN_FRAGMENT="machinectl-test-$RANDOM.nspawn" +cat >"/var/lib/machines/$NSPAWN_FRAGMENT" </tmp/fragment.nspawn <"/var/lib/machines/$NSPAWN_NAME" <<\EOF -[Exec] -Boot=true -EOF - -EDITOR='true' script -ec 'machinectl edit "$NSPAWN_NAME"' /dev/null -[ -f "/etc/systemd/nspawn/$NSPAWN_NAME" ] -cmp "/var/lib/machines/$NSPAWN_NAME" "/etc/systemd/nspawn/$NSPAWN_NAME" - -cat >new <<\EOF -[Exec] -Boot=false -EOF - -script -ec 'machinectl cat "$PWD/new"' /dev/null - -EDITOR='mv new' script -ec 'machinectl edit "$NSPAWN_NAME"' /dev/null -printf '%s\n' '[Exec]' 'Boot=false' | cmp - "/etc/systemd/nspawn/$NSPAWN_NAME"