mirror of
https://github.com/Dasharo/systemd.git
synced 2026-03-06 15:02:31 -08:00
test: add testsuite-74.machinectl
This commit is contained in:
@@ -7,4 +7,8 @@ TEST_DESCRIPTION="Tests for auxiliary utilities"
|
||||
# shellcheck source=test/test-functions
|
||||
. "${TEST_BASE_DIR:?}/test-functions"
|
||||
|
||||
test_append_files() (
|
||||
image_install script
|
||||
)
|
||||
|
||||
do_test "$@"
|
||||
|
||||
43
test/units/testsuite-74.machinectl.sh
Executable file
43
test/units/testsuite-74.machinectl.sh
Executable file
@@ -0,0 +1,43 @@
|
||||
#!/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
|
||||
|
||||
: >/failed
|
||||
|
||||
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
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
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"
|
||||
|
||||
touch /testok
|
||||
rm /failed
|
||||
Reference in New Issue
Block a user