"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)
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')
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")