mirror of
https://github.com/systemd/systemd.git
synced 2025-03-28 02:50:16 +03:00
test: Enable TEST-69-SHUTDOWN for mkosi
In mkosi, we run the test inside the VM instead of outside. To simplify the implementation we drop the reboot part and only verify that we can schedule and cancel shutdowns and that the wall messages are sent as expected.
This commit is contained in:
parent
0dde8adcf5
commit
e182c7b4db
@ -41,6 +41,7 @@ Packages=
|
||||
polkit
|
||||
procps-ng
|
||||
psmisc
|
||||
python-pexpect
|
||||
python-psutil
|
||||
quota-tools
|
||||
sbsigntools
|
||||
|
@ -53,6 +53,7 @@ Packages=
|
||||
policycoreutils
|
||||
polkit
|
||||
procps-ng
|
||||
python3-pexpect
|
||||
quota
|
||||
rpm
|
||||
rpm-build
|
||||
|
@ -64,6 +64,7 @@ Packages=
|
||||
policykit-1
|
||||
procps
|
||||
psmisc
|
||||
python3-pexpect
|
||||
python3-psutil
|
||||
quota
|
||||
sbsigntool
|
||||
|
@ -60,6 +60,7 @@ Packages=
|
||||
procps4
|
||||
psmisc
|
||||
python3-pefile
|
||||
python3-pexpect
|
||||
python3-psutil
|
||||
quota
|
||||
rpm-build
|
||||
|
@ -5,6 +5,8 @@ Wants=basic.target multi-user.target
|
||||
After=basic.target
|
||||
Before=getty-pre.target
|
||||
|
||||
ConditionPathExists=/usr/bin/python3
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=true
|
||||
ExecStart=/usr/lib/systemd/tests/testdata/units/TEST-69-SHUTDOWN.py
|
||||
|
@ -3,7 +3,6 @@
|
||||
integration_tests += [
|
||||
integration_test_template + {
|
||||
'name' : fs.name(meson.current_source_dir()),
|
||||
'enabled' : false,
|
||||
'unit' : files('TEST-69-SHUTDOWN.service'),
|
||||
},
|
||||
]
|
||||
|
58
test/units/TEST-69-SHUTDOWN.py
Executable file
58
test/units/TEST-69-SHUTDOWN.py
Executable file
@ -0,0 +1,58 @@
|
||||
#!/usr/bin/python3
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
# pylint: disable=broad-except
|
||||
|
||||
import logging
|
||||
import sys
|
||||
|
||||
import pexpect
|
||||
|
||||
|
||||
def main():
|
||||
logger = logging.getLogger("test-shutdown")
|
||||
|
||||
consoles = []
|
||||
for _ in range(2):
|
||||
# Use script to allocate a separate pseudo tty to run the login shell in.
|
||||
console = pexpect.spawn(
|
||||
"script", ["--quiet", "--return", "--flush", "--command", "login -f root", "/dev/null"],
|
||||
logfile=sys.stdout,
|
||||
env={"TERM": "dumb"},
|
||||
encoding="utf-8",
|
||||
timeout=60,
|
||||
)
|
||||
|
||||
logger.info("waiting for login prompt")
|
||||
console.expect(".*# ", 10)
|
||||
|
||||
consoles += [console]
|
||||
|
||||
consoles[1].sendline("tty")
|
||||
consoles[1].expect(r"/dev/(pts/\d+)")
|
||||
pty = console.match.group(1)
|
||||
logger.info("window 1 at tty %s", pty)
|
||||
|
||||
logger.info("schedule reboot")
|
||||
consoles[1].sendline("shutdown -r")
|
||||
consoles[1].expect("Reboot scheduled for (?P<date>.*), use 'shutdown -c' to cancel", 2)
|
||||
date = consoles[1].match.group("date")
|
||||
logger.info("reboot scheduled for %s", date)
|
||||
|
||||
logger.info("verify broadcast message")
|
||||
consoles[0].expect(f"Broadcast message from root@H on {pty}", 2)
|
||||
consoles[0].expect(f"The system will reboot at {date}!", 2)
|
||||
|
||||
logger.info("check show output")
|
||||
consoles[1].sendline("shutdown --show")
|
||||
consoles[1].expect(f"Reboot scheduled for {date}, use 'shutdown -c' to cancel", 2)
|
||||
|
||||
logger.info("cancel shutdown")
|
||||
consoles[1].sendline("shutdown -c")
|
||||
consoles[0].expect("System shutdown has been cancelled", 2)
|
||||
|
||||
consoles[0].sendline("> /testok")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
# vim: sw=4 et
|
Loading…
x
Reference in New Issue
Block a user