6 export BUP_DIR="$TOP/buptest.tmp"
17 test -e "$@" || continue
18 chattr -fR = "$@" || true
27 test -d "$BUP_DIR" && rm -r "$BUP_DIR"
34 WVFAIL bup index --exclude-from $D/cannot-exist $D
35 WVPASSEQ "$(bup index --check -p)" ""
36 WVPASSEQ "$(bup index --check -p $D)" ""
38 WVFAIL bup index --check -u $D.fake
39 WVPASS bup index --check -u $D
40 WVPASSEQ "$(bup index --check -p $D)" "$D/"
42 WVPASS bup random 128k >$D/b
44 WVPASS bup random 512 >$D/f
45 WVPASS ln -s non-existent-file $D/g
46 WVPASSEQ "$(bup index -s $D/)" "A $D/"
47 WVPASSEQ "$(bup index -s $D/b)" ""
48 WVPASSEQ "$(bup index --check -us $D/b)" "A $D/b"
49 WVPASSEQ "$(bup index --check -us $D/b $D/d)" \
55 WVPASSEQ "$(bup index --check -usx $D)" \
64 WVPASSEQ "$(bup index --check -us $D/a $D/b --fake-valid)" \
67 WVPASSEQ "$(bup index --check -us $D/a)" " $D/a" # stays unmodified
68 WVPASSEQ "$(bup index --check -us $D/d --fake-valid)" \
73 WVPASS bup index -u $D/d/z # becomes modified
74 WVPASSEQ "$(bup index -s $D/a $D $D/b)" \
84 WVPASS bup index -u $D/d/e $D/a --fake-invalid
85 WVPASSEQ "$(cd $D && bup index -m .)" \
93 WVPASSEQ "$(cd $D && bup index -m)" \
101 WVPASSEQ "$(cd $D && bup index -s .)" "$(cd $D && bup index -s .)"
103 WVFAIL bup save -t $D/doesnt-exist-filename
105 mv $BUP_DIR/bupindex $BUP_DIR/bi.old
106 WVFAIL bup save -t $D/d/e/fifotest
107 mkfifo $D/d/e/fifotest
108 WVPASS bup index -u $D/d/e/fifotest
109 WVPASS bup save -t $D/d/e/fifotest
110 WVPASS bup save -t $D/d/e
111 rm -f $D/d/e/fifotest
112 WVPASS bup index -u $D/d/e
113 WVFAIL bup save -t $D/d/e/fifotest
114 mv $BUP_DIR/bi.old $BUP_DIR/bupindex
116 WVPASS bup index -u $D/d/e
117 WVPASS bup save -t $D/d/e
118 WVPASSEQ "$(cd $D && bup index -m)" \
125 WVPASS bup save -t $D/d
126 WVPASS bup index --fake-invalid $D/d/z
127 WVPASS bup save -t $D/d/z
128 WVPASS bup save -t $D/d/z # test regenerating trees when no files are changed
129 WVPASS bup save -t $D/d
130 WVPASSEQ "$(cd $D && bup index -m)" \
135 tree1=$(bup save -t $D) || WVFAIL
136 WVPASSEQ "$(cd $D && bup index -m)" ""
137 tree2=$(bup save -t $D) || WVFAIL
138 WVPASSEQ "$tree1" "$tree2"
139 WVPASSEQ "$(bup index -s / | grep ^D)" ""
140 tree3=$(bup save -t /) || WVFAIL
141 WVPASSEQ "$tree1" "$tree3"
142 WVPASS bup save -r :$BUP_DIR -n r-test $D
143 WVFAIL bup save -r :$BUP_DIR/fake/path -n r-test $D
144 WVFAIL bup save -r :$BUP_DIR -n r-test $D/fake/path
149 WVPASS bup split -b a.tmp >taga.tmp
150 WVPASS bup split -b b.tmp >tagb.tmp
151 cat a.tmp b.tmp | WVPASS bup split -b >tagab.tmp
152 WVPASSEQ $(cat taga.tmp | wc -l) 1
153 WVPASSEQ $(cat tagb.tmp | wc -l) 1
154 WVPASSEQ $(cat tagab.tmp | wc -l) 1
155 WVPASSEQ $(cat tag[ab].tmp | wc -l) 2
156 WVPASSEQ "$(bup split -b a.tmp b.tmp)" "$(cat tagab.tmp)"
157 WVPASSEQ "$(bup split -b --keep-boundaries a.tmp b.tmp)" "$(cat tag[ab].tmp)"
158 WVPASSEQ "$(cat tag[ab].tmp | bup split -b --keep-boundaries --git-ids)" \
160 WVPASSEQ "$(cat tag[ab].tmp | bup split -b --git-ids)" \
162 WVPASS bup split --bench -b <t/testfile1 >tags1.tmp
163 WVPASS bup split -vvvv -b t/testfile2 >tags2.tmp
166 WVPASS bup midx --check -a
167 WVPASS bup midx -o $BUP_DIR/objects/pack/test1.midx \
168 $BUP_DIR/objects/pack/*.idx
169 WVPASS bup midx --check -a
170 WVPASS bup midx -o $BUP_DIR/objects/pack/test1.midx \
171 $BUP_DIR/objects/pack/*.idx \
172 $BUP_DIR/objects/pack/*.idx
173 WVPASS bup midx --check -a
174 all=$(echo $BUP_DIR/objects/pack/*.idx $BUP_DIR/objects/pack/*.midx)
175 WVPASS bup midx -o $BUP_DIR/objects/pack/zzz.midx $all
177 WVPASS bup midx -o $BUP_DIR/objects/pack/yyy.midx $all
179 WVPASSEQ "$(echo $BUP_DIR/objects/pack/*.midx)" \
180 "$BUP_DIR/objects/pack/yyy.midx"
182 WVPASS bup split -t t/testfile2 >tags2t.tmp
183 WVPASS bup split -t t/testfile2 --fanout 3 >tags2tf.tmp
184 WVPASS bup split -r "$BUP_DIR" -c t/testfile2 >tags2c.tmp
185 WVPASS bup split -r :$BUP_DIR -c t/testfile2 >tags2c.tmp
187 | WVPASS bup split -r :$BUP_DIR -c --fanout 3 --max-pack-objects 3 -n lslr
189 WVFAIL bup ls /does-not-exist
191 WVPASS bup ls /lslr/latest
192 WVPASS bup ls /lslr/latest/
193 #WVPASS bup ls /lslr/1971-01-01 # all dates always exist
194 WVFAIL diff -u tags1.tmp tags2.tmp
196 # fanout must be different from non-fanout
197 WVFAIL diff tags2t.tmp tags2tf.tmp
198 wc -c t/testfile1 t/testfile2
199 wc -l tags1.tmp tags2.tmp
202 WVPASS bup bloom -c $(ls -1 $BUP_DIR/objects/pack/*.idx|head -n1)
203 rm $BUP_DIR/objects/pack/bup.bloom
204 WVPASS bup bloom -k 4
205 WVPASS bup bloom -c $(ls -1 $BUP_DIR/objects/pack/*.idx|head -n1)
206 WVPASS bup bloom -d buptest.tmp/objects/pack --ruin --force
207 WVFAIL bup bloom -c $(ls -1 $BUP_DIR/objects/pack/*.idx|head -n1)
208 WVPASS bup bloom --force -k 5
209 WVPASS bup bloom -c $(ls -1 $BUP_DIR/objects/pack/*.idx|head -n1)
212 WVPASS bup memtest -c1 -n100
213 WVPASS bup memtest -c1 -n100 --existing
216 WVPASS bup join $(cat tags1.tmp) >out1.tmp
217 WVPASS bup join <tags2.tmp >out2.tmp
218 WVPASS bup join <tags2t.tmp -o out2t.tmp
219 WVPASS bup join -r "$BUP_DIR" <tags2c.tmp >out2c.tmp
220 WVPASS bup join -r ":$BUP_DIR" <tags2c.tmp >out2c.tmp
221 WVPASS diff -u t/testfile1 out1.tmp
222 WVPASS diff -u t/testfile2 out2.tmp
223 WVPASS diff -u t/testfile2 out2t.tmp
224 WVPASS diff -u t/testfile2 out2c.tmp
226 WVSTART "save/git-fsck"
229 cd "$BUP_DIR" || exit 1
232 (cd "$TOP/t/sampledata" && WVPASS bup save -vvn master /) || WVFAIL
233 n=$(git fsck --full --strict 2>&1 |
234 egrep -v 'dangling (commit|tree|blob)' |
237 WVPASS [ "$n" -eq 0 ]
241 force-delete buprestore.tmp
242 WVFAIL bup restore boink
246 WVPASS bup restore -C buprestore.tmp "/master/latest/$TOP/$D"
247 WVPASSEQ "$(ls buprestore.tmp)" "bupdata.tmp"
248 force-delete buprestore.tmp
249 WVPASS bup restore -C buprestore.tmp "/master/latest/$TOP/$D/"
250 touch $D/non-existent-file buprestore.tmp/non-existent-file # else diff fails
251 WVPASS diff -ur $D/ buprestore.tmp/
257 export BUP_DIR="$(pwd)/$tmp/bup"
259 mkdir -p $tmp/src/x/y/z
260 WVPASS bup random 8k > $tmp/src/x/y/random-1
261 WVPASS bup random 8k > $tmp/src/x/y/z/random-2
262 WVPASS bup index -u $tmp/src
263 WVPASS bup save --strip -n foo $tmp/src
265 WVSTART "restore /foo/latest"
266 WVPASS bup restore -C $tmp/restore /foo/latest
267 WVPASS t/compare-trees $tmp/src/ $tmp/restore/latest/
269 WVSTART "restore /foo/latest/"
270 force-delete "$tmp/restore"
271 WVPASS bup restore -C $tmp/restore /foo/latest/
272 for x in $tmp/src/*; do
273 WVPASS t/compare-trees $x/ $tmp/restore/$(basename $x);
276 WVSTART "restore /foo/latest/."
277 force-delete "$tmp/restore"
278 WVPASS bup restore -C $tmp/restore /foo/latest/.
279 WVPASS t/compare-trees $tmp/src/ $tmp/restore/
281 WVSTART "restore /foo/latest/x"
282 force-delete "$tmp/restore"
283 WVPASS bup restore -C $tmp/restore /foo/latest/x
284 WVPASS t/compare-trees $tmp/src/x/ $tmp/restore/x/
286 WVSTART "restore /foo/latest/x/"
287 force-delete "$tmp/restore"
288 WVPASS bup restore -C $tmp/restore /foo/latest/x/
289 for x in $tmp/src/x/*; do
290 WVPASS t/compare-trees $x/ $tmp/restore/$(basename $x);
293 WVSTART "restore /foo/latest/x/."
294 force-delete "$tmp/restore"
295 WVPASS bup restore -C $tmp/restore /foo/latest/x/.
296 WVPASS t/compare-trees $tmp/src/x/ $tmp/restore/
301 WVPASS bup ftp "cat /master/latest/$TOP/$D/b" >$D/b.new
302 WVPASS bup ftp "cat /master/latest/$TOP/$D/f" >$D/f.new
303 WVPASS bup ftp "cat /master/latest/$TOP/$D/f"{,} >$D/f2.new
304 WVPASS bup ftp "cat /master/latest/$TOP/$D/a" >$D/a.new
305 WVPASSEQ "$(sha1sum <$D/b)" "$(sha1sum <$D/b.new)"
306 WVPASSEQ "$(sha1sum <$D/f)" "$(sha1sum <$D/f.new)"
307 WVPASSEQ "$(cat $D/f.new{,} | sha1sum)" "$(sha1sum <$D/f2.new)"
308 WVPASSEQ "$(sha1sum <$D/a)" "$(sha1sum <$D/a.new)"
311 WVFAIL bup tag -d v0.n 2>/dev/null
312 WVFAIL bup tag v0.n non-existant 2>/dev/null
313 WVPASSEQ "$(bup tag)" ""
314 WVPASS bup tag v0.1 master
315 WVPASSEQ "$(bup tag)" "v0.1"
316 WVPASS bup tag -d v0.1
318 # This section destroys data in the bup repository, so it is done last.
321 WVPASS bup fsck --quick
322 if bup fsck --par2-ok; then
323 WVSTART "fsck (par2)"
325 WVSTART "fsck (PAR2 IS MISSING)"
329 WVPASS bup damage $BUP_DIR/objects/pack/*.pack -n10 -s1 -S0
330 WVFAIL bup fsck --quick
331 WVFAIL bup fsck --quick --disable-par2
332 chmod u+w $BUP_DIR/objects/pack/*.idx
333 WVPASS bup damage $BUP_DIR/objects/pack/*.idx -n10 -s1 -S0
334 WVFAIL bup fsck --quick -j4
335 WVPASS bup damage $BUP_DIR/objects/pack/*.pack -n10 -s1024 --percent 0.4 -S0
336 WVFAIL bup fsck --quick
337 WVFAIL bup fsck --quick -rvv -j99 # fails because repairs were needed
338 if bup fsck --par2-ok; then
339 WVPASS bup fsck -r # ok because of repairs from last time
340 WVPASS bup damage $BUP_DIR/objects/pack/*.pack -n202 -s1 --equal -S0
342 WVFAIL bup fsck -rvv # too many errors to be repairable
343 WVFAIL bup fsck -r # too many errors to be repairable
345 WVFAIL bup fsck --quick -r # still fails because par2 was missing
348 WVSTART "exclude-bupdir"
352 export BUP_DIR="$D/.bup"
355 WVPASS bup random 128k >$D/b
357 WVPASS bup random 512 >$D/f
358 WVPASS bup index -ux $D
359 bup save -n exclude-bupdir $D
360 WVPASSEQ "$(bup ls -a exclude-bupdir/latest/$TOP/$D/)" "a
369 export BUP_DIR="$D/.bup"
372 WVPASS bup random 128k >$D/b
374 WVPASS bup random 512 >$D/f
375 WVPASS bup index -ux --exclude $D/d $D
376 bup save -n exclude $D
377 WVPASSEQ "$(bup ls exclude/latest/$TOP/$D/)" "a
381 WVPASS bup index -ux --exclude $D/d --exclude $TOP/$D/g --exclude $D/h $D
382 bup save -n exclude $D
383 WVPASSEQ "$(bup ls exclude/latest/$TOP/$D/)" "a
387 WVSTART "exclude-from"
388 D=exclude-fromdir.tmp
389 EXCLUDE_FILE=exclude-from.tmp
392 $D/h" > $EXCLUDE_FILE
395 export BUP_DIR="$D/.bup"
398 WVPASS bup random 128k >$D/b
400 WVPASS bup random 512 >$D/f
402 WVPASS bup index -ux --exclude-from $EXCLUDE_FILE $D
403 bup save -n exclude-from $D
404 WVPASSEQ "$(bup ls exclude-from/latest/$TOP/$D/)" "a
410 WVSTART "save --strip"
415 export BUP_DIR="$(pwd)/$tmp/bup"
417 mkdir -p $tmp/src/x/y/z
418 WVPASS bup random 8k > $tmp/src/x/y/random-1
419 WVPASS bup random 8k > $tmp/src/x/y/z/random-2
420 WVPASS bup index -u $tmp/src
421 WVPASS bup save --strip -n foo $tmp/src/x/y
422 WVPASS bup restore -C $tmp/restore /foo/latest
423 WVPASS t/compare-trees $tmp/src/x/y/ "$tmp/restore/latest/"
426 WVSTART "save --strip-path (relative)"
431 export BUP_DIR="$(pwd)/$tmp/bup"
433 mkdir -p $tmp/src/x/y/z
434 WVPASS bup random 8k > $tmp/src/x/y/random-1
435 WVPASS bup random 8k > $tmp/src/x/y/z/random-2
436 WVPASS bup index -u $tmp/src
437 WVPASS bup save --strip-path $tmp/src -n foo $tmp/src/x
438 WVPASS bup restore -C $tmp/restore /foo/latest
439 WVPASS t/compare-trees $tmp/src/ "$tmp/restore/latest/"
442 WVSTART "save --strip-path (absolute)"
447 export BUP_DIR="$(pwd)/$tmp/bup"
449 mkdir -p $tmp/src/x/y/z
450 WVPASS bup random 8k > $tmp/src/x/y/random-1
451 WVPASS bup random 8k > $tmp/src/x/y/z/random-2
452 WVPASS bup index -u $tmp/src
453 WVPASS bup save --strip-path "$TOP" -n foo $tmp/src
454 WVPASS bup restore -C $tmp/restore /foo/latest
455 WVPASS t/compare-trees $tmp/src/ "$tmp/restore/latest/$tmp/src/"
458 WVSTART "save --strip-path (no match)"
463 export BUP_DIR="$(pwd)/$tmp/bup"
465 mkdir -p $tmp/src/x/y/z
466 WVPASS bup random 8k > $tmp/src/x/y/random-1
467 WVPASS bup random 8k > $tmp/src/x/y/z/random-2
468 WVPASS bup index -u $tmp/src
469 WVPASS bup save --strip-path $tmp/foo -n foo $tmp/src/x
470 WVPASS bup restore -C $tmp/restore /foo/latest
471 WVPASS t/compare-trees $tmp/src/ "$tmp/restore/latest/$TOP/$tmp/src/"
474 WVSTART "save --graft (empty graft points disallowed)"
479 export BUP_DIR="$(pwd)/$tmp/bup"
481 WVFAIL bup save --graft =/grafted -n graft-point-absolute $tmp
482 WVFAIL bup save --graft $TOP/$tmp= -n graft-point-absolute $tmp
485 WVSTART "save --graft /x/y=/a/b (relative paths)"
490 export BUP_DIR="$(pwd)/$tmp/bup"
492 mkdir -p $tmp/src/x/y/z
493 WVPASS bup random 8k > $tmp/src/x/y/random-1
494 WVPASS bup random 8k > $tmp/src/x/y/z/random-2
495 WVPASS bup index -u $tmp/src
496 WVPASS bup save --graft $tmp/src=x -n foo $tmp/src
497 WVPASS bup restore -C $tmp/restore /foo/latest
498 WVPASS t/compare-trees $tmp/src/ "$tmp/restore/latest/$TOP/x/"
501 WVSTART "save --graft /x/y=/a/b (matching structure)"
506 export BUP_DIR="$(pwd)/$tmp/bup"
508 mkdir -p $tmp/src/x/y/z
509 WVPASS bup random 8k > $tmp/src/x/y/random-1
510 WVPASS bup random 8k > $tmp/src/x/y/z/random-2
511 WVPASS bup index -u $tmp/src
512 WVPASS bup save -v --graft "$TOP/$tmp/src/x/y=$TOP/$tmp/src/a/b" \
514 WVPASS bup restore -C $tmp/restore /foo/latest
515 WVPASS t/compare-trees $tmp/src/x/y/ \
516 "$tmp/restore/latest/$TOP/$tmp/src/a/b/"
519 WVSTART "save --graft /x/y=/a (shorter target)"
524 export BUP_DIR="$(pwd)/$tmp/bup"
526 mkdir -p $tmp/src/x/y/z
527 WVPASS bup random 8k > $tmp/src/x/y/random-1
528 WVPASS bup random 8k > $tmp/src/x/y/z/random-2
529 WVPASS bup index -u $tmp/src
530 WVPASS bup save -v --graft "$TOP/$tmp/src/x/y=/a" -n foo $tmp/src/x/y
531 WVPASS bup restore -C $tmp/restore /foo/latest
532 WVPASS t/compare-trees $tmp/src/x/y/ "$tmp/restore/latest/a/"
535 WVSTART "save --graft /x=/a/b (longer target)"
538 export BUP_DIR="$(pwd)/$tmp/bup"
542 mkdir -p $tmp/src/x/y/z
543 WVPASS bup random 8k > $tmp/src/x/y/random-1
544 WVPASS bup random 8k > $tmp/src/x/y/z/random-2
545 WVPASS bup index -u $tmp/src
546 WVPASS bup save -v --graft "$TOP/$tmp/src=$TOP/$tmp/src/a/b/c" \
548 WVPASS bup restore -C $tmp/restore /foo/latest
549 WVPASS t/compare-trees $tmp/src/ "$tmp/restore/latest/$TOP/$tmp/src/a/b/c/"
552 WVSTART "save --graft /x=/ (root target)"
555 export BUP_DIR="$(pwd)/$tmp/bup"
559 mkdir -p $tmp/src/x/y/z
560 WVPASS bup random 8k > $tmp/src/x/y/random-1
561 WVPASS bup random 8k > $tmp/src/x/y/z/random-2
562 WVPASS bup index -u $tmp/src
563 WVPASS bup save -v --graft "$TOP/$tmp/src/x=/" -n foo $tmp/src/x
564 WVPASS bup restore -C $tmp/restore /foo/latest
565 WVPASS t/compare-trees $tmp/src/x/ "$tmp/restore/latest/"
568 #WVSTART "save --graft /=/x/ (root source)"
569 # FIXME: Not tested for now -- will require cleverness, or caution as root.
573 INDEXFILE=tmpindexfile.tmp
577 export BUP_DIR="$D/.bup"
582 WVPASS bup index -ux $D
583 bup save --strip -n bupdir $D
584 WVPASSEQ "$(bup ls bupdir/latest/)" "a
587 WVPASS bup index -f $INDEXFILE --exclude=$D/c -ux $D
588 bup save --strip -n indexfile -f $INDEXFILE $D
589 WVPASSEQ "$(bup ls indexfile/latest/)" "a
593 WVSTART "import-rsnapshot"
595 export BUP_DIR="$TOP/$D/.bup"
599 mkdir -p $D/hourly.0/buptest/a
600 touch $D/hourly.0/buptest/a/b
601 mkdir -p $D/hourly.0/buptest/c/d
602 touch $D/hourly.0/buptest/c/d/e
604 WVPASS bup import-rsnapshot $D/
605 WVPASSEQ "$(bup ls buptest/latest/)" "a/
609 if [ "$(which rdiff-backup)" != "" ]; then
610 WVSTART "import-rdiff-backup"
612 export BUP_DIR="$TOP/$D/.bup"
616 mkdir $D/rdiff-backup
617 rdiff-backup $TOP/cmd $D/rdiff-backup
619 rdiff-backup $TOP/Documentation $D/rdiff-backup
620 WVPASS bup import-rdiff-backup $D/rdiff-backup import-rdiff-backup
621 WVPASSEQ "$(bup ls import-rdiff-backup/ | wc -l)" "3"
622 WVPASSEQ "$(bup ls import-rdiff-backup/latest/ | sort)" "$(ls $TOP/Documentation | sort)"
626 WVSTART "compression"
628 export BUP_DIR="$TOP/$D/.bup"
632 WVPASS bup index $TOP/Documentation
633 WVPASS bup save -n compression -0 --strip $TOP/Documentation
634 # 'ls' on NetBSD sets -A by default when running as root, so we have to undo
635 # it by grepping out any dotfiles. (Normal OSes don't auto-set -A, but this
636 # is harmless there.)
637 WVPASSEQ "$(bup ls compression/latest/ | sort)" \
638 "$(ls $TOP/Documentation | grep -v '^\.' | sort)"
639 COMPRESSION_0_SIZE=$(du -k -s $D | cut -f1)
642 export BUP_DIR="$TOP/$D/.bup"
646 WVPASS bup index $TOP/Documentation
647 WVPASS bup save -n compression -9 --strip $TOP/Documentation
648 WVPASSEQ "$(bup ls compression/latest/ | sort)" "$(ls $TOP/Documentation | sort)"
649 COMPRESSION_9_SIZE=$(du -k -s $D | cut -f1)
651 WVPASS [ "$COMPRESSION_9_SIZE" -lt "$COMPRESSION_0_SIZE" ]
654 WVSTART "save disjoint top-level directories"
657 top_dir="$(echo $(pwd) | awk -F "/" '{print $2}')"
658 if [ "$top_dir" == tmp ]; then
659 echo "(running from within /tmp; skipping test)"
666 tmpdir="$(mktemp -d /tmp/bup-test-XXXXXXX)"
667 cleanup() { set -x; rm -r "${tmpdir}"; set +x; }
671 export BUP_DIR="$TOP/buptest.tmp"
672 test -d "$BUP_DIR" && rm -r "$BUP_DIR"
675 WVPASS bup index -vu $(pwd)/$D/x "$tmpdir"
676 WVPASS bup save -t -n src $(pwd)/$D/x "$tmpdir"
677 # For now, assume that "ls -a" and "sort" use the same order.
678 WVPASSEQ "$(bup ls -a src/latest)" "$(echo -e "$top_dir/\ntmp/" | sort)"
682 WVSTART "clear-index"
684 export BUP_DIR="$TOP/$D/.bup"
691 WVPASSEQ "$(bup index -p)" "$D/foo
696 WVPASS bup index --clear
698 WVPASSEQ "$(bup index -p)" "$D/bar