Skip to content

Commit

Permalink
Make lrzsz work with ymodem test
Browse files Browse the repository at this point in the history
  • Loading branch information
jmbaur committed Jul 22, 2024
1 parent a787c01 commit 1c5a031
Showing 1 changed file with 26 additions and 22 deletions.
48 changes: 26 additions & 22 deletions tests/ymodem/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -31,27 +31,31 @@ testers.runNixOSTest {
with open(params, "x") as f:
f.write("init=${nodes.machine.system.build.toplevel}/init ${toString nodes.machine.boot.kernelParams}")
machine.start()
chardev = machine.send_monitor_command("chardev-add pty,id=ymodem")
machine.send_monitor_command("device_add virtconsole,chardev=ymodem")
machine.wait_for_console_text("press ENTER to interrupt")
machine.send_console("\n") # interrupt boot process
time.sleep(1)
machine.send_console("list\n")
machine.send_console("select 2\n") # TODO(jared): make this selection less vague
time.sleep(1)
machine.send_console("probe\n")
pty = re.findall(r"/dev/pts/[0-9]+", chardev)[0]
print(f"using pty {pty}")
subprocess.run(["${lib.getExe' tinybootTools "tboot-ymodem"}", "send", "--tty", pty, "--dir", host_boot_dir.name])
# with open(pty, "r+b") as f:
# TODO(jared): make this work with stdin/stdout
# subprocess.run(["${lib.getExe' lrzsz "sx"}", "--ymodem", "-kb", linux, initrd, params], stdin=f, stdout=f, text=False)
machine.send_console("boot\n")
machine.wait_for_unit("multi-user.target")
def tboot_ymodem(pty):
subprocess.run(["${lib.getExe' tinybootTools "tboot-ymodem"}", "send", "--tty", pty, "--dir", host_boot_dir.name])
def lrzsz(pty):
subprocess.run(f"${lib.getExe' lrzsz "sx"} --ymodem -kb {linux} {initrd} {params} > {pty} < {pty}", shell=True)
for fn in [tboot_ymodem, lrzsz]:
machine.start()
chardev = machine.send_monitor_command("chardev-add pty,id=ymodem")
machine.send_monitor_command("device_add virtconsole,chardev=ymodem")
machine.wait_for_console_text("press ENTER to interrupt")
machine.send_console("\n") # interrupt boot process
time.sleep(1)
machine.send_console("list\n")
machine.send_console("select 2\n") # TODO(jared): make this selection less vague
time.sleep(1)
machine.send_console("probe\n")
pty = re.findall(r"/dev/pts/[0-9]+", chardev)[0]
print(f"using pty {pty}")
fn(pty)
machine.send_console("boot\n")
machine.wait_for_unit("multi-user.target")
machine.shutdown()
machine.wait_for_shutdown()
'';
}

0 comments on commit 1c5a031

Please sign in to comment.