test(stick): the fixed screen's other sessions -- replace, mint_fail, system_pull_real (#92, 5.6) [skip ci]

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GE3SDvQn5EoxdGufk84zz2
This commit is contained in:
Claude
2026-11-10 06:42:07 +00:00
parent bb64678692
commit b8da642f02
+98 -5
View File
@@ -82,6 +82,13 @@ the stick's, plan 2026-10-26-stick-1-screen-and-keyboard.md):
2026-10-29-stick-5, Task 5): the fixed screen's four lines, no ok> for 30 s, `3 4 + .`
typed there not run; her stick added: the prompt; pulled: the screen again; R with no
stick offered: the plug-in line, any key stops it, the screen again
replace the fixed screen (as fallback); R, a blank stick, YES: a replacement minted, its prompt;
it pulled: the screen; the old stick added: "not this system's Zuse stick -- not used",
no ok> for 30 s; the new one added: the prompt
mint_fail the fixed screen; R, a stick whose writes all fail (blkdebug): "failed -- nothing
changed", the screen again; the old stick added: the prompt (Review Focus 4)
system_pull_real logged in on her stick; the data stick pulled: hers let go first (no detach
refusal), session ended; the data stick replugged, hers still in: she is logged in
bam_flush --target qemu-stick --stick-gib 16: an Artemis block changed and SAVE-BUFFERS'd three
times, each timed (TIME:); each answers ok within 2 s (#155: it took 5-6 s); then the BAM's bytes on the
stick hashed (BAM:), to be the same before and after #155's change
@@ -129,7 +136,7 @@ NO_ZUSE_MODES = {"gpt_zuse", "gpt_hotplug", "gpt_foreign", "gpt_bad_crc", "gpt_b
"screen_dark_until_login", "screen_console_after_login", "screen_dark_after_logout",
"kbd_typeahead", "stick_boot", "stick_v3", "stick_zuse", "screen_boot", "genesis",
"stick_genesis", "stick_grow", "stick_small", "bam_flush",
"zuse_stick_first", "fallback"}
"zuse_stick_first", "fallback", "replace", "mint_fail", "system_pull_real"}
label = a.label or f"{a.mode}-{a.arch}"
work = os.path.join(ROOT, "build", "qemu-session", label)
shutil.rmtree(work, ignore_errors=True)
@@ -181,7 +188,7 @@ if a.stick_gib:
make_args.append(f"STICK_GIB={a.stick_gib}")
if a.mode in ("stick_grow", "stick_small", "bam_flush"):
make_args.append("KERNEL_ARGS=--log-level=info") # the blk: disk lines the sizes are read from
if a.mode in ("zuse_stick_first", "fallback"):
if a.mode in ("zuse_stick_first", "fallback", "replace", "mint_fail", "system_pull_real"):
# a data stick made once into the session's directory: minted on, then booted again
dstick = os.path.join(work, "data.img")
subprocess.run(["make", "-f", "kernel/Makefile", f"ARCH={a.arch}", "datastick", f"DATASTICK_IMG={dstick}"],
@@ -410,9 +417,13 @@ def add_zuse(n, img=None, fail_sector0=False):
drive=f"zuse{n}", id=f"zusedev{n}")
def add_stick(n, img, port):
"""A USB stick added over QMP on the xHCI controller's `port` (plan 2026-10-29-stick-5, Task 4)."""
qcmd("blockdev-add", driver="raw", **{"node-name": f"stick{n}"}, file={"driver": "file", "filename": img})
def add_stick(n, img, port, fail_writes=False):
"""A USB stick added over QMP on the xHCI controller's `port` (plan 2026-10-29-stick-5, Task 4);
with fail_writes, every write to it fails (blkdebug, EIO -- Task 5's mint_fail)."""
f = {"driver": "file", "filename": img}
if fail_writes:
f = {"driver": "blkdebug", "image": f, "inject-error": [{"event": "none", "iotype": "write", "errno": 5}]}
qcmd("blockdev-add", driver="raw", **{"node-name": f"stick{n}"}, file=f)
qcmd("device_add", driver="usb-storage", bus="xhci0.0", port=str(port), drive=f"stick{n}", id=f"stickdev{n}")
@@ -717,6 +728,88 @@ elif m == "fallback":
check("no ok> on the screen", "ok> " not in text()[text().rfind("Zuse: session ended"):])
check("no fault", count(r"EXCEPTION|PANIC|panic") == 0)
elif m in ("replace", "mint_fail", "system_pull_real"):
SCREEN0 = r"Zuse's stick is not here\."
old_img = os.path.join(work, "zuse-real.img")
subprocess.run(["truncate", "-s", "600M", old_img], check=True)
check("[zuse@Hera] ok> (the proxy, first boot)", wait_for(PROMPT, 300))
type_line("MINT-ZUSE")
wait_for(r"MINT-ZUSE: plug in the stick for the real Zuse", 60)
add_stick(1, old_img, 3)
wait_for(r"MINT-ZUSE: type YES to write it", 120)
type_line("YES")
check("the real Zuse minted (first boot)", wait_for(r"Zuse: real Zuse minted onto the second stick", 300))
shutdown()
print("-- the second boot: the data stick alone", flush=True)
boot([x for x in make_args if x != "clean"])
check("POST: PASSED (second boot)", wait_for(r"POST: PASSED", 900))
if m in ("replace", "mint_fail"):
check("the fixed screen", wait_for(SCREEN0, 120), near=r"Artemis: |Zuse")
time.sleep(3)
p0 = count(r"MINT-ZUSE: plug in the stick for the real Zuse")
s.send(b"R")
check("R: the plug-in line", wait_for(r"MINT-ZUSE: plug in the stick for the real Zuse", 60, p0))
new_img = os.path.join(work, "zuse-new.img")
subprocess.run(["truncate", "-s", "600M", new_img], check=True)
if m == "replace":
add_stick(2, new_img, 3)
wait_for(r"MINT-ZUSE: type YES to write it", 120)
c = count(r"Zuse: identity confirmed from attached thumbdrive")
type_line("YES")
check("a replacement minted", wait_for(r"Zuse: real Zuse minted onto the second stick", 300), near=r"MINT-ZUSE|Zuse:")
check("the new stick logs in", wait_for(r"Zuse: identity confirmed from attached thumbdrive", 120, c))
check("its prompt", wait_for(PROMPT, 60))
shots = count(SCREEN0)
qcmd("device_del", id="stickdev2")
check("the new stick pulled: the screen", wait_for(SCREEN0, 60, shots))
qcmd("blockdev-del", **{"node-name": "stick2"})
nr = count(r"Zuse: not this system's Zuse stick -- not used")
add_stick(3, old_img, 3)
check("the old stick: not this system's Zuse stick -- not used",
wait_for(r"Zuse: not this system's Zuse stick -- not used", 120, nr), near=r"Zuse|USB")
n = count(ANYPROMPT)
check("no ok> for 30 s with the old stick", not wait_for(ANYPROMPT, 30, n))
qcmd("device_del", id="stickdev3")
time.sleep(3)
qcmd("blockdev-del", **{"node-name": "stick3"})
c = count(r"Zuse: identity confirmed from attached thumbdrive")
add_stick(4, new_img, 3)
check("the new one again: identity confirmed", wait_for(r"Zuse: identity confirmed from attached thumbdrive", 120, c))
check("the prompt", wait_for(PROMPT, 60))
else:
shots = count(SCREEN0)
add_stick(2, new_img, 3, fail_writes=True)
wait_for(r"MINT-ZUSE: type YES to write it", 120)
type_line("YES")
check("MINT-ZUSE: failed -- nothing changed", wait_for(r"MINT-ZUSE: failed -- nothing changed", 300), near=r"MINT-ZUSE")
check("no replacement minted", count(r"real Zuse minted") == 1)
check("the fixed screen again", wait_for(SCREEN0, 60, shots))
qcmd("device_del", id="stickdev2")
time.sleep(3)
qcmd("blockdev-del", **{"node-name": "stick2"})
c = count(r"Zuse: identity confirmed from attached thumbdrive")
add_stick(3, old_img, 3)
check("the old stick still logs in", wait_for(r"Zuse: identity confirmed from attached thumbdrive", 120, c))
check("the prompt", wait_for(PROMPT, 60))
else:
wait_for(SCREEN0, 120)
c = count(r"Zuse: identity confirmed from attached thumbdrive")
add_stick(2, old_img, 3)
check("her stick: logged in", wait_for(r"Zuse: identity confirmed from attached thumbdrive", 120, c))
check("the prompt", wait_for(PROMPT, 60))
e = count(r"Zuse: session ended")
qcmd("device_del", id="datadev")
check("the data stick pulled: session ended", wait_for(r"Zuse: session ended -- reattach to re-authenticate", 60, e))
time.sleep(5)
check("no detach refusal in the log", re.search(r"detach.*(refus|fail|not the tail)", text(), re.I) is None)
data = os.path.join(work, "data.img") # the session's own data stick
c = count(r"Zuse: identity confirmed from attached thumbdrive")
add_stick(9, data, 2)
check("the data stick replugged, hers still in: she is logged in",
wait_for(r"Zuse: identity confirmed from attached thumbdrive", 120, c), near=r"Artemis: |Zuse|USB")
check("the prompt", wait_for(PROMPT, 60))
check("no fault", count(r"EXCEPTION|PANIC|panic") == 0)
elif m == "mint_zuse":
blank = os.path.join(work, "zuse-real.img")
subprocess.run(["truncate", "-s", "600M", blank], check=True)