Skip to content

Commit b5850b8

Browse files
committed
pexpect: Make standard boot logic work with quiet boot
When booting with "quiet" on the command line, the "Freeing unused kernel" message doesn't appear. Look also for the expected prompt, or the "login:" banner. Tested with buildroot rootdisk, Fedora & Ubuntu.
1 parent b53b058 commit b5850b8

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

lib/pexpect_utils.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,19 +103,26 @@ def cmd(self, cmd):
103103

104104
def standard_boot(p, login=False, user='root', password=None, timeout=-1):
105105
logging.info("Waiting for kernel to boot")
106-
p.expect("Freeing unused kernel ", timeout=timeout)
106+
i = p.expect([p.prompt, "login:", "Freeing unused kernel "], timeout=timeout)
107+
108+
if i == 0:
109+
# We booted straight to a prompt, we're done
110+
pass
111+
elif login:
112+
if i != 1:
113+
logging.info("Kernel came up, waiting for login ...")
114+
p.expect("login:", timeout=timeout)
107115

108-
if login:
109-
logging.info("Kernel came up, waiting for login ...")
110-
p.expect("login:", timeout=timeout)
111116
p.send(user)
112117
if password is not None:
113118
p.expect("Password:", timeout=timeout)
114119
p.send(password)
120+
121+
p.expect_prompt(timeout=timeout)
115122
else:
116123
logging.info("Kernel came up, waiting for prompt ...")
124+
p.expect_prompt(timeout=timeout)
117125

118-
p.expect_prompt(timeout=timeout)
119126
logging.info("Booted to shell prompt")
120127

121128

0 commit comments

Comments
 (0)