X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=t%2Ftest-index-check-device.sh;h=88a966a330dff54b2ddf148e40b91482c1536c59;hb=ae9cde2e3df85569bf76487a9528080926841db5;hp=0ffc3b878ed997e4a5ac34a2a055d704f29c1e81;hpb=91b23d50390bc555063a0c6863b31b19b3fd99dc;p=bup.git diff --git a/t/test-index-check-device.sh b/t/test-index-check-device.sh index 0ffc3b8..88a966a 100755 --- a/t/test-index-check-device.sh +++ b/t/test-index-check-device.sh @@ -1,80 +1,89 @@ #!/usr/bin/env bash -. ./wvtest-bup.sh -. ./t/lib.sh +. ./wvtest-bup.sh || exit $? +. ./t/lib.sh || exit $? -set -ex -o pipefail +set -o pipefail -if [ $(t/root-status) != root ]; then +root_status="$(t/root-status)" || exit $? + +if [ "$root_status" != root ]; then echo 'Not root: skipping --check-device tests.' exit 0 # FIXME: add WVSKIP. fi +if test -n "$(type -p modprobe)" && ! modprobe loop; then + echo 'Unable to load loopback module; skipping --check-device test.' 1>&2 + exit 0 +fi + if test -z "$(type -p losetup)"; then - echo 'Unable to find losetup: skipping --check-device tests.' + echo 'Unable to find losetup: skipping --check-device tests.' 1>&2 exit 0 # FIXME: add WVSKIP. fi if test -z "$(type -p mke2fs)"; then - echo 'Unable to find mke2fs: skipping --check-device tests.' + echo 'Unable to find mke2fs: skipping --check-device tests.' 1>&2 exit 0 # FIXME: add WVSKIP. fi WVSTART '--check-device' top="$(pwd)" -tmpdir="$(wvmktempdir)" +tmpdir="$(WVPASS wvmktempdir)" || exit $? + export BUP_DIR="$tmpdir/bup" bup() { "$top/bup" "$@"; } -srcmnt="$(wvmkmountpt)" -tmpmnt1="$(wvmkmountpt)" -tmpmnt2="$(wvmkmountpt)" +srcmnt="$(WVPASS wvmkmountpt)" || exit $? +tmpmnt1="$(WVPASS wvmkmountpt)" || exit $? +tmpmnt2="$(WVPASS wvmkmountpt)" || exit $? -cd "$tmpdir" +WVPASS cd "$tmpdir" -dd if=/dev/zero of=testfs.img bs=1M count=32 -mke2fs -F -j -m 0 testfs.img -mount -o loop testfs.img "$tmpmnt1" +WVPASS dd if=/dev/zero of=testfs.img bs=1M count=32 +WVPASS mke2fs -F -j -m 0 testfs.img +WVPASS mount -o loop testfs.img "$tmpmnt1" # Hide, so that tests can't create risks. -chown root:root "$tmpmnt1" -chmod 0700 "$tmpmnt1" +WVPASS chown root:root "$tmpmnt1" +WVPASS chmod 0700 "$tmpmnt1" # Create trivial content. -date > "$tmpmnt1/foo" -umount "$tmpmnt1" +WVPASS date > "$tmpmnt1/foo" +WVPASS umount "$tmpmnt1" # Mount twice, so we'll have the same content with different devices. -mount -oro,loop testfs.img "$tmpmnt1" -mount -oro,loop testfs.img "$tmpmnt2" +WVPASS cp -pP testfs.img testfs2.img +WVPASS mount -oro,loop testfs.img "$tmpmnt1" +WVPASS mount -oro,loop testfs2.img "$tmpmnt2" # Test default behavior: --check-device. -mount -oro --bind "$tmpmnt1" "$srcmnt" -bup init -bup index --fake-valid "$srcmnt" -umount "$srcmnt" -mount -oro --bind "$tmpmnt2" "$srcmnt" -bup index "$srcmnt" +WVPASS mount -oro --bind "$tmpmnt1" "$srcmnt" +WVPASS bup init +WVPASS bup index --fake-valid "$srcmnt" +WVPASS umount "$srcmnt" +WVPASS mount -oro --bind "$tmpmnt2" "$srcmnt" +WVPASS bup index "$srcmnt" WVPASSEQ "$(bup index --status "$srcmnt")" \ "M $srcmnt/lost+found/ M $srcmnt/foo M $srcmnt/" -umount "$srcmnt" +WVPASS umount "$srcmnt" WVSTART '--no-check-device' -mount -oro --bind "$tmpmnt1" "$srcmnt" -bup index --clear -bup index --fake-valid "$srcmnt" -umount "$srcmnt" -mount -oro --bind "$tmpmnt2" "$srcmnt" -bup index --no-check-device "$srcmnt" -bup index --status "$srcmnt" +WVPASS mount -oro --bind "$tmpmnt1" "$srcmnt" +WVPASS bup index --clear +WVPASS bup index --fake-valid "$srcmnt" +WVPASS umount "$srcmnt" +WVPASS mount -oro --bind "$tmpmnt2" "$srcmnt" +WVPASS bup index --no-check-device "$srcmnt" +WVPASS bup index --status "$srcmnt" WVPASSEQ "$(bup index --status "$srcmnt")" \ " $srcmnt/lost+found/ $srcmnt/foo $srcmnt/" -umount "$srcmnt" -umount "$tmpmnt1" -umount "$tmpmnt2" -rm -r "$tmpmnt1" "$tmpmnt2" "$tmpdir" +WVPASS umount "$srcmnt" +WVPASS umount "$tmpmnt1" +WVPASS umount "$tmpmnt2" +WVPASS rm -r "$tmpmnt1" "$tmpmnt2" "$tmpdir"