2 . ./wvtest-bup.sh || exit $?
3 . ./dev/lib.sh || exit $?
7 root_status="$(dev/root-status)" || exit $?
9 if [ "$root_status" != root ]; then
10 WVSKIP 'Not root: skipping --check-device tests.'
14 if test -n "$(type -p modprobe)" && ! modprobe loop; then
15 WVSKIP 'Unable to load loopback module; skipping --check-device test.'
19 if test -z "$(type -p losetup)"; then
20 WVSKIP 'Unable to find losetup: skipping --check-device tests.'
24 if test -z "$(type -p mke2fs)"; then
25 WVSKIP 'Unable to find mke2fs: skipping --check-device tests.'
29 WVSTART '--check-device'
32 tmpdir="$(WVPASS wvmktempdir)" || exit $?
34 export BUP_DIR="$tmpdir/bup"
36 bup() { "$top/bup" "$@"; }
38 srcmnt="$(WVPASS wvmkmountpt)" || exit $?
39 tmpmnt1="$(WVPASS wvmkmountpt)" || exit $?
40 tmpmnt2="$(WVPASS wvmkmountpt)" || exit $?
44 WVPASS dd if=/dev/zero of=testfs.img bs=1M count=32
45 WVPASS mke2fs -F -j -m 0 testfs.img
46 WVPASS mount -o loop testfs.img "$tmpmnt1"
47 # Hide, so that tests can't create risks.
48 WVPASS chown root:root "$tmpmnt1"
49 WVPASS chmod 0700 "$tmpmnt1"
51 # Create trivial content.
52 WVPASS date > "$tmpmnt1/foo"
53 # A non-lazy umount was reported to fail on some systems
54 WVPASS umount -l "$tmpmnt1"
56 # Mount twice, so we'll have the same content with different devices.
57 WVPASS cp -pP testfs.img testfs2.img
58 WVPASS mount -oro,loop testfs.img "$tmpmnt1"
59 WVPASS mount -oro,loop testfs2.img "$tmpmnt2"
61 # Test default behavior: --check-device.
62 WVPASS mount -oro --bind "$tmpmnt1" "$srcmnt"
64 WVPASS bup index --fake-valid "$srcmnt"
65 WVPASS umount "$srcmnt"
66 WVPASS mount -oro --bind "$tmpmnt2" "$srcmnt"
67 WVPASS bup index "$srcmnt"
68 WVPASSEQ "$(bup index --status "$srcmnt")" \
69 "M $srcmnt/lost+found/
72 WVPASS umount "$srcmnt"
74 WVSTART '--no-check-device'
75 WVPASS mount -oro --bind "$tmpmnt1" "$srcmnt"
76 WVPASS bup index --clear
77 WVPASS bup index --fake-valid "$srcmnt"
78 WVPASS umount "$srcmnt"
79 WVPASS mount -oro --bind "$tmpmnt2" "$srcmnt"
80 WVPASS bup index --no-check-device "$srcmnt"
81 WVPASS bup index --status "$srcmnt"
82 WVPASSEQ "$(bup index --status "$srcmnt")" \
87 WVPASS umount "$srcmnt"
88 WVPASS umount "$tmpmnt1"
89 WVPASS umount "$tmpmnt2"
90 WVPASS rm -r "$tmpmnt1" "$tmpmnt2" "$tmpdir"