mirror of
https://github.com/systemd/systemd.git
synced 2025-01-12 13:18:14 +03:00
test: merge machinectl edit/cat tests into TEST-13
This commit is contained in:
parent
990b629e12
commit
a1ff1ac273
@ -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" <<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)
|
||||
|
@ -1,36 +0,0 @@
|
||||
#!/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"
|
Loading…
Reference in New Issue
Block a user