6 export BUP_DIR="$TOP/buptest.tmp"
23 WVPASSEQ "$(bup index --check -p)" ""
24 WVPASSEQ "$(bup index --check -p $D)" ""
26 WVFAIL bup index --check -u $D.fake
27 WVPASS bup index --check -u $D
28 WVPASSEQ "$(bup index --check -p $D)" "$D/"
30 WVPASS bup random 128k >$D/b
32 WVPASS bup random 512 >$D/f
33 WVPASS ln -s non-existent-file $D/g
34 WVPASSEQ "$(bup index -s $D/)" "A $D/"
35 WVPASSEQ "$(bup index -s $D/b)" ""
36 WVPASSEQ "$(bup index --check -us $D/b)" "A $D/b"
37 WVPASSEQ "$(bup index --check -us $D/b $D/d)" \
43 WVPASSEQ "$(bup index --check -usx $D)" \
52 WVPASSEQ "$(bup index --check -us $D/a $D/b --fake-valid)" \
55 WVPASSEQ "$(bup index --check -us $D/a)" " $D/a" # stays unmodified
56 WVPASSEQ "$(bup index --check -us $D/d --fake-valid)" \
61 WVPASS bup index -u $D/d/z # becomes modified
62 WVPASSEQ "$(bup index -s $D/a $D $D/b)" \
72 WVPASS bup index -u $D/d/e $D/a --fake-invalid
73 WVPASSEQ "$(cd $D && bup index -m .)" \
81 WVPASSEQ "$(cd $D && bup index -m)" \
89 WVPASSEQ "$(cd $D && bup index -s .)" "$(cd $D && bup index -s .)"
91 WVFAIL bup save -t $D/doesnt-exist-filename
93 mv $BUP_DIR/bupindex $BUP_DIR/bi.old
94 WVFAIL bup save -t $D/d/e/fifotest
95 mkfifo $D/d/e/fifotest
96 WVPASS bup index -u $D/d/e/fifotest
97 WVPASS bup save -t $D/d/e/fifotest
98 WVPASS bup save -t $D/d/e
100 WVPASS bup index -u $D/d/e
101 WVFAIL bup save -t $D/d/e/fifotest
102 mv $BUP_DIR/bi.old $BUP_DIR/bupindex
104 WVPASS bup index -u $D/d/e
105 WVPASS bup save -t $D/d/e
106 WVPASSEQ "$(cd $D && bup index -m)" \
113 WVPASS bup save -t $D/d
114 WVPASS bup index --fake-invalid $D/d/z
115 WVPASS bup save -t $D/d/z
116 WVPASS bup save -t $D/d/z # test regenerating trees when no files are changed
117 WVPASS bup save -t $D/d
118 WVPASSEQ "$(cd $D && bup index -m)" \
123 tree1=$(bup save -t $D) || WVFAIL
124 WVPASSEQ "$(cd $D && bup index -m)" ""
125 tree2=$(bup save -t $D) || WVFAIL
126 WVPASSEQ "$tree1" "$tree2"
127 WVPASSEQ "$(bup index -s / | grep ^D)" ""
128 tree3=$(bup save -t /) || WVFAIL
129 WVPASSEQ "$tree1" "$tree3"
130 WVPASS bup save -r :$BUP_DIR -n r-test $D
131 WVFAIL bup save -r :$BUP_DIR/fake/path -n r-test $D
132 WVFAIL bup save -r :$BUP_DIR -n r-test $D/fake/path
137 WVPASS bup split -b a.tmp >taga.tmp
138 WVPASS bup split -b b.tmp >tagb.tmp
139 cat a.tmp b.tmp | WVPASS bup split -b >tagab.tmp
140 WVPASSEQ $(cat taga.tmp | wc -l) 1
141 WVPASSEQ $(cat tagb.tmp | wc -l) 1
142 WVPASSEQ $(cat tagab.tmp | wc -l) 1
143 WVPASSEQ $(cat tag[ab].tmp | wc -l) 2
144 WVPASSEQ "$(bup split -b a.tmp b.tmp)" "$(cat tagab.tmp)"
145 WVPASSEQ "$(bup split -b --keep-boundaries a.tmp b.tmp)" "$(cat tag[ab].tmp)"
146 WVPASSEQ "$(cat tag[ab].tmp | bup split -b --keep-boundaries --git-ids)" \
148 WVPASSEQ "$(cat tag[ab].tmp | bup split -b --git-ids)" \
150 WVPASS bup split --bench -b <t/testfile1 >tags1.tmp
151 WVPASS bup split -vvvv -b t/testfile2 >tags2.tmp
154 WVPASS bup midx --check -a
155 WVPASS bup midx -o $BUP_DIR/objects/pack/test1.midx \
156 $BUP_DIR/objects/pack/*.idx
157 WVPASS bup midx --check -a
158 WVPASS bup midx -o $BUP_DIR/objects/pack/test1.midx \
159 $BUP_DIR/objects/pack/*.idx \
160 $BUP_DIR/objects/pack/*.idx
161 WVPASS bup midx --check -a
162 all=$(echo $BUP_DIR/objects/pack/*.idx $BUP_DIR/objects/pack/*.midx)
163 WVPASS bup midx -o $BUP_DIR/objects/pack/zzz.midx $all
165 WVPASS bup midx -o $BUP_DIR/objects/pack/yyy.midx $all
167 WVPASSEQ "$(echo $BUP_DIR/objects/pack/*.midx)" \
168 "$BUP_DIR/objects/pack/yyy.midx"
170 WVPASS bup split -t t/testfile2 >tags2t.tmp
171 WVPASS bup split -t t/testfile2 --fanout 3 >tags2tf.tmp
172 WVPASS bup split -r "$BUP_DIR" -c t/testfile2 >tags2c.tmp
173 WVPASS bup split -r :$BUP_DIR -c t/testfile2 >tags2c.tmp
175 | WVPASS bup split -r :$BUP_DIR -c --fanout 3 --max-pack-objects 3 -n lslr
177 WVFAIL bup ls /does-not-exist
179 WVPASS bup ls /lslr/latest
180 WVPASS bup ls /lslr/latest/
181 #WVPASS bup ls /lslr/1971-01-01 # all dates always exist
182 WVFAIL diff -u tags1.tmp tags2.tmp
184 # fanout must be different from non-fanout
185 WVFAIL diff tags2t.tmp tags2tf.tmp
186 wc -c t/testfile1 t/testfile2
187 wc -l tags1.tmp tags2.tmp
190 WVPASS bup bloom -c $(ls -1 $BUP_DIR/objects/pack/*.idx|head -n1)
191 rm $BUP_DIR/objects/pack/bup.bloom
192 WVPASS bup bloom -k 4
193 WVPASS bup bloom -c $(ls -1 $BUP_DIR/objects/pack/*.idx|head -n1)
194 WVPASS bup bloom -d buptest.tmp/objects/pack --ruin --force
195 WVFAIL bup bloom -c $(ls -1 $BUP_DIR/objects/pack/*.idx|head -n1)
196 WVPASS bup bloom --force -k 5
197 WVPASS bup bloom -c $(ls -1 $BUP_DIR/objects/pack/*.idx|head -n1)
200 WVPASS bup memtest -c1 -n100
201 WVPASS bup memtest -c1 -n100 --existing
204 WVPASS bup join $(cat tags1.tmp) >out1.tmp
205 WVPASS bup join <tags2.tmp >out2.tmp
206 WVPASS bup join <tags2t.tmp -o out2t.tmp
207 WVPASS bup join -r "$BUP_DIR" <tags2c.tmp >out2c.tmp
208 WVPASS bup join -r ":$BUP_DIR" <tags2c.tmp >out2c.tmp
209 WVPASS diff -u t/testfile1 out1.tmp
210 WVPASS diff -u t/testfile2 out2.tmp
211 WVPASS diff -u t/testfile2 out2t.tmp
212 WVPASS diff -u t/testfile2 out2c.tmp
214 WVSTART "save/git-fsck"
217 cd "$BUP_DIR" || exit 1
220 (cd "$TOP/t/sampledata" && WVPASS bup save -vvn master /) || WVFAIL
221 n=$(git fsck --full --strict 2>&1 |
222 egrep -v 'dangling (commit|tree|blob)' |
225 WVPASS [ "$n" -eq 0 ]
229 rm -rf buprestore.tmp
230 WVFAIL bup restore boink
234 WVPASS bup restore -C buprestore.tmp "/master/latest/$TOP/$D"
235 WVPASSEQ "$(ls buprestore.tmp)" "bupdata.tmp"
236 rm -rf buprestore.tmp
237 WVPASS bup restore -C buprestore.tmp "/master/latest/$TOP/$D/"
238 touch $D/non-existent-file buprestore.tmp/non-existent-file # else diff fails
239 WVPASS diff -ur $D/ buprestore.tmp/
245 export BUP_DIR="$(pwd)/$tmp/bup"
247 mkdir -p $tmp/src/x/y/z
248 WVPASS bup random 8k > $tmp/src/x/y/random-1
249 WVPASS bup random 8k > $tmp/src/x/y/z/random-2
250 WVPASS bup index -u $tmp/src
251 WVPASS bup save --strip -n foo $tmp/src
253 WVSTART "restore /foo/latest"
254 WVPASS bup restore -C $tmp/restore /foo/latest
255 WVPASS t/compare-trees $tmp/src/ $tmp/restore/latest/
257 WVSTART "restore /foo/latest/"
258 rm -rf "$tmp/restore"
259 WVPASS bup restore -C $tmp/restore /foo/latest/
260 for x in $tmp/src/*; do
261 WVPASS t/compare-trees $x/ $tmp/restore/$(basename $x);
264 WVSTART "restore /foo/latest/."
265 rm -rf "$tmp/restore"
266 WVPASS bup restore -C $tmp/restore /foo/latest/.
267 WVPASS t/compare-trees $tmp/src/ $tmp/restore/
269 WVSTART "restore /foo/latest/x"
270 rm -rf "$tmp/restore"
271 WVPASS bup restore -C $tmp/restore /foo/latest/x
272 WVPASS t/compare-trees $tmp/src/x/ $tmp/restore/x/
274 WVSTART "restore /foo/latest/x/"
275 rm -rf "$tmp/restore"
276 WVPASS bup restore -C $tmp/restore /foo/latest/x/
277 for x in $tmp/src/x/*; do
278 WVPASS t/compare-trees $x/ $tmp/restore/$(basename $x);
281 WVSTART "restore /foo/latest/x/."
282 rm -rf "$tmp/restore"
283 WVPASS bup restore -C $tmp/restore /foo/latest/x/.
284 WVPASS t/compare-trees $tmp/src/x/ $tmp/restore/
289 WVPASS bup ftp "cat /master/latest/$TOP/$D/b" >$D/b.new
290 WVPASS bup ftp "cat /master/latest/$TOP/$D/f" >$D/f.new
291 WVPASS bup ftp "cat /master/latest/$TOP/$D/f"{,} >$D/f2.new
292 WVPASS bup ftp "cat /master/latest/$TOP/$D/a" >$D/a.new
293 WVPASSEQ "$(sha1sum <$D/b)" "$(sha1sum <$D/b.new)"
294 WVPASSEQ "$(sha1sum <$D/f)" "$(sha1sum <$D/f.new)"
295 WVPASSEQ "$(cat $D/f.new{,} | sha1sum)" "$(sha1sum <$D/f2.new)"
296 WVPASSEQ "$(sha1sum <$D/a)" "$(sha1sum <$D/a.new)"
299 WVFAIL bup tag -d v0.n 2>/dev/null
300 WVFAIL bup tag v0.n non-existant 2>/dev/null
301 WVPASSEQ "$(bup tag)" ""
302 WVPASS bup tag v0.1 master
303 WVPASSEQ "$(bup tag)" "v0.1"
304 WVPASS bup tag -d v0.1
306 # This section destroys data in the bup repository, so it is done last.
309 WVPASS bup fsck --quick
310 if bup fsck --par2-ok; then
311 WVSTART "fsck (par2)"
313 WVSTART "fsck (PAR2 IS MISSING)"
317 WVPASS bup damage $BUP_DIR/objects/pack/*.pack -n10 -s1 -S0
318 WVFAIL bup fsck --quick
319 WVFAIL bup fsck --quick --disable-par2
320 chmod u+w $BUP_DIR/objects/pack/*.idx
321 WVPASS bup damage $BUP_DIR/objects/pack/*.idx -n10 -s1 -S0
322 WVFAIL bup fsck --quick -j4
323 WVPASS bup damage $BUP_DIR/objects/pack/*.pack -n10 -s1024 --percent 0.4 -S0
324 WVFAIL bup fsck --quick
325 WVFAIL bup fsck --quick -rvv -j99 # fails because repairs were needed
326 if bup fsck --par2-ok; then
327 WVPASS bup fsck -r # ok because of repairs from last time
328 WVPASS bup damage $BUP_DIR/objects/pack/*.pack -n202 -s1 --equal -S0
330 WVFAIL bup fsck -rvv # too many errors to be repairable
331 WVFAIL bup fsck -r # too many errors to be repairable
333 WVFAIL bup fsck --quick -r # still fails because par2 was missing
336 WVSTART "exclude-bupdir"
340 export BUP_DIR="$D/.bup"
343 WVPASS bup random 128k >$D/b
345 WVPASS bup random 512 >$D/f
346 WVPASS bup index -ux $D
347 bup save -n exclude-bupdir $D
348 WVPASSEQ "$(bup ls -a exclude-bupdir/latest/$TOP/$D/)" "a
357 export BUP_DIR="$D/.bup"
360 WVPASS bup random 128k >$D/b
362 WVPASS bup random 512 >$D/f
363 WVPASS bup index -ux --exclude $D/d $D
364 bup save -n exclude $D
365 WVPASSEQ "$(bup ls exclude/latest/$TOP/$D/)" "a
369 WVPASS bup index -ux --exclude $D/d --exclude $TOP/$D/g --exclude $D/h $D
370 bup save -n exclude $D
371 WVPASSEQ "$(bup ls exclude/latest/$TOP/$D/)" "a
375 WVSTART "exclude-from"
376 D=exclude-fromdir.tmp
377 EXCLUDE_FILE=exclude-from.tmp
380 $D/h" > $EXCLUDE_FILE
383 export BUP_DIR="$D/.bup"
386 WVPASS bup random 128k >$D/b
388 WVPASS bup random 512 >$D/f
390 WVPASS bup index -ux --exclude-from $EXCLUDE_FILE $D
391 bup save -n exclude-from $D
392 WVPASSEQ "$(bup ls exclude-from/latest/$TOP/$D/)" "a
398 WVSTART "save --strip"
403 export BUP_DIR="$(pwd)/$tmp/bup"
405 mkdir -p $tmp/src/x/y/z
406 WVPASS bup random 8k > $tmp/src/x/y/random-1
407 WVPASS bup random 8k > $tmp/src/x/y/z/random-2
408 WVPASS bup index -u $tmp/src
409 WVPASS bup save --strip -n foo $tmp/src/x/y
410 WVPASS bup restore -C $tmp/restore /foo/latest
411 WVPASS t/compare-trees $tmp/src/x/y/ "$tmp/restore/latest/"
414 WVSTART "save --strip-path (relative)"
419 export BUP_DIR="$(pwd)/$tmp/bup"
421 mkdir -p $tmp/src/x/y/z
422 WVPASS bup random 8k > $tmp/src/x/y/random-1
423 WVPASS bup random 8k > $tmp/src/x/y/z/random-2
424 WVPASS bup index -u $tmp/src
425 WVPASS bup save --strip-path $tmp/src -n foo $tmp/src/x
426 WVPASS bup restore -C $tmp/restore /foo/latest
427 WVPASS t/compare-trees $tmp/src/ "$tmp/restore/latest/"
430 WVSTART "save --strip-path (absolute)"
435 export BUP_DIR="$(pwd)/$tmp/bup"
437 mkdir -p $tmp/src/x/y/z
438 WVPASS bup random 8k > $tmp/src/x/y/random-1
439 WVPASS bup random 8k > $tmp/src/x/y/z/random-2
440 WVPASS bup index -u $tmp/src
441 WVPASS bup save --strip-path "$TOP" -n foo $tmp/src
442 WVPASS bup restore -C $tmp/restore /foo/latest
443 WVPASS t/compare-trees $tmp/src/ "$tmp/restore/latest/$tmp/src/"
446 WVSTART "save --strip-path (no match)"
451 export BUP_DIR="$(pwd)/$tmp/bup"
453 mkdir -p $tmp/src/x/y/z
454 WVPASS bup random 8k > $tmp/src/x/y/random-1
455 WVPASS bup random 8k > $tmp/src/x/y/z/random-2
456 WVPASS bup index -u $tmp/src
457 WVPASS bup save --strip-path $tmp/foo -n foo $tmp/src/x
458 WVPASS bup restore -C $tmp/restore /foo/latest
459 WVPASS t/compare-trees $tmp/src/ "$tmp/restore/latest/$TOP/$tmp/src/"
462 WVSTART "save --graft (empty graft points disallowed)"
467 export BUP_DIR="$(pwd)/$tmp/bup"
469 WVFAIL bup save --graft =/grafted -n graft-point-absolute $tmp
470 WVFAIL bup save --graft $TOP/$tmp= -n graft-point-absolute $tmp
473 WVSTART "save --graft /x/y=/a/b (relative paths)"
478 export BUP_DIR="$(pwd)/$tmp/bup"
480 mkdir -p $tmp/src/x/y/z
481 WVPASS bup random 8k > $tmp/src/x/y/random-1
482 WVPASS bup random 8k > $tmp/src/x/y/z/random-2
483 WVPASS bup index -u $tmp/src
484 WVPASS bup save --graft $tmp/src=x -n foo $tmp/src
485 WVPASS bup restore -C $tmp/restore /foo/latest
486 WVPASS t/compare-trees $tmp/src/ "$tmp/restore/latest/$TOP/x/"
489 WVSTART "save --graft /x/y=/a/b (matching structure)"
494 export BUP_DIR="$(pwd)/$tmp/bup"
496 mkdir -p $tmp/src/x/y/z
497 WVPASS bup random 8k > $tmp/src/x/y/random-1
498 WVPASS bup random 8k > $tmp/src/x/y/z/random-2
499 WVPASS bup index -u $tmp/src
500 WVPASS bup save -v --graft "$TOP/$tmp/src/x/y=$TOP/$tmp/src/a/b" \
502 WVPASS bup restore -C $tmp/restore /foo/latest
503 WVPASS t/compare-trees $tmp/src/x/y/ \
504 "$tmp/restore/latest/$TOP/$tmp/src/a/b/"
507 WVSTART "save --graft /x/y=/a (shorter target)"
512 export BUP_DIR="$(pwd)/$tmp/bup"
514 mkdir -p $tmp/src/x/y/z
515 WVPASS bup random 8k > $tmp/src/x/y/random-1
516 WVPASS bup random 8k > $tmp/src/x/y/z/random-2
517 WVPASS bup index -u $tmp/src
518 WVPASS bup save -v --graft "$TOP/$tmp/src/x/y=/a" -n foo $tmp/src/x/y
519 WVPASS bup restore -C $tmp/restore /foo/latest
520 WVPASS t/compare-trees $tmp/src/x/y/ "$tmp/restore/latest/a/"
523 WVSTART "save --graft /x=/a/b (longer target)"
526 export BUP_DIR="$(pwd)/$tmp/bup"
530 mkdir -p $tmp/src/x/y/z
531 WVPASS bup random 8k > $tmp/src/x/y/random-1
532 WVPASS bup random 8k > $tmp/src/x/y/z/random-2
533 WVPASS bup index -u $tmp/src
534 WVPASS bup save -v --graft "$TOP/$tmp/src=$TOP/$tmp/src/a/b/c" \
536 WVPASS bup restore -C $tmp/restore /foo/latest
537 WVPASS t/compare-trees $tmp/src/ "$tmp/restore/latest/$TOP/$tmp/src/a/b/c/"
540 WVSTART "save --graft /x=/ (root target)"
543 export BUP_DIR="$(pwd)/$tmp/bup"
547 mkdir -p $tmp/src/x/y/z
548 WVPASS bup random 8k > $tmp/src/x/y/random-1
549 WVPASS bup random 8k > $tmp/src/x/y/z/random-2
550 WVPASS bup index -u $tmp/src
551 WVPASS bup save -v --graft "$TOP/$tmp/src/x=/" -n foo $tmp/src/x
552 WVPASS bup restore -C $tmp/restore /foo/latest
553 WVPASS t/compare-trees $tmp/src/x/ "$tmp/restore/latest/"
556 #WVSTART "save --graft /=/x/ (root source)"
557 # FIXME: Not tested for now -- will require cleverness, or caution as root.
561 INDEXFILE=tmpindexfile.tmp
565 export BUP_DIR="$D/.bup"
570 WVPASS bup index -ux $D
571 bup save --strip -n bupdir $D
572 WVPASSEQ "$(bup ls bupdir/latest/)" "a
575 WVPASS bup index -f $INDEXFILE --exclude=$D/c -ux $D
576 bup save --strip -n indexfile -f $INDEXFILE $D
577 WVPASSEQ "$(bup ls indexfile/latest/)" "a
581 WVSTART "import-rsnapshot"
583 export BUP_DIR="$TOP/$D/.bup"
587 mkdir -p $D/hourly.0/buptest/a
588 touch $D/hourly.0/buptest/a/b
589 mkdir -p $D/hourly.0/buptest/c/d
590 touch $D/hourly.0/buptest/c/d/e
592 WVPASS bup import-rsnapshot $D/
593 WVPASSEQ "$(bup ls buptest/latest/)" "a/
597 if [ "$(which rdiff-backup)" != "" ]; then
598 WVSTART "import-rdiff-backup"
600 export BUP_DIR="$TOP/$D/.bup"
604 mkdir $D/rdiff-backup
605 rdiff-backup $TOP/cmd $D/rdiff-backup
607 rdiff-backup $TOP/Documentation $D/rdiff-backup
608 WVPASS bup import-rdiff-backup $D/rdiff-backup import-rdiff-backup
609 WVPASSEQ "$(bup ls import-rdiff-backup/ | wc -l)" "3"
610 WVPASSEQ "$(bup ls import-rdiff-backup/latest/ | sort)" "$(ls $TOP/Documentation | sort)"
614 WVSTART "compression"
616 export BUP_DIR="$TOP/$D/.bup"
620 WVPASS bup index $TOP/Documentation
621 WVPASS bup save -n compression -0 --strip $TOP/Documentation
622 # 'ls' on NetBSD sets -A by default when running as root, so we have to undo
623 # it by grepping out any dotfiles. (Normal OSes don't auto-set -A, but this
624 # is harmless there.)
625 WVPASSEQ "$(bup ls compression/latest/ | sort)" \
626 "$(ls $TOP/Documentation | grep -v '^\.' | sort)"
627 COMPRESSION_0_SIZE=$(du -k -s $D | cut -f1)
630 export BUP_DIR="$TOP/$D/.bup"
634 WVPASS bup index $TOP/Documentation
635 WVPASS bup save -n compression -9 --strip $TOP/Documentation
636 WVPASSEQ "$(bup ls compression/latest/ | sort)" "$(ls $TOP/Documentation | sort)"
637 COMPRESSION_9_SIZE=$(du -k -s $D | cut -f1)
639 WVPASS [ "$COMPRESSION_9_SIZE" -lt "$COMPRESSION_0_SIZE" ]
642 WVSTART "save disjoint top-level directories"
645 top_dir="$(echo $(pwd) | awk -F "/" '{print $2}')"
646 if [ "$top_dir" == tmp ]; then
647 echo "(running from within /tmp; skipping test)"
654 tmpdir="$(mktemp -d /tmp/bup-test-XXXXXXX)"
655 cleanup() { set -x; rm -rf "${tmpdir}"; set +x; }
659 export BUP_DIR="$TOP/buptest.tmp"
663 WVPASS bup index -vu $(pwd)/$D/x "$tmpdir"
664 WVPASS bup save -t -n src $(pwd)/$D/x "$tmpdir"
665 # For now, assume that "ls -a" and "sort" use the same order.
666 WVPASSEQ "$(bup ls -a src/latest)" "$(echo -e "$top_dir/\ntmp/" | sort)"
670 WVSTART "clear-index"
672 export BUP_DIR="$TOP/$D/.bup"
679 WVPASSEQ "$(bup index -p)" "$D/foo
684 WVPASS bup index --clear
686 WVPASSEQ "$(bup index -p)" "$D/bar