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
timeout 10 sh -c "while ! machinectl clean --all; do sleep .5; done"
+NSPAWN_FRAGMENT="machinectl-test-$RANDOM.nspawn"
+cat >"/var/lib/machines/$NSPAWN_FRAGMENT" <<EOF
+[Exec]
+Boot=true
+EOF
+machinectl cat "$NSPAWN_FRAGMENT"
+EDITOR=true script -qec "machinectl edit $NSPAWN_FRAGMENT" /dev/null
+test -f "/etc/systemd/nspawn/$NSPAWN_FRAGMENT"
+diff "/var/lib/machines/$NSPAWN_FRAGMENT" "/etc/systemd/nspawn/$NSPAWN_FRAGMENT"
+
+cat >/tmp/fragment.nspawn <<EOF
+[Exec]
+Boot=false
+EOF
+machinectl cat /tmp/fragment.nspawn
+EDITOR="cp /tmp/fragment.nspawn" script -qec "machinectl edit $NSPAWN_FRAGMENT" /dev/null
+diff /tmp/fragment.nspawn "/etc/systemd/nspawn/$NSPAWN_FRAGMENT"
+
for opt in format lines machine max-addresses output setenv verify; do
(! machinectl status "--$opt=" long-running)
(! machinectl status "--$opt=-1" long-running)
+++ /dev/null
-#!/usr/bin/env bash
-# SPDX-License-Identifier: LGPL-2.1-or-later
-# shellcheck disable=SC2016
-set -eux
-set -o pipefail
-
-# shellcheck source=test/units/assert.sh
-. "$(dirname "$0")"/assert.sh
-
-at_exit() {
- if [[ -v NSPAWN_NAME && -e "/var/lib/machines/$NSPAWN_NAME" ]]; then
- rm -fvr "/var/lib/machines/$NSPAWN_NAME" "/etc/systemd/nspawn/$NSPAWN_NAME" "new"
- fi
-}
-
-trap at_exit EXIT
-
-export NSPAWN_NAME="machinectl-test-$RANDOM.nspawn"
-cat >"/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"