hwdb: fix screen rotation for EXO Wings 2in1 w1125 (#36283)
[systemd.io.git] / test / units / TEST-69-SHUTDOWN.py
blob4e554702abbcc5e6c6284d6f11f1732339a877b7
1 #!/usr/bin/python3
2 # SPDX-License-Identifier: LGPL-2.1-or-later
3 # pylint: disable=broad-except
5 import logging
6 import sys
8 import pexpect
11 def main():
12 # TODO: drop once https://bugs.debian.org/1075733 is fixed
13 with open("/usr/lib/os-release") as f:
14 for line in f:
15 if line.startswith("ID="):
16 if "debian" in line or "ubuntu" in line:
17 sys.exit(77)
19 logger = logging.getLogger("test-shutdown")
21 consoles = []
22 for _ in range(2):
23 # Use script to allocate a separate pseudo tty to run the login shell in.
24 console = pexpect.spawn(
25 "script", ["--quiet", "--return", "--flush", "--command", "login -f root", "/dev/null"],
26 logfile=sys.stdout,
27 env={"TERM": "dumb"},
28 encoding="utf-8",
29 timeout=60,
32 logger.info("waiting for login prompt")
33 console.expect(".*# ", 10)
35 consoles += [console]
37 consoles[1].sendline("tty")
38 consoles[1].expect(r"/dev/(pts/\d+)")
39 pty = console.match.group(1)
40 logger.info("window 1 at tty %s", pty)
42 logger.info("schedule reboot")
43 consoles[1].sendline("shutdown -r")
44 consoles[1].expect("Reboot scheduled for (?P<date>.*), use 'shutdown -c' to cancel", 2)
45 date = consoles[1].match.group("date")
46 logger.info("reboot scheduled for %s", date)
48 logger.info("verify broadcast message")
49 consoles[0].expect(f"Broadcast message from root@H on {pty}", 2)
50 consoles[0].expect(f"The system will reboot at {date}!", 2)
52 logger.info("check show output")
53 consoles[1].sendline("shutdown --show")
54 consoles[1].expect(f"Reboot scheduled for {date}, use 'shutdown -c' to cancel", 2)
56 logger.info("cancel shutdown")
57 consoles[1].sendline("shutdown -c")
58 consoles[0].expect("System shutdown has been cancelled", 2)
60 consoles[0].sendline("> /testok")
62 if __name__ == "__main__":
63 main()
65 # vim: sw=4 et