8 top="$(WVPASS /bin/pwd)" || exit $?
9 tmpdir="$(WVPASS wvmktempdir)" || exit $?
10 export BUP_DIR="$tmpdir/bup"
12 bup() { "$top/bup" "$@"; }
22 WVPASS force-delete $D
24 WVFAIL bup index --exclude-from $D/cannot-exist $D
25 WVPASSEQ "$(bup index --check -p)" ""
26 WVPASSEQ "$(bup index --check -p $D)" ""
28 WVFAIL bup index --check -u $D.fake
29 WVPASS bup index --check -u $D
30 WVPASSEQ "$(bup index --check -p $D)" "$D/"
32 WVPASS bup random 128k >$D/b
33 WVPASS mkdir $D/d $D/d/e
34 WVPASS bup random 512 >$D/f
35 WVPASS ln -s non-existent-file $D/g
36 WVPASSEQ "$(bup index -s $D/)" "A $D/"
37 WVPASSEQ "$(bup index -s $D/b)" ""
38 WVPASSEQ "$(bup index --check -us $D/b)" "A $D/b"
39 WVPASSEQ "$(bup index --check -us $D/b $D/d)" \
45 WVPASSEQ "$(bup index --check -usx $D)" \
54 WVPASSEQ "$(bup index --check -us $D/a $D/b --fake-valid)" \
57 WVPASSEQ "$(bup index --check -us $D/a)" " $D/a" # stays unmodified
58 WVPASSEQ "$(bup index --check -us $D/d --fake-valid)" \
63 WVPASS bup index -u $D/d/z # becomes modified
64 WVPASSEQ "$(bup index -s $D/a $D $D/b)" \
74 WVPASS bup index -u $D/d/e $D/a --fake-invalid
75 WVPASSEQ "$(cd $D && bup index -m .)" \
83 WVPASSEQ "$(cd $D && bup index -m)" \
91 WVPASSEQ "$(cd $D && bup index -s .)" "$(cd $D && bup index -s .)"
93 WVFAIL bup save -t $D/doesnt-exist-filename
95 WVPASS mv "$BUP_DIR/bupindex" "$BUP_DIR/bi.old"
96 WVFAIL bup save -t $D/d/e/fifotest
97 WVPASS mkfifo $D/d/e/fifotest
98 WVPASS bup index -u $D/d/e/fifotest
99 WVPASS bup save -t $D/d/e/fifotest
100 WVPASS bup save -t $D/d/e
101 WVPASS rm -f $D/d/e/fifotest
102 WVPASS bup index -u $D/d/e
103 WVFAIL bup save -t $D/d/e/fifotest
104 WVPASS mv "$BUP_DIR/bi.old" "$BUP_DIR/bupindex"
106 WVPASS bup index -u $D/d/e
107 WVPASS bup save -t $D/d/e
108 WVPASSEQ "$(cd $D && bup index -m)" \
115 WVPASS bup save -t $D/d
116 WVPASS bup index --fake-invalid $D/d/z
117 WVPASS bup save -t $D/d/z
118 WVPASS bup save -t $D/d/z # test regenerating trees when no files are changed
119 WVPASS bup save -t $D/d
120 WVPASSEQ "$(cd $D && bup index -m)" \
125 WVPASS bup save -r ":$BUP_DIR" -n r-test $D
126 WVFAIL bup save -r ":$BUP_DIR/fake/path" -n r-test $D
127 WVFAIL bup save -r ":$BUP_DIR" -n r-test $D/fake/path
132 WVPASS bup split -b a.tmp >taga.tmp
133 WVPASS bup split -b b.tmp >tagb.tmp
134 WVPASS cat a.tmp b.tmp | WVPASS bup split -b >tagab.tmp
135 WVPASSEQ $(cat taga.tmp | wc -l) 1
136 WVPASSEQ $(cat tagb.tmp | wc -l) 1
137 WVPASSEQ $(cat tagab.tmp | wc -l) 1
138 WVPASSEQ $(cat tag[ab].tmp | wc -l) 2
139 WVPASSEQ "$(bup split -b a.tmp b.tmp)" "$(cat tagab.tmp)"
140 WVPASSEQ "$(bup split -b --keep-boundaries a.tmp b.tmp)" "$(cat tag[ab].tmp)"
141 WVPASSEQ "$(cat tag[ab].tmp | bup split -b --keep-boundaries --git-ids)" \
143 WVPASSEQ "$(cat tag[ab].tmp | bup split -b --git-ids)" \
145 WVPASS bup split --bench -b <"$top/t/testfile1" >tags1.tmp
146 WVPASS bup split -vvvv -b "$top/t/testfile2" >tags2.tmp
149 WVPASS bup midx --check -a
150 WVPASS bup midx -o "$BUP_DIR/objects/pack/test1.midx" \
151 "$BUP_DIR"/objects/pack/*.idx
152 WVPASS bup midx --check -a
153 WVPASS bup midx -o "$BUP_DIR"/objects/pack/test1.midx \
154 "$BUP_DIR"/objects/pack/*.idx \
155 "$BUP_DIR"/objects/pack/*.idx
156 WVPASS bup midx --check -a
157 all=$(echo "$BUP_DIR"/objects/pack/*.idx "$BUP_DIR"/objects/pack/*.midx)
158 WVPASS bup midx -o "$BUP_DIR"/objects/pack/zzz.midx $all
160 WVPASS bup midx -o "$BUP_DIR"/objects/pack/yyy.midx $all
162 WVPASSEQ "$(echo "$BUP_DIR"/objects/pack/*.midx)" \
163 ""$BUP_DIR"/objects/pack/yyy.midx"
165 WVPASS bup split -t "$top/t/testfile2" >tags2t.tmp
166 WVPASS bup split -t "$top/t/testfile2" --fanout 3 >tags2tf.tmp
167 WVPASS bup split -r "$BUP_DIR" -c "$top/t/testfile2" >tags2c.tmp
168 WVPASS bup split -r ":$BUP_DIR" -c "$top/t/testfile2" >tags2c.tmp
170 | WVPASS bup split -r ":$BUP_DIR" -c --fanout 3 --max-pack-objects 3 -n lslr \
173 WVFAIL bup ls /does-not-exist
175 WVPASS bup ls /lslr/latest
176 WVPASS bup ls /lslr/latest/
177 #WVPASS bup ls /lslr/1971-01-01 # all dates always exist
178 WVFAIL diff -u tags1.tmp tags2.tmp
180 # fanout must be different from non-fanout
181 WVFAIL diff tags2t.tmp tags2tf.tmp
182 WVPASS wc -c "$top/t/testfile1" "$top/t/testfile2"
183 WVPASS wc -l tags1.tmp tags2.tmp
186 WVPASS bup bloom -c $(ls -1 "$BUP_DIR"/objects/pack/*.idx|head -n1)
187 WVPASS rm "$BUP_DIR"/objects/pack/bup.bloom
188 WVPASS bup bloom -k 4
189 WVPASS bup bloom -c $(ls -1 "$BUP_DIR"/objects/pack/*.idx|head -n1)
190 WVPASS bup bloom -d "$BUP_DIR"/objects/pack --ruin --force
191 WVFAIL bup bloom -c $(ls -1 "$BUP_DIR"/objects/pack/*.idx|head -n1)
192 WVPASS bup bloom --force -k 5
193 WVPASS bup bloom -c $(ls -1 "$BUP_DIR"/objects/pack/*.idx|head -n1)
196 WVPASS bup memtest -c1 -n100
197 WVPASS bup memtest -c1 -n100 --existing
200 WVPASS bup join $(cat tags1.tmp) >out1.tmp
201 WVPASS bup join <tags2.tmp >out2.tmp
202 WVPASS bup join <tags2t.tmp -o out2t.tmp
203 WVPASS bup join -r "$BUP_DIR" <tags2c.tmp >out2c.tmp
204 WVPASS bup join -r ":$BUP_DIR" <tags2c.tmp >out2c.tmp
205 WVPASS diff -u "$top/t/testfile1" out1.tmp
206 WVPASS diff -u "$top/t/testfile2" out2.tmp
207 WVPASS diff -u "$top/t/testfile2" out2t.tmp
208 WVPASS diff -u "$top/t/testfile2" out2c.tmp
210 WVSTART "save/git-fsck"
215 (WVPASS cd "$top/t/sampledata" && WVPASS bup save -vvn master /) || exit $?
216 result="$(git fsck --full --strict 2>&1)" || exit $?
218 WVFAIL egrep -v 'dangling (commit|tree|blob)' |
219 WVPASS tee -a /dev/stderr |
220 WVPASS wc -l) || exit $?
221 WVPASS [ "$n" -eq 0 ]
225 WVPASS force-delete buprestore.tmp
226 WVFAIL bup restore boink
227 WVPASS touch "$tmpdir/$D/$D"
228 WVPASS bup index -u "$tmpdir/$D"
229 WVPASS bup save -n master /
230 WVPASS bup restore -C buprestore.tmp "/master/latest/$tmpdir/$D"
231 WVPASSEQ "$(ls buprestore.tmp)" "bupdata.tmp"
232 WVPASS force-delete buprestore.tmp
233 WVPASS bup restore -C buprestore.tmp "/master/latest/$tmpdir/$D/"
234 WVPASS touch $D/non-existent-file buprestore.tmp/non-existent-file # else diff fails
235 WVPASS diff -ur $D/ buprestore.tmp/
239 WVPASS force-delete $tmp
241 export BUP_DIR="$(pwd)/$tmp/bup"
242 WVPASS WVPASS bup init
243 WVPASS mkdir -p $tmp/src/x/y/z
244 WVPASS bup random 8k > $tmp/src/x/y/random-1
245 WVPASS bup random 8k > $tmp/src/x/y/z/random-2
246 WVPASS bup index -u $tmp/src
247 WVPASS bup save --strip -n foo $tmp/src
249 WVSTART "restore /foo/latest"
250 WVPASS bup restore -C $tmp/restore /foo/latest
251 WVPASS "$top/t/compare-trees" $tmp/src/ $tmp/restore/latest/
253 WVSTART "restore /foo/latest/"
254 WVPASS force-delete "$tmp/restore"
255 WVPASS bup restore -C $tmp/restore /foo/latest/
256 for x in $tmp/src/*; do
257 WVPASS "$top/t/compare-trees" $x/ $tmp/restore/$(basename $x);
260 WVSTART "restore /foo/latest/."
261 WVPASS force-delete "$tmp/restore"
262 WVPASS bup restore -C $tmp/restore /foo/latest/.
263 WVPASS "$top/t/compare-trees" $tmp/src/ $tmp/restore/
265 WVSTART "restore /foo/latest/x"
266 WVPASS force-delete "$tmp/restore"
267 WVPASS bup restore -C $tmp/restore /foo/latest/x
268 WVPASS "$top/t/compare-trees" $tmp/src/x/ $tmp/restore/x/
270 WVSTART "restore /foo/latest/x/"
271 WVPASS force-delete "$tmp/restore"
272 WVPASS bup restore -C $tmp/restore /foo/latest/x/
273 for x in $tmp/src/x/*; do
274 WVPASS "$top/t/compare-trees" $x/ $tmp/restore/$(basename $x);
277 WVSTART "restore /foo/latest/x/."
278 WVPASS force-delete "$tmp/restore"
279 WVPASS bup restore -C $tmp/restore /foo/latest/x/.
280 WVPASS "$top/t/compare-trees" $tmp/src/x/ $tmp/restore/
285 WVPASS bup ftp "cat /master/latest/$tmpdir/$D/b" >$D/b.new
286 WVPASS bup ftp "cat /master/latest/$tmpdir/$D/f" >$D/f.new
287 WVPASS bup ftp "cat /master/latest/$tmpdir/$D/f"{,} >$D/f2.new
288 WVPASS bup ftp "cat /master/latest/$tmpdir/$D/a" >$D/a.new
289 WVPASSEQ "$(sha1sum <$D/b)" "$(sha1sum <$D/b.new)"
290 WVPASSEQ "$(sha1sum <$D/f)" "$(sha1sum <$D/f.new)"
291 WVPASSEQ "$(cat $D/f.new{,} | sha1sum)" "$(sha1sum <$D/f2.new)"
292 WVPASSEQ "$(sha1sum <$D/a)" "$(sha1sum <$D/a.new)"
295 WVFAIL bup tag -d v0.n 2>/dev/null
296 WVFAIL bup tag v0.n non-existant 2>/dev/null
297 WVPASSEQ "$(bup tag)" ""
298 WVPASS bup tag v0.1 master
299 WVPASSEQ "$(bup tag)" "v0.1"
300 WVFAIL bup tag v0.1 master
301 WVPASS bup tag -f v0.1 master
302 WVPASS bup tag -d v0.1
303 WVPASS bup tag -f -d v0.1
304 WVFAIL bup tag -d v0.1
307 WVSTART "save (no index)"
309 tmp=save-no-index.tmp
310 WVPASS force-delete $tmp
312 export BUP_DIR="$(WVPASS pwd)/$tmp/bup" || exit $?
314 WVFAIL bup save -n nothing /
320 INDEXFILE=tmpindexfile.tmp
321 WVPASS rm -f $INDEXFILE
322 WVPASS force-delete $D
324 export BUP_DIR="$D/.bup"
329 WVPASS bup index -ux $D
330 WVPASS bup save --strip -n bupdir $D
331 WVPASSEQ "$(bup ls -F bupdir/latest/)" "a
334 WVPASS bup index -f $INDEXFILE --exclude=$D/c -ux $D
335 WVPASS bup save --strip -n indexfile -f $INDEXFILE $D
336 WVPASSEQ "$(bup ls indexfile/latest/)" "a
340 WVSTART "import-rsnapshot"
342 export BUP_DIR="$tmpdir/$D/.bup"
343 WVPASS force-delete $D
346 WVPASS mkdir -p $D/hourly.0/buptest/a
347 WVPASS touch $D/hourly.0/buptest/a/b
348 WVPASS mkdir -p $D/hourly.0/buptest/c/d
349 WVPASS touch $D/hourly.0/buptest/c/d/e
351 WVPASS bup import-rsnapshot $D/
352 WVPASSEQ "$(bup ls -F buptest/latest/)" "a/
356 WVSTART "save disjoint top-level directories"
358 # Resolve any symlinks involving the top top-level dirs.
359 real_pwd="$(WVPASS realpath .)" || exit $?
360 real_tmp="$(WVPASS realpath /tmp/.)" || exit $?
361 pwd_top="$(echo $real_pwd | WVPASS awk -F "/" '{print $2}')" || exit $?
362 tmp_top="$(echo $real_tmp | WVPASS awk -F "/" '{print $2}')" || exit $?
364 if [ "$pwd_top" = "$tmp_top" ]; then
365 echo "(running from within /$tmp_top; skipping test)" 1>&2
369 WVPASS force-delete $D
372 tmpdir2="$(WVPASS mktemp -d $real_tmp/bup-test-XXXXXXX)" || exit $?
373 cleanup() { WVPASS rm -r "$tmpdir2"; }
374 WVPASS trap cleanup EXIT
375 WVPASS date > "$tmpdir2/2"
377 export BUP_DIR="$tmpdir/bup"
378 WVPASS test -d "$BUP_DIR" && WVPASS rm -r "$BUP_DIR"
381 WVPASS bup index -vu $(pwd)/$D/x "$tmpdir2"
382 WVPASS bup save -t -n src $(pwd)/$D/x "$tmpdir2"
384 # For now, assume that "ls -a" and "sort" use the same order.
385 actual="$(WVPASS bup ls -AF src/latest)" || exit $?
386 expected="$(echo -e "$pwd_top/\n$tmp_top/" | WVPASS sort)" || exit $?
387 WVPASSEQ "$actual" "$expected"
390 WVPASS rm -rf "$tmpdir"