summaryrefslogtreecommitdiffstats
path: root/test/test-shutdown.py
diff options
context:
space:
mode:
authorFranck Bui <fbui@suse.com>2024-02-08 16:12:41 +0100
committerFranck Bui <fbui@suse.com>2024-02-12 16:57:51 +0100
commitcf14d1144717967ebdd150cb21ed5dc00e832a80 (patch)
treef7b97bed190e98ae7c3803a075e84c62021c0cc9 /test/test-shutdown.py
parenttest-69: send SIGTERM to ask systemd-nspawn to properly stop the container (diff)
downloadsystemd-cf14d1144717967ebdd150cb21ed5dc00e832a80.tar.xz
systemd-cf14d1144717967ebdd150cb21ed5dc00e832a80.zip
test/test-shutdown.py: optionally display the test I/Os in a dedicated log file
Given that the test involves screen(1), sending various control sequences to resize/clear the screen, most of the logs sent from the python script were nearly impossible to read or mixed with other messages sent to the console hence making the debug harder when the test is run manually. This patch introduces an option to redirect the pexpect IOs into a file (to be used in $STATEDIR/TEST-69-SHUTDOWN/run-nspawn). The pexpect logs are also enabled later so the boot logs are skipped since those are already included in the journal.
Diffstat (limited to 'test/test-shutdown.py')
-rwxr-xr-xtest/test-shutdown.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/test/test-shutdown.py b/test/test-shutdown.py
index e491f1e1a9..f496122f80 100755
--- a/test/test-shutdown.py
+++ b/test/test-shutdown.py
@@ -21,15 +21,18 @@ def run(args):
"TERM": "linux",
}, encoding='utf-8', timeout=60)
- if args.verbose:
- console.logfile = sys.stdout
-
logger.debug("child pid %d", console.pid)
try:
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)
@@ -44,7 +47,7 @@ def run(args):
console.sendline('tty')
console.expect(r'/dev/(pts/\d+)')
pty = console.match.group(1)
- logger.info("window 1 at line %s", pty)
+ logger.info("window 1 at tty %s", pty)
logger.info("schedule reboot")
console.sendline('shutdown -r')
@@ -112,6 +115,7 @@ def run(args):
def main():
parser = argparse.ArgumentParser(description='test logind shutdown feature')
parser.add_argument("-v", "--verbose", action="store_true", help="verbose")
+ parser.add_argument("--logfile", metavar='FILE', help="Save all test input/output to the given path")
parser.add_argument("command", help="command to run")
parser.add_argument("arg", nargs='*', help="args for command")