commit 5572c0ecb0b2d404053aa069de0f1c5217793a61
parent 4cbe3ba6830f68d0b104f4fd9e33a507f18a47fb
Author: Daniel Barlow <dan@telent.net>
Date: Mon, 9 Dec 2024 23:36:22 +0000
rewrite parts of inout test to be differently wrong
Diffstat:
2 files changed, 29 insertions(+), 15 deletions(-)
diff --git a/tests/inout/script.expect b/tests/inout/script.expect
@@ -1,4 +1,5 @@
-set timeout 10
+set timeout 40
+fconfigure stdout -buffering none
set when [lindex $argv 0];
@@ -7,9 +8,11 @@ send_user "\n\n\n\n#################################\n running $when"
spawn socat -,echo=0,icanon=1 unix-connect:vm/monitor
set monitor_id $spawn_id
+fconfigure $monitor_id -buffering none
spawn socat unix-connect:vm/console -
set console_id $spawn_id
+fconfigure $console_id -buffering none
proc chat {instr outstr} {
expect {
@@ -22,17 +25,20 @@ proc adddevice { } {
global monitor_id console_id spawn_id
set spawn_id $monitor_id
- send_user "inserting usb device"
+ send_user "\n#### inserting usb device"
send "\r\n"
chat "QEMU" "device_add usb-storage,bus=xhci.0,drive=usbstick\n"
- chat "(qemu)" "version\r"
set spawn_id $console_id
+
expect {
"sda: sda1" { }
- timeout { exit 1 }
+ timeout {
+ puts stderr "timeout waiting for disk"
+ exit 1
+ }
}
- send_user "done inserting usb device"
+ send_user "done inserting usb device"
}
if { $when eq "early" } {
@@ -41,21 +47,25 @@ if { $when eq "early" } {
expect "BusyBox"
chat "#" "PS1=RE\\ADY_\\ ; stty -echo \r"
+# script needs klogd output to tell when sda1 appears. Then
+# run s6-rc -b -a list to wait for booting to finish
chat "READY_" "tail -f /run/log/current & \rs6-rc -b -a list\r"
-chat "mount" "\r"
-
if { $when eq "late" } {
adddevice
}
send_user "\n\n\nwaiting for mount to happen"
-send "\r"
-set timeout 20
-## 1234
-chat "READY_" "sleep 5; grep /srv /proc/mounts && hostname\r"
-
-expect {
- "inout" { }
- timeout { exit 1 }
+
+set FINISHED 0
+set EXIT "1"
+while { $FINISHED < 10 } {
+ chat "READY_" "grep /srv /proc/mounts\r\n"
+ expect {
+ "backup-disk" { set FINISHED 20; set EXIT 0; }
+ "READY_" { send_user "waiting ...\n" ; send "\r\n"; sleep 6 }
+ }
+ set FINISHED [ expr $FINISHED + 1 ]
}
+
+exit $EXIT
diff --git a/tests/inout/test.nix b/tests/inout/test.nix
@@ -18,13 +18,17 @@ mkfs.ext2 -L backup-disk ./vm/stick.e2fs
dd if=/dev/zero of=./vm/stick.img bs=1M count=38
dd if=./vm/stick.e2fs of=./vm/stick.img bs=512 seek=34 conv=notrunc
parted -s ./vm/stick.img -- mklabel gpt mkpart backup-disk ext2 34s -0M
+sync
+cp ./vm/stick.img ./vm/stick.img.orig
{
+
${img}/run.sh --background ./vm --flag -device --flag usb-ehci,id=xhci --flag -drive --flag if=none,id=usbstick,format=raw,file=$(pwd)/vm/stick.img
expect ${./script.expect} late
kill $(cat ./vm/pid)
+cp ./vm/stick.img.orig ./vm/stick.img
${img}/run.sh --background ./vm --flag -device --flag usb-ehci,id=xhci --flag -drive --flag if=none,id=usbstick,format=raw,file=$(pwd)/vm/stick.img
expect ${./script.expect} early