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