mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-20 14:03:39 +03:00
Add basic systemctl edit test
This commit is contained in:
parent
a1ad873d2f
commit
209d355c70
@ -7,4 +7,8 @@ TEST_DESCRIPTION="systemctl-related tests"
|
|||||||
# shellcheck source=test/test-functions
|
# shellcheck source=test/test-functions
|
||||||
. "${TEST_BASE_DIR:?}/test-functions"
|
. "${TEST_BASE_DIR:?}/test-functions"
|
||||||
|
|
||||||
|
test_append_files() (
|
||||||
|
image_install script
|
||||||
|
)
|
||||||
|
|
||||||
do_test "$@"
|
do_test "$@"
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||||
|
# shellcheck disable=SC2016
|
||||||
set -eux
|
set -eux
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
|
||||||
at_exit() {
|
at_exit() {
|
||||||
if [[ -v UNIT_NAME && -e "/usr/lib/systemd/system/$UNIT_NAME" ]]; then
|
if [[ -v UNIT_NAME && -e "/usr/lib/systemd/system/$UNIT_NAME" ]]; then
|
||||||
rm -fv "/usr/lib/systemd/system/$UNIT_NAME"
|
rm -fvr "/usr/lib/systemd/system/$UNIT_NAME" "/etc/systemd/system/$UNIT_NAME.d" "+4"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -17,7 +18,7 @@ trap at_exit EXIT
|
|||||||
# Create a simple unit file for testing
|
# Create a simple unit file for testing
|
||||||
# Note: the service file is created under /usr on purpose to test
|
# Note: the service file is created under /usr on purpose to test
|
||||||
# the 'revert' verb as well
|
# the 'revert' verb as well
|
||||||
UNIT_NAME="systemctl-test-$RANDOM.service"
|
export UNIT_NAME="systemctl-test-$RANDOM.service"
|
||||||
cat >"/usr/lib/systemd/system/$UNIT_NAME" <<\EOF
|
cat >"/usr/lib/systemd/system/$UNIT_NAME" <<\EOF
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=systemctl test
|
Description=systemctl test
|
||||||
@ -41,7 +42,16 @@ EOF
|
|||||||
mkdir /run/systemd/system-preset/
|
mkdir /run/systemd/system-preset/
|
||||||
echo "disable $UNIT_NAME" >/run/systemd/system-preset/99-systemd-test.preset
|
echo "disable $UNIT_NAME" >/run/systemd/system-preset/99-systemd-test.preset
|
||||||
|
|
||||||
systemctl daemon-reload
|
EDITOR='true' script -ec 'systemctl edit "$UNIT_NAME"' /dev/null
|
||||||
|
[ ! -e "/etc/systemd/system/$UNIT_NAME.d/override.conf" ]
|
||||||
|
|
||||||
|
printf '%s\n' '[Service]' 'ExecStart=' 'ExecStart=sleep 10d' > "+4"
|
||||||
|
EDITOR='mv' script -ec 'systemctl edit "$UNIT_NAME"' /dev/null
|
||||||
|
printf '%s\n' '[Service]' 'ExecStart=' 'ExecStart=sleep 10d' | cmp - "/etc/systemd/system/$UNIT_NAME.d/override.conf"
|
||||||
|
|
||||||
|
printf '%b' '[Service]\n' 'ExecStart=\n' 'ExecStart=sleep 10d' > "+4"
|
||||||
|
EDITOR='mv' script -ec 'systemctl edit "$UNIT_NAME"' /dev/null
|
||||||
|
printf '%s\n' '[Service]' 'ExecStart=' 'ExecStart=sleep 10d' | cmp - "/etc/systemd/system/$UNIT_NAME.d/override.conf"
|
||||||
|
|
||||||
# Argument help
|
# Argument help
|
||||||
systemctl --state help
|
systemctl --state help
|
||||||
|
Loading…
x
Reference in New Issue
Block a user