mirror of
https://github.com/systemd/systemd.git
synced 2025-09-01 13:59:26 +03:00
test: check if we skip the full setup on daemon-reexec
A simple test case for issue #27106. Resolves: #27139
This commit is contained in:
committed by
Yu Watanabe
parent
d7805ff711
commit
61961e693d
@ -220,6 +220,7 @@ BASICTOOLS=(
|
|||||||
sh
|
sh
|
||||||
sleep
|
sleep
|
||||||
stat
|
stat
|
||||||
|
stty
|
||||||
su
|
su
|
||||||
sulogin
|
sulogin
|
||||||
sysctl
|
sysctl
|
||||||
@ -262,7 +263,6 @@ DEBUGTOOLS=(
|
|||||||
route
|
route
|
||||||
sort
|
sort
|
||||||
strace
|
strace
|
||||||
stty
|
|
||||||
tty
|
tty
|
||||||
vi
|
vi
|
||||||
/usr/libexec/vi
|
/usr/libexec/vi
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=TEST-01-BASIC
|
Description=TEST-01-BASIC
|
||||||
After=multi-user.target
|
# Order the test unit after systemd-update-utmp-runlevel.service, since
|
||||||
|
# the service doesn't play well with daemon-reexec
|
||||||
|
# See: https://github.com/systemd/systemd/issues/27167
|
||||||
|
After=multi-user.target systemd-update-utmp-runlevel.service
|
||||||
Wants=systemd-resolved.service systemd-networkd.service
|
Wants=systemd-resolved.service systemd-networkd.service
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
ExecStartPre=rm -f /failed /testok
|
ExecStartPre=rm -f /failed /testok
|
||||||
ExecStart=sh -e -x -c 'systemctl --state=failed --no-legend --no-pager >/failed ; systemctl daemon-reload ; echo OK >/testok'
|
ExecStart=/usr/lib/systemd/tests/testdata/units/%N.sh
|
||||||
Type=oneshot
|
Type=oneshot
|
||||||
|
42
test/units/testsuite-01.sh
Executable file
42
test/units/testsuite-01.sh
Executable file
@ -0,0 +1,42 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||||
|
set -eux
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
|
STTY_ORIGINAL="$(stty --file=/dev/console --save)"
|
||||||
|
|
||||||
|
at_exit() {
|
||||||
|
set +e
|
||||||
|
stty --file=/dev/console "${STTY_ORIGINAL:?}"
|
||||||
|
}
|
||||||
|
|
||||||
|
trap at_exit EXIT
|
||||||
|
|
||||||
|
# Do one reexec beforehand to get /dev/console into some predictable state
|
||||||
|
systemctl daemon-reexec
|
||||||
|
|
||||||
|
# Check if we do skip the early setup when doing daemon-reexec
|
||||||
|
# See: https://github.com/systemd/systemd/issues/27106
|
||||||
|
#
|
||||||
|
# Change a couple of console settings, do a reexec, and then check if our
|
||||||
|
# changes persisted, since we reset the terminal stuff only on "full" reexec
|
||||||
|
#
|
||||||
|
# Relevant function: reset_terminal_fd() from terminal-util.cs
|
||||||
|
stty --file=/dev/console brkint igncr inlcr istrip iuclc -icrnl -imaxbel -iutf8 \
|
||||||
|
kill ^K quit ^I
|
||||||
|
STTY_NEW="$(stty --file=/dev/console --save)"
|
||||||
|
systemctl daemon-reexec
|
||||||
|
diff <(echo "$STTY_NEW") <(stty --file=/dev/console --save)
|
||||||
|
|
||||||
|
if ! systemd-detect-virt -qc; then
|
||||||
|
# We also disable coredumps when doing a "full" reexec, so check for that too
|
||||||
|
sysctl -w kernel.core_pattern=dont-overwrite-me
|
||||||
|
systemctl daemon-reexec
|
||||||
|
diff <(echo dont-overwrite-me) <(sysctl --values kernel.core_pattern)
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Collect failed units & do one daemon-reload to a basic sanity check
|
||||||
|
systemctl --state=failed --no-legend --no-pager | tee /failed
|
||||||
|
systemctl daemon-reload
|
||||||
|
|
||||||
|
echo OK >/testok
|
Reference in New Issue
Block a user