btrfs-progs: tests: convert misc/006-image-on-missing-device to loopdevs
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
528a5bf6ad
commit
83fe48c54b
|
@ -10,38 +10,8 @@ check_prereq btrfs-image
|
|||
check_prereq mkfs.btrfs
|
||||
check_prereq btrfs
|
||||
|
||||
ndevs=2
|
||||
declare -a devs
|
||||
dev1=
|
||||
dev2=
|
||||
|
||||
setup_root_helper
|
||||
|
||||
|
||||
# TODO: move the helpers to common
|
||||
|
||||
prepare_devices()
|
||||
{
|
||||
for i in `seq $ndevs`; do
|
||||
touch img$i
|
||||
chmod a+rw img$i
|
||||
truncate -s0 img$i
|
||||
truncate -s2g img$i
|
||||
devs[$i]=`run_check_stdout $SUDO_HELPER losetup --find --show img$i`
|
||||
done
|
||||
}
|
||||
|
||||
cleanup_devices()
|
||||
{
|
||||
for dev in ${devs[@]}; do
|
||||
run_mayfail $SUDO_HELPER losetup -d $dev
|
||||
done
|
||||
for i in `seq $ndevs`; do
|
||||
truncate -s0 img$i
|
||||
done
|
||||
run_check $SUDO_HELPER losetup --all
|
||||
}
|
||||
|
||||
test_image_dump()
|
||||
{
|
||||
run_check $SUDO_HELPER $TOP/btrfs check $dev1
|
||||
|
@ -65,13 +35,15 @@ test_run()
|
|||
# btrfs-image must not loop
|
||||
run_mayfail wipefs -a $dev2
|
||||
run_check $SUDO_HELPER losetup -d $dev2
|
||||
unset loopdevs[2]
|
||||
run_check $SUDO_HELPER $TOP/btrfs filesystem show $dev1
|
||||
|
||||
test_image_dump
|
||||
}
|
||||
|
||||
prepare_devices
|
||||
dev1=${devs[1]}
|
||||
dev2=${devs[2]}
|
||||
setup_loopdevs 2
|
||||
prepare_loopdevs
|
||||
dev1=${loopdevs[1]}
|
||||
dev2=${loopdevs[2]}
|
||||
test_run
|
||||
cleanup_devices
|
||||
cleanup_loopdevs
|
||||
|
|
Loading…
Reference in New Issue