diff --git a/test/bare.test b/test/bare.test index d680caa..ae513d4 100755 --- a/test/bare.test +++ b/test/bare.test @@ -5,13 +5,14 @@ cleanup() { umount "${tmpdir}/root" || : - qemu-nbd -d /dev/nbd0 || : + qemu-nbd -d "$nbd" || : rm -rf "$tmpdir" } set -ef trap cleanup EXIT INT +nbd=${NBD:-/dev/nbd1} devmgr=${DEVMGR:-proc} arch=${ARCH:-$(uname -m)} kernel=${KERNEL:-$(uname -r)} @@ -25,7 +26,7 @@ image="${tmpdir}/root.qcow2" initrd="${tmpdir}/initramfs-$(uname -r)" qemu-img create -f qcow2 "$image" 1G -qemu-nbd -c /dev/nbd0 "$image" +qemu-nbd -c "$nbd" "$image" # o: Create MBR table. # n: Add new partition to table. @@ -34,7 +35,7 @@ qemu-nbd -c /dev/nbd0 "$image" # newline: Use default value for first sector. # newline: Use default value for last sector. # w: Write changes and re-read partition table. -fdisk /dev/nbd0 << EOF +fdisk "$nbd" << EOF o n p @@ -51,8 +52,8 @@ EOF mkdir -p "$root" -mkfs.ext4 -L root /dev/nbd0p1 -mount /dev/nbd0p1 "$root" +mkfs.ext4 -L root "${nbd}p1" +mount "${nbd}p1" "$root" ( tmpdir=$root; cd "$tmpdir" @@ -78,7 +79,7 @@ EOF ) umount "$root" -qemu-nbd -d /dev/nbd0 +qemu-nbd -d "$nbd" (cd .. && ./tinyramfs -lk "$kernel" -c "$config" "$initrd") @@ -101,11 +102,11 @@ fi "qemu-system-${arch}" "$@" -qemu-nbd -c /dev/nbd0 "$image" +qemu-nbd -c "$nbd" "$image" # Re-read partition table. -fdisk /dev/nbd0 << EOF +fdisk "$nbd" << EOF w EOF -[ "$(e2label /dev/nbd0p1)" = success ] +[ "$(e2label "${nbd}p1")" = success ] diff --git a/test/luks.test b/test/luks.test index 37b1db7..1b82838 100755 --- a/test/luks.test +++ b/test/luks.test @@ -6,7 +6,7 @@ cleanup() { umount "${tmpdir}/root" || : cryptsetup close "$name" || : - qemu-nbd -d /dev/nbd0 || : + qemu-nbd -d "$nbd" || : rm -rf "$tmpdir" } @@ -15,6 +15,7 @@ command -v cryptsetup > /dev/null || exit 222 set -ef trap cleanup EXIT INT +nbd=${NBD:-/dev/nbd2} devmgr=${DEVMGR:-proc} arch=${ARCH:-$(uname -m)} kernel=${KERNEL:-$(uname -r)} @@ -29,7 +30,7 @@ image="${tmpdir}/root.qcow2" initrd="${tmpdir}/initramfs-$(uname -r)" qemu-img create -f qcow2 "$image" 1G -qemu-nbd -c /dev/nbd0 "$image" +qemu-nbd -c "$nbd" "$image" # o: Create MBR table. # n: Add new partition to table. @@ -38,7 +39,7 @@ qemu-nbd -c /dev/nbd0 "$image" # newline: Use default value for first sector. # newline: Use default value for last sector. # w: Write changes and re-read partition table. -fdisk /dev/nbd0 << EOF +fdisk "$nbd" << EOF o n p @@ -50,13 +51,13 @@ EOF dd bs=512 count=1 if=/dev/urandom of="${tmpdir}/key" -cryptsetup -qd "${tmpdir}/key" --pbkdf=pbkdf2 luksFormat /dev/nbd0p1 -cryptsetup -d "${tmpdir}/key" open /dev/nbd0p1 "$name" +cryptsetup -qd "${tmpdir}/key" --pbkdf=pbkdf2 luksFormat "${nbd}p1" +cryptsetup -d "${tmpdir}/key" open "${nbd}p1" "$name" cat > "$config" << EOF hooks=$devmgr,luks root=LABEL=root -luks_root=UUID=$(cryptsetup luksUUID /dev/nbd0p1) +luks_root=UUID=$(cryptsetup luksUUID "${nbd}p1") luks_key=${tmpdir}/key EOF @@ -90,7 +91,7 @@ EOF umount "$root" cryptsetup close "$name" -qemu-nbd -d /dev/nbd0 +qemu-nbd -d "$nbd" (cd .. && ./tinyramfs -lk "$kernel" -c "$config" "$initrd") @@ -113,13 +114,13 @@ fi "qemu-system-${arch}" "$@" -qemu-nbd -c /dev/nbd0 "$image" +qemu-nbd -c "$nbd" "$image" # Re-read partition table. -fdisk /dev/nbd0 << EOF +fdisk "$nbd" << EOF w EOF -cryptsetup -d "${tmpdir}/key" open /dev/nbd0p1 "$name" +cryptsetup -d "${tmpdir}/key" open "${nbd}p1" "$name" [ "$(e2label "/dev/mapper/${name}")" = success ] diff --git a/test/lvm.test b/test/lvm.test index a02563c..d37b441 100755 --- a/test/lvm.test +++ b/test/lvm.test @@ -6,7 +6,7 @@ cleanup() { umount "${tmpdir}/root" || : vgchange -an "$vg" || : - qemu-nbd -d /dev/nbd0 || : + qemu-nbd -d "$nbd" || : rm -rf "$tmpdir" } @@ -15,6 +15,7 @@ command -v lvm > /dev/null || exit 222 set -ef trap cleanup EXIT INT +nbd=${NBD:-/dev/nbd3} devmgr=${DEVMGR:-proc} arch=${ARCH:-$(uname -m)} kernel=${KERNEL:-$(uname -r)} @@ -30,7 +31,7 @@ image="${tmpdir}/root.qcow2" initrd="${tmpdir}/initramfs-$(uname -r)" qemu-img create -f qcow2 "$image" 1G -qemu-nbd -c /dev/nbd0 "$image" +qemu-nbd -c "$nbd" "$image" # o: Create MBR table. # n: Add new partition to table. @@ -39,7 +40,7 @@ qemu-nbd -c /dev/nbd0 "$image" # newline: Use default value for first sector. # newline: Use default value for last sector. # w: Write changes and re-read partition table. -fdisk /dev/nbd0 << EOF +fdisk "$nbd" << EOF o n p @@ -56,7 +57,7 @@ lvm_group=$vg lvm_name=$lv EOF -vgcreate "$vg" /dev/nbd0p1 +vgcreate "$vg" "${nbd}p1" lvcreate -l 100%FREE -n "$lv" "$vg" lvchange -ay "${vg}/${lv}" @@ -90,7 +91,7 @@ EOF umount "$root" vgchange -an "$vg" -qemu-nbd -d /dev/nbd0 +qemu-nbd -d "$nbd" (cd .. && ./tinyramfs -lk "$kernel" -c "$config" "$initrd") @@ -113,10 +114,10 @@ fi "qemu-system-${arch}" "$@" -qemu-nbd -c /dev/nbd0 "$image" +qemu-nbd -c "$nbd" "$image" # Re-read partition table. -fdisk /dev/nbd0 << EOF +fdisk "$nbd" << EOF w EOF diff --git a/test/zfs.test b/test/zfs.test index 1b7565e..ffb199c 100755 --- a/test/zfs.test +++ b/test/zfs.test @@ -5,7 +5,7 @@ cleanup() { zpool export "$pool" || : - qemu-nbd -d /dev/nbd0 || : + qemu-nbd -d "$nbd" || : rm -rf "$tmpdir" } @@ -14,6 +14,7 @@ command -v zfs > /dev/null || exit 222 set -ef trap cleanup EXIT INT +nbd=${NBD:-/dev/nbd4} devmgr=${DEVMGR:-proc} arch=${ARCH:-$(uname -m)} kernel=${KERNEL:-$(uname -r)} @@ -28,7 +29,7 @@ image="${tmpdir}/root.qcow2" initrd="${tmpdir}/initramfs-$(uname -r)" qemu-img create -f qcow2 "$image" 1G -qemu-nbd -c /dev/nbd0 "$image" +qemu-nbd -c "$nbd" "$image" # o: Create MBR table. # n: Add new partition to table. @@ -37,7 +38,7 @@ qemu-nbd -c /dev/nbd0 "$image" # newline: Use default value for first sector. # newline: Use default value for last sector. # w: Write changes and re-read partition table. -fdisk /dev/nbd0 << EOF +fdisk "$nbd" << EOF o n p @@ -49,7 +50,7 @@ EOF dd bs=512 count=1 if=/dev/urandom of="${tmpdir}/key" -zpool create -m none "$pool" /dev/nbd0p1 +zpool create -m none "$pool" "${nbd}p1" zfs create \ -o mountpoint=legacy \ -o canmount=noauto \ @@ -96,7 +97,7 @@ EOF ) zpool export "$pool" -qemu-nbd -d /dev/nbd0 +qemu-nbd -d "$nbd" (cd .. && ./tinyramfs -lk "$kernel" -c "$config" "$initrd") @@ -119,13 +120,13 @@ fi "qemu-system-${arch}" "$@" -qemu-nbd -c /dev/nbd0 "$image" +qemu-nbd -c "$nbd" "$image" # Re-read partition table. -fdisk /dev/nbd0 << EOF +fdisk "$nbd" << EOF w EOF -zpool import -Nd /dev/nbd0p1 "$pool" +zpool import -Nd "${nbd}p1" "$pool" [ "$(zfs get -Ho value success: "${pool}/root")" = true ]