]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: set pexpect's logfile early
authorFrantisek Sumsal <frantisek@sumsal.cz>
Tue, 9 Apr 2024 18:55:48 +0000 (20:55 +0200)
committerFrantisek Sumsal <frantisek@sumsal.cz>
Tue, 9 Apr 2024 19:39:46 +0000 (21:39 +0200)
So we capture the container's boot as well.

test/test-shutdown.py

index f496122f80ce5f546f51522ca100a6109d9a2609..b83487c5d4dac46726ea6fae315b512234a661c5 100755 (executable)
@@ -15,9 +15,16 @@ 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={
+    console = pexpect.spawn(args.command, args.arg, logfile=logfile, env={
             "TERM": "linux",
         }, encoding='utf-8', timeout=60)
 
@@ -27,12 +34,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)