From cec572daccafa1e912cbed363df6f84687778c6f Mon Sep 17 00:00:00 2001 From: Nicholas D Steeves Date: Sat, 23 Apr 2016 00:41:30 +0100 Subject: btrfs-progs (4.4.1-1.1) unstable; urgency=medium * Non-maintainer upload. * New upstream release. * Rename package to btrfs-progs (Closes: #780081) * Update standards version to 3.9.7 (no changes needed). * debian/control: Add "Breaks" per Gianfranco Costamagna's suggestion * Change lintian override to reflect package rename * Switch from using postinst and postrm to using triggers per Christian Seiler's recommendation. # imported from the archive --- .../misc-tests/006-image-on-missing-device/test.sh | 78 ++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100755 tests/misc-tests/006-image-on-missing-device/test.sh (limited to 'tests/misc-tests/006-image-on-missing-device/test.sh') diff --git a/tests/misc-tests/006-image-on-missing-device/test.sh b/tests/misc-tests/006-image-on-missing-device/test.sh new file mode 100755 index 00000000..8680a707 --- /dev/null +++ b/tests/misc-tests/006-image-on-missing-device/test.sh @@ -0,0 +1,78 @@ +#!/bin/bash +# test btrfs-image with a missing device (uses loop devices) +# +# - btrfs-image must not loop indefinetelly +# - btrfs-image will expectedly fail to produce the dump + +source $TOP/tests/common + +check_prereq btrfs-show-super +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 --list +} + +test_image_dump() +{ + run_check $SUDO_HELPER $TOP/btrfs check $dev1 + # the output file will be deleted + run_mayfail $SUDO_HELPER $TOP/btrfs-image $dev1 /tmp/test-img.dump +} + +test_run() +{ + run_check $SUDO_HELPER $TOP/mkfs.btrfs -f -d raid1 -m raid1 $dev1 $dev2 + + # we need extents to trigger reading from all devices + run_check $SUDO_HELPER mount $dev1 $TEST_MNT + run_check $SUDO_HELPER dd if=/dev/zero of=$TEST_MNT/a bs=1M count=10 + run_check $SUDO_HELPER dd if=/dev/zero of=$TEST_MNT/b bs=4k count=1000 conv=sync + run_check $SUDO_HELPER umount $TEST_MNT + + test_image_dump + run_check btrfs fi show $dev1 + # create a degraded raid1 filesystem, check must succeed + # btrfs-image must not loop + run_mayfail wipefs -a $dev2 + run_check $SUDO_HELPER losetup -d $dev2 + run_check btrfs fi show $dev1 + + test_image_dump +} + +prepare_devices +dev1=${devs[1]} +dev2=${devs[2]} +test_run +cleanup_devices -- cgit v1.2.3