fix(vm): match zsh prompt in serial driver login

This commit is contained in:
Phoebus 2026-09-27 23:19:04 -07:00
parent 78d5680a79
commit 497cba6b81

View file

@ -45,6 +45,12 @@ USER = os.environ.get("USERNAME", "phoebus")
MEM = os.environ.get("VM_MEM", "8192") MEM = os.environ.get("VM_MEM", "8192")
SMP = os.environ.get("VM_SMP", "8") SMP = os.environ.get("VM_SMP", "8")
# Shell-prompt alternative for an installed Phoebus login. The default login
# shell is zsh with a powerline-style prompt ending in the `❯` glyph; color
# escapes sit between the glyph and the trailing space, so the bare glyph
# (not `❯ `) is matched. Bash/root prompts keep matching `[$#] `.
SHELL_PROMPT = r"[$#] |❯"
BLS_APPEND = ( BLS_APPEND = (
"root=live:CDLABEL=gentoo-amd64-livegui rd.live.dir=/ " "root=live:CDLABEL=gentoo-amd64-livegui rd.live.dir=/ "
"rd.live.squashimg=image.squashfs cdroot console=ttyS0,115200" "rd.live.squashimg=image.squashfs cdroot console=ttyS0,115200"
@ -171,7 +177,7 @@ def _unlock_and_login(child, results, tag):
timeout=30) timeout=30)
if idx == 0: if idx == 0:
child.sendline(USER_PW) child.sendline(USER_PW)
if child.expect([r"[$#] $", r"Login incorrect", r"phoebus login:"], if child.expect([SHELL_PROMPT, r"Login incorrect", r"phoebus login:"],
timeout=60) == 0: timeout=60) == 0:
logged_in = True logged_in = True
break break
@ -374,7 +380,7 @@ def do_boot(results, paths, disks):
r"Login incorrect"], timeout=30) r"Login incorrect"], timeout=30)
if idx == 0: if idx == 0:
child.sendline(USER_PW) child.sendline(USER_PW)
login_result = child.expect([r"[$#] $", r"Login incorrect", login_result = child.expect([SHELL_PROMPT, r"Login incorrect",
r"phoebus login:"], timeout=60) r"phoebus login:"], timeout=60)
if login_result == 0: if login_result == 0:
logged_in = True logged_in = True
@ -385,10 +391,10 @@ def do_boot(results, paths, disks):
results.assert_true("detached-boot-login", logged_in, "could not log in") results.assert_true("detached-boot-login", logged_in, "could not log in")
if os.environ.get("BOOT_AUTHENTICATE") == "1": if os.environ.get("BOOT_AUTHENTICATE") == "1":
child.sendline("sudo -v") child.sendline("sudo -v")
idx = child.expect([r"[Pp]assword(?: for [^:]+)?:", r"[$#] $"], timeout=30) idx = child.expect([r"[Pp]assword(?: for [^:]+)?:", SHELL_PROMPT], timeout=30)
if idx == 0: if idx == 0:
child.sendline(USER_PW) child.sendline(USER_PW)
child.expect(r"[$#] $", timeout=30) child.expect(SHELL_PROMPT, timeout=30)
child.sendline(checks) child.sendline(checks)
child.expect("===CHECKS-END===", timeout=int(os.environ.get("CHECKS_TIMEOUT", "180"))) child.expect("===CHECKS-END===", timeout=int(os.environ.get("CHECKS_TIMEOUT", "180")))
serial = paths.serial_log.read_text(errors="replace") serial = paths.serial_log.read_text(errors="replace")