]> arthur.barton.de Git - bup.git/blob - t/test-xdev.sh
test-restore-map-owner: accommodate python 3 and test there
[bup.git] / t / test-xdev.sh
1 #!/usr/bin/env bash
2 . ./wvtest-bup.sh || exit $?
3
4 set -o pipefail
5
6 root_status="$(t/root-status)" || exit $?
7
8 if [ "$root_status" != root ]; then
9     WVSTART 'not root: skipping tests'
10     exit 0 # FIXME: add WVSKIP.
11 fi
12
13 if ! modprobe loop; then
14     WVSTART 'unable to load loopback module; skipping tests' 1>&2
15     exit 0
16 fi
17
18 # These tests are only likely to work under Linux for now
19 # (patches welcome).
20 if ! [[ $(uname) =~ Linux ]]; then
21     WVSTART 'not Linux: skipping tests'
22     exit 0 # FIXME: add WVSKIP.
23 fi
24
25 top="$(WVPASS pwd)" || exit $?
26 tmpdir="$(WVPASS wvmktempdir)" || exit $?
27
28 export BUP_DIR="$tmpdir/bup"
29 export GIT_DIR="$tmpdir/bup"
30
31 bup() { "$top/bup" "$@"; }
32
33 WVPASS bup init
34 WVPASS pushd "$tmpdir"
35
36 WVSTART 'drecurse'
37
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
45
46 WVPASS touch src/1
47
48 WVPASS mkdir -p src/mnt-1/x
49 WVPASS touch src/mnt-1/2 src/mnt-1/x/3
50
51 WVPASS touch src/mnt-2/4
52
53 (WVPASS cd src && WVPASS ln -s mnt-2 mnt-link)
54 (WVPASS cd src && WVPASS ln -s . top)
55
56 WVPASSEQ "$(bup drecurse src | grep -vF lost+found)" "src/top
57 src/mnt-link
58 src/mnt-2/4
59 src/mnt-2/
60 src/mnt-1/x/3
61 src/mnt-1/x/
62 src/mnt-1/2
63 src/mnt-1/
64 src/1
65 src/"
66
67 WVPASSEQ "$(bup drecurse -x src)" "src/top
68 src/mnt-link
69 src/mnt-2/
70 src/mnt-1/
71 src/1
72 src/"
73
74 WVSTART 'index/save/restore'
75
76 WVPASS bup index src
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/t/compare-trees" -c src/ src-restore/src/
82
83 # Test -x when none of the mount points are explicitly indexed
84 WVPASS rm -r "$BUP_DIR" src-restore
85 WVPASS bup init
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)" \
92 ".
93 ./1
94 ./mnt-1
95 ./mnt-2
96 ./mnt-link
97 ./top"
98
99 # Test -x when a mount point is explicitly indexed.  This should
100 # include the mount.
101 WVPASS rm -r "$BUP_DIR" src-restore
102 WVPASS bup init
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)" \
109 ".
110 ./1
111 ./mnt-1
112 ./mnt-2
113 ./mnt-2/4
114 ./mnt-link
115 ./top"
116
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
120 WVPASS bup init
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)" \
127 ".
128 ./1
129 ./mnt-1
130 ./mnt-2
131 ./mnt-link
132 ./top"
133
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
138 WVPASS bup init
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)" \
145 ".
146 ./1
147 ./mnt-1
148 ./mnt-2
149 ./mnt-2/4
150 ./mnt-link
151 ./top"
152
153 WVPASS cd "$top"
154 WVPASS umount "$tmpdir/src/mnt-1"
155 WVPASS umount "$tmpdir/src/mnt-2"
156 WVPASS rm -r "$tmpdir"