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="$(wvmktempdir)"
26 export BUP_DIR="$tmpdir/bup"
28 bup() { "$top/bup" "$@"; }
30 srcmnt="$(wvmkmountpt)"
31 tmpmnt1="$(wvmkmountpt)"
32 tmpmnt2="$(wvmkmountpt)"
36 dd if=/dev/zero of=testfs.img bs=1M count=32
37 mke2fs -F -j -m 0 testfs.img
38 mount -o loop testfs.img "$tmpmnt1"
39 # Hide, so that tests can't create risks.
40 chown root:root "$tmpmnt1"
43 # Create trivial content.
47 # Mount twice, so we'll have the same content with different devices.
48 mount -oro,loop testfs.img "$tmpmnt1"
49 mount -oro,loop testfs.img "$tmpmnt2"
51 # Test default behavior: --check-device.
52 mount -oro --bind "$tmpmnt1" "$srcmnt"
54 bup index --fake-valid "$srcmnt"
56 mount -oro --bind "$tmpmnt2" "$srcmnt"
58 WVPASSEQ "$(bup index --status "$srcmnt")" \
59 "M $srcmnt/lost+found/
64 WVSTART '--no-check-device'
65 mount -oro --bind "$tmpmnt1" "$srcmnt"
67 bup index --fake-valid "$srcmnt"
69 mount -oro --bind "$tmpmnt2" "$srcmnt"
70 bup index --no-check-device "$srcmnt"
71 bup index --status "$srcmnt"
72 WVPASSEQ "$(bup index --status "$srcmnt")" \
80 rm -r "$tmpmnt1" "$tmpmnt2" "$tmpdir"