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}/ssh"
"${modulesPath}/mount"
"${modulesPath}/mdevd.nix"
];
filesystem = dir { srv = dir {}; };
@ -46,11 +47,20 @@ in rec {
rootfsType = "jffs2";
hostname = "inout";
services.mount_external_disk = svc.mount.build {
device = "LABEL=backup-disk";
mountpoint = "/srv";
fstype = "ext4";
};
services.watch_mount_srv =
let
node = "/dev/disk/by-partlabel/backup-disk";
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"
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
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
expect {
"mounted filesystem" { }
"sda: sda1" { }
timeout { exit 1 }
}
send "\r"
chat "READY_" "s6-rc -b -a list\r"
chat "READY_" "cat /proc/mounts\r"
chat "READY_" "sleep 3; grep /srv /proc/mounts && hostname\r"
expect {
"/srv" { }
"inout" { }
timeout { exit 1 }
}

View file

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