test: Connect test unit to console when running interactively (#36586)
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
Description=TEST-07-PID1
|
||||
Wants=basic.target multi-user.target
|
||||
After=basic.target
|
||||
Before=getty-pre.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
|
||||
@@ -5,7 +5,6 @@ Description=TEST-16-EXTEND-TIMEOUT
|
||||
|
||||
Wants=basic.target multi-user.target
|
||||
After=basic.target
|
||||
Before=getty-pre.target
|
||||
|
||||
Wants=success-all.service
|
||||
Wants=success-start.service
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
Description=TEST-44-LOG-NAMESPACE
|
||||
Wants=basic.target multi-user.target systemd-journald@foobar.socket systemd-journald-varlink@foobar.socket
|
||||
After=basic.target systemd-journald@foobar.socket systemd-journald-varlink@foobar.socket
|
||||
Before=getty-pre.target
|
||||
|
||||
[Service]
|
||||
ExecStartPre=rm -f /failed /testok
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
Description=TEST-69-SHUTDOWN
|
||||
Wants=basic.target multi-user.target
|
||||
After=basic.target
|
||||
Before=getty-pre.target
|
||||
|
||||
ConditionPathExists=/usr/bin/python3
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ Description=TEST-82-SOFTREBOOT
|
||||
DefaultDependencies=no
|
||||
Wants=basic.target multi-user.target
|
||||
After=basic.target
|
||||
Before=getty-pre.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
|
||||
@@ -5,6 +5,8 @@ set -o pipefail
|
||||
|
||||
case "$1" in
|
||||
setup)
|
||||
busctl call org.freedesktop.systemd1 /org/freedesktop/systemd1 org.freedesktop.systemd1.Manager SetShowStatus s no
|
||||
|
||||
if [[ -f "$STATE_DIRECTORY/inprogress" ]]; then
|
||||
exit 0
|
||||
fi
|
||||
@@ -46,6 +48,8 @@ case "$1" in
|
||||
touch "$STATE_DIRECTORY/inprogress"
|
||||
;;
|
||||
finalize)
|
||||
busctl call org.freedesktop.systemd1 /org/freedesktop/systemd1 org.freedesktop.systemd1.Manager SetShowStatus s auto
|
||||
|
||||
# If we're rebooting, the test does a reboot as part of its execution and we shouldn't remove /inprogress.
|
||||
if ! [[ "$(systemctl list-jobs)" =~ reboot.target|kexec.target|soft-reboot.target ]]; then
|
||||
rm -f "$STATE_DIRECTORY/inprogress"
|
||||
|
||||
@@ -395,7 +395,7 @@ def main() -> None:
|
||||
shell = bool(int(os.getenv('TEST_SHELL', '0')))
|
||||
summary = Summary.get(args)
|
||||
|
||||
if shell and not sys.stderr.isatty():
|
||||
if shell and not sys.stdin.isatty():
|
||||
print(
|
||||
'--interactive must be passed to meson test to use TEST_SHELL=1',
|
||||
file=sys.stderr,
|
||||
@@ -443,7 +443,7 @@ def main() -> None:
|
||||
|
||||
journal_file.unlink(missing_ok=True)
|
||||
|
||||
if not sys.stderr.isatty():
|
||||
if not sys.stdin.isatty():
|
||||
dropin += textwrap.dedent(
|
||||
"""
|
||||
[Unit]
|
||||
@@ -454,11 +454,22 @@ def main() -> None:
|
||||
dropin += textwrap.dedent(
|
||||
"""
|
||||
[Unit]
|
||||
Wants=multi-user.target
|
||||
Wants=multi-user.target getty-pre.target
|
||||
Before=getty-pre.target
|
||||
|
||||
[Service]
|
||||
StandardInput=tty
|
||||
StandardOutput=inherit
|
||||
StandardError=inherit
|
||||
TTYReset=yes
|
||||
TTYVHangup=yes
|
||||
IgnoreSIGPIPE=no
|
||||
# bash ignores SIGTERM
|
||||
KillSignal=SIGHUP
|
||||
"""
|
||||
)
|
||||
|
||||
if sys.stderr.isatty():
|
||||
if sys.stdin.isatty():
|
||||
dropin += textwrap.dedent(
|
||||
"""
|
||||
[Service]
|
||||
@@ -489,7 +500,7 @@ def main() -> None:
|
||||
'--credential', f'systemd.extra-unit.emergency-exit.service={shlex.quote(EMERGENCY_EXIT_SERVICE)}', # noqa: E501
|
||||
'--credential', f'systemd.unit-dropin.emergency.target={shlex.quote(EMERGENCY_EXIT_DROPIN)}',
|
||||
]
|
||||
if not sys.stderr.isatty()
|
||||
if not sys.stdin.isatty()
|
||||
else []
|
||||
),
|
||||
'--credential', f'systemd.unit-dropin.{args.unit}={shlex.quote(dropin)}',
|
||||
@@ -514,13 +525,13 @@ def main() -> None:
|
||||
'systemd.crash_action=poweroff',
|
||||
'loglevel=6',
|
||||
]
|
||||
if not sys.stderr.isatty()
|
||||
if not sys.stdin.isatty()
|
||||
else []
|
||||
),
|
||||
]
|
||||
),
|
||||
'--credential', f"journal.storage={'persistent' if sys.stderr.isatty() else args.storage}",
|
||||
*(['--runtime-build-sources=no', '--register=no'] if not sys.stderr.isatty() else []),
|
||||
'--credential', f"journal.storage={'persistent' if sys.stdin.isatty() else args.storage}",
|
||||
*(['--runtime-build-sources=no', '--register=no'] if not sys.stdin.isatty() else []),
|
||||
'vm' if args.vm or os.getuid() != 0 or os.getenv('TEST_PREFER_QEMU', '0') == '1' else 'boot',
|
||||
] # fmt: skip
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
Description=%N
|
||||
Wants=basic.target network.target @wants@
|
||||
After=basic.target network.target @after@
|
||||
Before=getty-pre.target
|
||||
|
||||
[Service]
|
||||
ExecStartPre=rm -f /failed /testok
|
||||
|
||||
Reference in New Issue
Block a user