convert inout test to use uevent-watch

This commit is contained in:
Daniel Barlow 2024-04-15 22:15:27 +01:00
parent 41a4b1f7ef
commit a5f16dfa81
3 changed files with 26 additions and 15 deletions

View file

@ -15,6 +15,7 @@ in rec {
"${modulesPath}/network" "${modulesPath}/network"
"${modulesPath}/ssh" "${modulesPath}/ssh"
"${modulesPath}/mount" "${modulesPath}/mount"
"${modulesPath}/mdevd.nix"
]; ];
filesystem = dir { srv = dir {}; }; filesystem = dir { srv = dir {}; };
@ -46,11 +47,20 @@ in rec {
rootfsType = "jffs2"; rootfsType = "jffs2";
hostname = "inout"; hostname = "inout";
services.mount_external_disk = svc.mount.build { services.watch_mount_srv =
device = "LABEL=backup-disk"; let
mountpoint = "/srv"; node = "/dev/disk/by-partlabel/backup-disk";
fstype = "ext4"; mount = oneshot {
name = "mount-srv";
up = "mount -t ext2 ${node} /srv";
down = "umount /srv";
};
in longrun {
name = "mount_srv";
run = ''
${pkgs.uevent-watch}/bin/uevent-watch -s ${mount.name} -n ${node} partname=backup-disk devtype=partition
'';
dependencies = [ config.services.mdevd ];
buildInputs = [ mount ];
}; };
} }

View file

@ -14,9 +14,9 @@ set console_id $spawn_id
expect "BusyBox" expect "BusyBox"
chat "#" "PS1=RE\\ADY_\\ ; stty -echo \r" chat "#" "PS1=RE\\ADY_\\ ; stty -echo \r"
chat "READY_" "s6-rc -b -a list\r" chat "READY_" "tail -f /run/uncaught-logs/current & \rs6-rc -b -a list\r"
chat "watch-mount" "\r" chat "mount" "\r"
set spawn_id $monitor_id set spawn_id $monitor_id
chat "QEMU" "device_add usb-storage,bus=xhci.0,drive=usbstick\n" chat "QEMU" "device_add usb-storage,bus=xhci.0,drive=usbstick\n"
@ -25,16 +25,15 @@ chat "(qemu)" "version\r"
set spawn_id $console_id set spawn_id $console_id
expect { expect {
"mounted filesystem" { } "sda: sda1" { }
timeout { exit 1 } timeout { exit 1 }
} }
send "\r" send "\r"
chat "READY_" "s6-rc -b -a list\r" chat "READY_" "sleep 3; grep /srv /proc/mounts && hostname\r"
chat "READY_" "cat /proc/mounts\r"
expect { expect {
"/srv" { } "inout" { }
timeout { exit 1 } timeout { exit 1 }
} }

View file

@ -13,13 +13,15 @@ in pkgs.runCommand "check" {
socat socat
e2fsprogs e2fsprogs
util-linux # for sfdisk, fallocate util-linux # for sfdisk, fallocate
parted
] ; ] ;
} '' } ''
mkdir vm mkdir vm
dd if=/dev/zero of=./vm/stick.e2fs bs=1M count=32 dd if=/dev/zero of=./vm/stick.e2fs bs=1M count=32
mkfs.ext2 -L backup-disk ./vm/stick.e2fs mkfs.ext2 -L backup-disk ./vm/stick.e2fs
cat <(dd if=/dev/zero bs=512 count=4) ./vm/stick.e2fs > ./vm/stick.img dd if=/dev/zero of=./vm/stick.img bs=1M count=38
echo '4,-,L,*' | sfdisk ./vm/stick.img 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
${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 ${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} | tee $out expect ${./script.expect} | tee $out