7 if [ $(t/root-status) != root ]; then
8 echo 'Not root: skipping --check-device tests.'
9 exit 0 # FIXME: add WVSKIP.
12 if test -z "$(type -p losetup)"; then
13 echo 'Unable to find losetup: skipping --check-device tests.'
14 exit 0 # FIXME: add WVSKIP.
17 if test -z "$(type -p mke2fs)"; then
18 echo 'Unable to find mke2fs: skipping --check-device tests.'
19 exit 0 # FIXME: add WVSKIP.
22 WVSTART '--check-device'
25 tmpdir="$(WVPASS wvmktempdir)" || exit $?
27 export BUP_DIR="$tmpdir/bup"
29 bup() { "$top/bup" "$@"; }
31 srcmnt="$(WVPASS wvmkmountpt)" || exit $?
32 tmpmnt1="$(WVPASS wvmkmountpt)" || exit $?
33 tmpmnt2="$(WVPASS wvmkmountpt)" || exit $?
37 WVPASS dd if=/dev/zero of=testfs.img bs=1M count=32
38 WVPASS mke2fs -F -j -m 0 testfs.img
39 WVPASS mount -o loop testfs.img "$tmpmnt1"
40 # Hide, so that tests can't create risks.
41 WVPASS chown root:root "$tmpmnt1"
42 WVPASS chmod 0700 "$tmpmnt1"
44 # Create trivial content.
45 WVPASS date > "$tmpmnt1/foo"
46 WVPASS umount "$tmpmnt1"
48 # Mount twice, so we'll have the same content with different devices.
49 WVPASS mount -oro,loop testfs.img "$tmpmnt1"
50 WVPASS mount -oro,loop testfs.img "$tmpmnt2"
52 # Test default behavior: --check-device.
53 WVPASS mount -oro --bind "$tmpmnt1" "$srcmnt"
55 WVPASS bup index --fake-valid "$srcmnt"
56 WVPASS umount "$srcmnt"
57 WVPASS mount -oro --bind "$tmpmnt2" "$srcmnt"
58 WVPASS bup index "$srcmnt"
59 WVPASSEQ "$(bup index --status "$srcmnt")" \
60 "M $srcmnt/lost+found/
63 WVPASS umount "$srcmnt"
65 WVSTART '--no-check-device'
66 WVPASS mount -oro --bind "$tmpmnt1" "$srcmnt"
67 WVPASS bup index --clear
68 WVPASS bup index --fake-valid "$srcmnt"
69 WVPASS umount "$srcmnt"
70 WVPASS mount -oro --bind "$tmpmnt2" "$srcmnt"
71 WVPASS bup index --no-check-device "$srcmnt"
72 WVPASS bup index --status "$srcmnt"
73 WVPASSEQ "$(bup index --status "$srcmnt")" \
78 WVPASS umount "$srcmnt"
79 WVPASS umount "$tmpmnt1"
80 WVPASS umount "$tmpmnt2"
81 WVPASS rm -r "$tmpmnt1" "$tmpmnt2" "$tmpdir"