2 . ./wvtest-bup.sh || exit $?
6 root_status="$(dev/root-status)" || exit $?
8 if [ "$root_status" != root ]; then
9 WVSTART 'not root: skipping tests'
10 exit 0 # FIXME: add WVSKIP.
13 if ! modprobe loop; then
14 WVSTART 'unable to load loopback module; skipping tests' 1>&2
18 # These tests are only likely to work under Linux for now
20 if ! [[ $(uname) =~ Linux ]]; then
21 WVSTART 'not Linux: skipping tests'
22 exit 0 # FIXME: add WVSKIP.
25 top="$(WVPASS pwd)" || exit $?
26 tmpdir="$(WVPASS wvmktempdir)" || exit $?
28 export BUP_DIR="$tmpdir/bup"
29 export GIT_DIR="$tmpdir/bup"
31 bup() { "$top/bup" "$@"; }
34 WVPASS pushd "$tmpdir"
38 WVPASS dd if=/dev/zero of=testfs-1.img bs=1M count=32
39 WVPASS dd if=/dev/zero of=testfs-2.img bs=1M count=32
40 WVPASS mkfs -F testfs-1.img # Don't care what type (though must have symlinks)
41 WVPASS mkfs -F testfs-2.img # Don't care what type (though must have symlinks)
42 WVPASS mkdir -p src/mnt-1/hidden-1 src/mnt-2/hidden-2
43 WVPASS mount -o loop testfs-1.img src/mnt-1
44 WVPASS mount -o loop testfs-2.img src/mnt-2
48 WVPASS mkdir -p src/mnt-1/x
49 WVPASS touch src/mnt-1/2 src/mnt-1/x/3
51 WVPASS touch src/mnt-2/4
53 (WVPASS cd src && WVPASS ln -s mnt-2 mnt-link)
54 (WVPASS cd src && WVPASS ln -s . top)
56 WVPASSEQ "$(bup drecurse src | grep -vF lost+found)" "src/top
67 WVPASSEQ "$(bup drecurse -x src)" "src/top
74 WVSTART 'index/save/restore'
77 WVPASS bup save -n src src
78 WVPASS mkdir src-restore
79 WVPASS bup restore -C src-restore "/src/latest$(pwd)/"
80 WVPASS test -d src-restore/src
81 WVPASS "$top/dev/compare-trees" -c src/ src-restore/src/
83 # Test -x when none of the mount points are explicitly indexed
84 WVPASS rm -r "$BUP_DIR" src-restore
86 WVPASS bup index -x src
87 WVPASS bup save -n src src
88 WVPASS mkdir src-restore
89 WVPASS bup restore -C src-restore "/src/latest$(pwd)/"
90 WVPASS test -d src-restore/src
91 WVPASSEQ "$(cd src-restore/src && find . -not -name lost+found | LC_ALL=C sort)" \
99 # Test -x when a mount point is explicitly indexed. This should
101 WVPASS rm -r "$BUP_DIR" src-restore
103 WVPASS bup index -x src src/mnt-2
104 WVPASS bup save -n src src
105 WVPASS mkdir src-restore
106 WVPASS bup restore -C src-restore "/src/latest$(pwd)/"
107 WVPASS test -d src-restore/src
108 WVPASSEQ "$(cd src-restore/src && find . -not -name lost+found | LC_ALL=C sort)" \
117 # Test -x when a direct link to a mount point is explicitly indexed.
118 # This should *not* include the mount.
119 WVPASS rm -r "$BUP_DIR" src-restore
121 WVPASS bup index -x src src/mnt-link
122 WVPASS bup save -n src src
123 WVPASS mkdir src-restore
124 WVPASS bup restore -C src-restore "/src/latest$(pwd)/"
125 WVPASS test -d src-restore/src
126 WVPASSEQ "$(cd src-restore/src && find . -not -name lost+found | LC_ALL=C sort)" \
134 # Test -x when a path that resolves to a mount point is explicitly
135 # indexed (i.e. dir symlnks that redirect the leaf to a mount point).
136 # This should include the mount.
137 WVPASS rm -r "$BUP_DIR" src-restore
139 WVPASS bup index -x src src/top/top/mnt-2
140 WVPASS bup save -n src src
141 WVPASS mkdir src-restore
142 WVPASS bup restore -C src-restore "/src/latest$(pwd)/"
143 WVPASS test -d src-restore/src
144 WVPASSEQ "$(cd src-restore/src && find . -not -name lost+found | LC_ALL=C sort)" \
154 WVPASS umount "$tmpdir/src/mnt-1"
155 WVPASS umount "$tmpdir/src/mnt-2"
156 WVPASS rm -r "$tmpdir"