]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - test/test-shutdown.py
test-network: introduce check_networkd_log() helper function
[thirdparty/systemd.git] / test / test-shutdown.py
index f496122f80ce5f546f51522ca100a6109d9a2609..d19a03742c246f6c5cd2f2b40da28be601f38d21 100755 (executable)
@@ -12,13 +12,19 @@ import pexpect
 
 
 def run(args):
-
     ret = 1
     logger = logging.getLogger("test-shutdown")
+    logfile = None
+
+    if args.logfile:
+        logger.debug("Logging pexpect IOs to %s", args.logfile)
+        logfile = open(args.logfile, 'w')
+    elif args.verbose:
+        logfile = sys.stdout
 
     logger.info("spawning test")
-    console = pexpect.spawn(args.command, args.arg, env={
-            "TERM": "linux",
+    console = pexpect.spawn(args.command, args.arg, logfile=logfile, env={
+            "TERM": "dumb",
         }, encoding='utf-8', timeout=60)
 
     logger.debug("child pid %d", console.pid)
@@ -27,12 +33,6 @@ def run(args):
         logger.info("waiting for login prompt")
         console.expect('H login: ', 10)
 
-        if args.logfile:
-            logger.debug("Logging pexpect IOs to %s", args.logfile)
-            console.logfile = open(args.logfile, 'w')
-        elif args.verbose:
-            console.logfile = sys.stdout
-
         logger.info("log in and start screen")
         console.sendline('root')
         console.expect('bash.*# ', 10)
@@ -42,6 +42,10 @@ def run(args):
         console.send('c')
         console.expect('screen1 ', 10)
 
+        logger.info('wait for the machine to fully boot')
+        console.sendline('systemctl is-system-running --wait')
+        console.expect(r'\b(running|degraded)\b', 60)
+
 #        console.interact()
 
         console.sendline('tty')