2 . ./wvtest-bup.sh || exit $?
6 if [ $(t/root-status) != root ]; then
7 WVSTART 'not root: skipping tests'
8 exit 0 # FIXME: add WVSKIP.
11 if ! modprobe loop; then
12 WVSTART 'unable to load loopback module; skipping tests' 1>&2
16 # These tests are only likely to work under Linux for now
18 if ! [[ $(uname) =~ Linux ]]; then
19 WVSTART 'not Linux: skipping tests'
20 exit 0 # FIXME: add WVSKIP.
23 top="$(WVPASS pwd)" || exit $?
24 tmpdir="$(WVPASS wvmktempdir)" || exit $?
26 export BUP_DIR="$tmpdir/bup"
27 export GIT_DIR="$tmpdir/bup"
29 bup() { "$top/bup" "$@"; }
32 WVPASS pushd "$tmpdir"
36 WVPASS dd if=/dev/zero of=testfs-1.img bs=1M count=32
37 WVPASS dd if=/dev/zero of=testfs-2.img bs=1M count=32
38 WVPASS mkfs -F testfs-1.img # Don't care what type (though must have symlinks)
39 WVPASS mkfs -F testfs-2.img # Don't care what type (though must have symlinks)
40 WVPASS mkdir -p src/mnt-1/hidden-1 src/mnt-2/hidden-2
41 WVPASS mount -o loop testfs-1.img src/mnt-1
42 WVPASS mount -o loop testfs-1.img src/mnt-2
46 WVPASS mkdir -p src/mnt-1/x
47 WVPASS touch src/mnt-1/2 src/mnt-1/x/3
49 WVPASS touch src/mnt-2/4
51 (WVPASS cd src && WVPASS ln -s mnt-2 mnt-link)
52 (WVPASS cd src && WVPASS ln -s . top)
54 WVPASSEQ "$(bup drecurse src | grep -vF lost+found)" "src/top
65 WVPASSEQ "$(bup drecurse -x src)" "src/top
72 WVSTART 'index/save/restore'
75 WVPASS bup save -n src src
76 WVPASS mkdir src-restore
77 WVPASS bup restore -C src-restore "/src/latest$(pwd)/"
78 WVPASS test -d src-restore/src
79 WVPASS "$top/t/compare-trees" -c src/ src-restore/src/
81 # Test -x when none of the mount points are explicitly indexed
82 WVPASS rm -r "$BUP_DIR" src-restore
84 WVPASS bup index -x src
85 WVPASS bup save -n src src
86 WVPASS mkdir src-restore
87 WVPASS bup restore -C src-restore "/src/latest$(pwd)/"
88 WVPASS test -d src-restore/src
89 WVPASSEQ "$(cd src-restore/src && find . -not -name lost+found | LC_ALL=C sort)" \
97 # Test -x when a mount point is explicitly indexed. This should
99 WVPASS rm -r "$BUP_DIR" src-restore
101 WVPASS bup index -x src src/mnt-2
102 WVPASS bup save -n src src
103 WVPASS mkdir src-restore
104 WVPASS bup restore -C src-restore "/src/latest$(pwd)/"
105 WVPASS test -d src-restore/src
106 WVPASSEQ "$(cd src-restore/src && find . -not -name lost+found | LC_ALL=C sort)" \
115 # Test -x when a direct link to a mount point is explicitly indexed.
116 # This should *not* include the mount.
117 WVPASS rm -r "$BUP_DIR" src-restore
119 WVPASS bup index -x src src/mnt-link
120 WVPASS bup save -n src src
121 WVPASS mkdir src-restore
122 WVPASS bup restore -C src-restore "/src/latest$(pwd)/"
123 WVPASS test -d src-restore/src
124 WVPASSEQ "$(cd src-restore/src && find . -not -name lost+found | LC_ALL=C sort)" \
132 # Test -x when a path that resolves to a mount point is explicitly
133 # indexed (i.e. dir symlnks that redirect the leaf to a mount point).
134 # This should include the mount.
135 WVPASS rm -r "$BUP_DIR" src-restore
137 WVPASS bup index -x src src/top/top/mnt-2
138 WVPASS bup save -n src src
139 WVPASS mkdir src-restore
140 WVPASS bup restore -C src-restore "/src/latest$(pwd)/"
141 WVPASS test -d src-restore/src
142 WVPASSEQ "$(cd src-restore/src && find . -not -name lost+found | LC_ALL=C sort)" \
152 WVPASS umount "$tmpdir/src/mnt-1"
153 WVPASS umount "$tmpdir/src/mnt-2"
154 WVPASS rm -r "$tmpdir"