6 export BUP_DIR="$TOP/buptest.tmp"
23 WVFAIL bup index --exclude-from $D/cannot-exist $D
24 WVPASSEQ "$(bup index --check -p)" ""
25 WVPASSEQ "$(bup index --check -p $D)" ""
27 WVFAIL bup index --check -u $D.fake
28 WVPASS bup index --check -u $D
29 WVPASSEQ "$(bup index --check -p $D)" "$D/"
31 WVPASS bup random 128k >$D/b
33 WVPASS bup random 512 >$D/f
34 WVPASS ln -s non-existent-file $D/g
35 WVPASSEQ "$(bup index -s $D/)" "A $D/"
36 WVPASSEQ "$(bup index -s $D/b)" ""
37 WVPASSEQ "$(bup index --check -us $D/b)" "A $D/b"
38 WVPASSEQ "$(bup index --check -us $D/b $D/d)" \
44 WVPASSEQ "$(bup index --check -usx $D)" \
53 WVPASSEQ "$(bup index --check -us $D/a $D/b --fake-valid)" \
56 WVPASSEQ "$(bup index --check -us $D/a)" " $D/a" # stays unmodified
57 WVPASSEQ "$(bup index --check -us $D/d --fake-valid)" \
62 WVPASS bup index -u $D/d/z # becomes modified
63 WVPASSEQ "$(bup index -s $D/a $D $D/b)" \
73 WVPASS bup index -u $D/d/e $D/a --fake-invalid
74 WVPASSEQ "$(cd $D && bup index -m .)" \
82 WVPASSEQ "$(cd $D && bup index -m)" \
90 WVPASSEQ "$(cd $D && bup index -s .)" "$(cd $D && bup index -s .)"
92 WVFAIL bup save -t $D/doesnt-exist-filename
94 mv $BUP_DIR/bupindex $BUP_DIR/bi.old
95 WVFAIL bup save -t $D/d/e/fifotest
96 mkfifo $D/d/e/fifotest
97 WVPASS bup index -u $D/d/e/fifotest
98 WVPASS bup save -t $D/d/e/fifotest
99 WVPASS bup save -t $D/d/e
100 rm -f $D/d/e/fifotest
101 WVPASS bup index -u $D/d/e
102 WVFAIL bup save -t $D/d/e/fifotest
103 mv $BUP_DIR/bi.old $BUP_DIR/bupindex
105 WVPASS bup index -u $D/d/e
106 WVPASS bup save -t $D/d/e
107 WVPASSEQ "$(cd $D && bup index -m)" \
114 WVPASS bup save -t $D/d
115 WVPASS bup index --fake-invalid $D/d/z
116 WVPASS bup save -t $D/d/z
117 WVPASS bup save -t $D/d/z # test regenerating trees when no files are changed
118 WVPASS bup save -t $D/d
119 WVPASSEQ "$(cd $D && bup index -m)" \
124 tree1=$(bup save -t $D) || WVFAIL
125 WVPASSEQ "$(cd $D && bup index -m)" ""
126 tree2=$(bup save -t $D) || WVFAIL
127 WVPASSEQ "$tree1" "$tree2"
128 WVPASSEQ "$(bup index -s / | grep ^D)" ""
129 tree3=$(bup save -t /) || WVFAIL
130 WVPASSEQ "$tree1" "$tree3"
131 WVPASS bup save -r :$BUP_DIR -n r-test $D
132 WVFAIL bup save -r :$BUP_DIR/fake/path -n r-test $D
133 WVFAIL bup save -r :$BUP_DIR -n r-test $D/fake/path
138 WVPASS bup split -b a.tmp >taga.tmp
139 WVPASS bup split -b b.tmp >tagb.tmp
140 cat a.tmp b.tmp | WVPASS bup split -b >tagab.tmp
141 WVPASSEQ $(cat taga.tmp | wc -l) 1
142 WVPASSEQ $(cat tagb.tmp | wc -l) 1
143 WVPASSEQ $(cat tagab.tmp | wc -l) 1
144 WVPASSEQ $(cat tag[ab].tmp | wc -l) 2
145 WVPASSEQ "$(bup split -b a.tmp b.tmp)" "$(cat tagab.tmp)"
146 WVPASSEQ "$(bup split -b --keep-boundaries a.tmp b.tmp)" "$(cat tag[ab].tmp)"
147 WVPASSEQ "$(cat tag[ab].tmp | bup split -b --keep-boundaries --git-ids)" \
149 WVPASSEQ "$(cat tag[ab].tmp | bup split -b --git-ids)" \
151 WVPASS bup split --bench -b <t/testfile1 >tags1.tmp
152 WVPASS bup split -vvvv -b t/testfile2 >tags2.tmp
155 WVPASS bup midx --check -a
156 WVPASS bup midx -o $BUP_DIR/objects/pack/test1.midx \
157 $BUP_DIR/objects/pack/*.idx
158 WVPASS bup midx --check -a
159 WVPASS bup midx -o $BUP_DIR/objects/pack/test1.midx \
160 $BUP_DIR/objects/pack/*.idx \
161 $BUP_DIR/objects/pack/*.idx
162 WVPASS bup midx --check -a
163 all=$(echo $BUP_DIR/objects/pack/*.idx $BUP_DIR/objects/pack/*.midx)
164 WVPASS bup midx -o $BUP_DIR/objects/pack/zzz.midx $all
166 WVPASS bup midx -o $BUP_DIR/objects/pack/yyy.midx $all
168 WVPASSEQ "$(echo $BUP_DIR/objects/pack/*.midx)" \
169 "$BUP_DIR/objects/pack/yyy.midx"
171 WVPASS bup split -t t/testfile2 >tags2t.tmp
172 WVPASS bup split -t t/testfile2 --fanout 3 >tags2tf.tmp
173 WVPASS bup split -r "$BUP_DIR" -c t/testfile2 >tags2c.tmp
174 WVPASS bup split -r :$BUP_DIR -c t/testfile2 >tags2c.tmp
176 | WVPASS bup split -r :$BUP_DIR -c --fanout 3 --max-pack-objects 3 -n lslr
178 WVFAIL bup ls /does-not-exist
180 WVPASS bup ls /lslr/latest
181 WVPASS bup ls /lslr/latest/
182 #WVPASS bup ls /lslr/1971-01-01 # all dates always exist
183 WVFAIL diff -u tags1.tmp tags2.tmp
185 # fanout must be different from non-fanout
186 WVFAIL diff tags2t.tmp tags2tf.tmp
187 wc -c t/testfile1 t/testfile2
188 wc -l tags1.tmp tags2.tmp
191 WVPASS bup bloom -c $(ls -1 $BUP_DIR/objects/pack/*.idx|head -n1)
192 rm $BUP_DIR/objects/pack/bup.bloom
193 WVPASS bup bloom -k 4
194 WVPASS bup bloom -c $(ls -1 $BUP_DIR/objects/pack/*.idx|head -n1)
195 WVPASS bup bloom -d buptest.tmp/objects/pack --ruin --force
196 WVFAIL bup bloom -c $(ls -1 $BUP_DIR/objects/pack/*.idx|head -n1)
197 WVPASS bup bloom --force -k 5
198 WVPASS bup bloom -c $(ls -1 $BUP_DIR/objects/pack/*.idx|head -n1)
201 WVPASS bup memtest -c1 -n100
202 WVPASS bup memtest -c1 -n100 --existing
205 WVPASS bup join $(cat tags1.tmp) >out1.tmp
206 WVPASS bup join <tags2.tmp >out2.tmp
207 WVPASS bup join <tags2t.tmp -o out2t.tmp
208 WVPASS bup join -r "$BUP_DIR" <tags2c.tmp >out2c.tmp
209 WVPASS bup join -r ":$BUP_DIR" <tags2c.tmp >out2c.tmp
210 WVPASS diff -u t/testfile1 out1.tmp
211 WVPASS diff -u t/testfile2 out2.tmp
212 WVPASS diff -u t/testfile2 out2t.tmp
213 WVPASS diff -u t/testfile2 out2c.tmp
215 WVSTART "save/git-fsck"
218 cd "$BUP_DIR" || exit 1
221 (cd "$TOP/t/sampledata" && WVPASS bup save -vvn master /) || WVFAIL
222 n=$(git fsck --full --strict 2>&1 |
223 egrep -v 'dangling (commit|tree|blob)' |
226 WVPASS [ "$n" -eq 0 ]
230 rm -rf buprestore.tmp
231 WVFAIL bup restore boink
235 WVPASS bup restore -C buprestore.tmp "/master/latest/$TOP/$D"
236 WVPASSEQ "$(ls buprestore.tmp)" "bupdata.tmp"
237 rm -rf buprestore.tmp
238 WVPASS bup restore -C buprestore.tmp "/master/latest/$TOP/$D/"
239 touch $D/non-existent-file buprestore.tmp/non-existent-file # else diff fails
240 WVPASS diff -ur $D/ buprestore.tmp/
246 export BUP_DIR="$(pwd)/$tmp/bup"
248 mkdir -p $tmp/src/x/y/z
249 WVPASS bup random 8k > $tmp/src/x/y/random-1
250 WVPASS bup random 8k > $tmp/src/x/y/z/random-2
251 WVPASS bup index -u $tmp/src
252 WVPASS bup save --strip -n foo $tmp/src
254 WVSTART "restore /foo/latest"
255 WVPASS bup restore -C $tmp/restore /foo/latest
256 WVPASS t/compare-trees $tmp/src/ $tmp/restore/latest/
258 WVSTART "restore /foo/latest/"
259 rm -rf "$tmp/restore"
260 WVPASS bup restore -C $tmp/restore /foo/latest/
261 for x in $tmp/src/*; do
262 WVPASS t/compare-trees $x/ $tmp/restore/$(basename $x);
265 WVSTART "restore /foo/latest/."
266 rm -rf "$tmp/restore"
267 WVPASS bup restore -C $tmp/restore /foo/latest/.
268 WVPASS t/compare-trees $tmp/src/ $tmp/restore/
270 WVSTART "restore /foo/latest/x"
271 rm -rf "$tmp/restore"
272 WVPASS bup restore -C $tmp/restore /foo/latest/x
273 WVPASS t/compare-trees $tmp/src/x/ $tmp/restore/x/
275 WVSTART "restore /foo/latest/x/"
276 rm -rf "$tmp/restore"
277 WVPASS bup restore -C $tmp/restore /foo/latest/x/
278 for x in $tmp/src/x/*; do
279 WVPASS t/compare-trees $x/ $tmp/restore/$(basename $x);
282 WVSTART "restore /foo/latest/x/."
283 rm -rf "$tmp/restore"
284 WVPASS bup restore -C $tmp/restore /foo/latest/x/.
285 WVPASS t/compare-trees $tmp/src/x/ $tmp/restore/
290 WVPASS bup ftp "cat /master/latest/$TOP/$D/b" >$D/b.new
291 WVPASS bup ftp "cat /master/latest/$TOP/$D/f" >$D/f.new
292 WVPASS bup ftp "cat /master/latest/$TOP/$D/f"{,} >$D/f2.new
293 WVPASS bup ftp "cat /master/latest/$TOP/$D/a" >$D/a.new
294 WVPASSEQ "$(sha1sum <$D/b)" "$(sha1sum <$D/b.new)"
295 WVPASSEQ "$(sha1sum <$D/f)" "$(sha1sum <$D/f.new)"
296 WVPASSEQ "$(cat $D/f.new{,} | sha1sum)" "$(sha1sum <$D/f2.new)"
297 WVPASSEQ "$(sha1sum <$D/a)" "$(sha1sum <$D/a.new)"
300 WVFAIL bup tag -d v0.n 2>/dev/null
301 WVFAIL bup tag v0.n non-existant 2>/dev/null
302 WVPASSEQ "$(bup tag)" ""
303 WVPASS bup tag v0.1 master
304 WVPASSEQ "$(bup tag)" "v0.1"
305 WVPASS bup tag -d v0.1
307 # This section destroys data in the bup repository, so it is done last.
310 WVPASS bup fsck --quick
311 if bup fsck --par2-ok; then
312 WVSTART "fsck (par2)"
314 WVSTART "fsck (PAR2 IS MISSING)"
318 WVPASS bup damage $BUP_DIR/objects/pack/*.pack -n10 -s1 -S0
319 WVFAIL bup fsck --quick
320 WVFAIL bup fsck --quick --disable-par2
321 chmod u+w $BUP_DIR/objects/pack/*.idx
322 WVPASS bup damage $BUP_DIR/objects/pack/*.idx -n10 -s1 -S0
323 WVFAIL bup fsck --quick -j4
324 WVPASS bup damage $BUP_DIR/objects/pack/*.pack -n10 -s1024 --percent 0.4 -S0
325 WVFAIL bup fsck --quick
326 WVFAIL bup fsck --quick -rvv -j99 # fails because repairs were needed
327 if bup fsck --par2-ok; then
328 WVPASS bup fsck -r # ok because of repairs from last time
329 WVPASS bup damage $BUP_DIR/objects/pack/*.pack -n202 -s1 --equal -S0
331 WVFAIL bup fsck -rvv # too many errors to be repairable
332 WVFAIL bup fsck -r # too many errors to be repairable
334 WVFAIL bup fsck --quick -r # still fails because par2 was missing
337 WVSTART "exclude-bupdir"
341 export BUP_DIR="$D/.bup"
344 WVPASS bup random 128k >$D/b
346 WVPASS bup random 512 >$D/f
347 WVPASS bup index -ux $D
348 bup save -n exclude-bupdir $D
349 WVPASSEQ "$(bup ls -a exclude-bupdir/latest/$TOP/$D/)" "a
358 export BUP_DIR="$D/.bup"
361 WVPASS bup random 128k >$D/b
363 WVPASS bup random 512 >$D/f
364 WVPASS bup index -ux --exclude $D/d $D
365 bup save -n exclude $D
366 WVPASSEQ "$(bup ls exclude/latest/$TOP/$D/)" "a
370 WVPASS bup index -ux --exclude $D/d --exclude $TOP/$D/g --exclude $D/h $D
371 bup save -n exclude $D
372 WVPASSEQ "$(bup ls exclude/latest/$TOP/$D/)" "a
376 WVSTART "exclude-from"
377 D=exclude-fromdir.tmp
378 EXCLUDE_FILE=exclude-from.tmp
381 $D/h" > $EXCLUDE_FILE
384 export BUP_DIR="$D/.bup"
387 WVPASS bup random 128k >$D/b
389 WVPASS bup random 512 >$D/f
391 WVPASS bup index -ux --exclude-from $EXCLUDE_FILE $D
392 bup save -n exclude-from $D
393 WVPASSEQ "$(bup ls exclude-from/latest/$TOP/$D/)" "a
399 WVSTART "save --strip"
404 export BUP_DIR="$(pwd)/$tmp/bup"
406 mkdir -p $tmp/src/x/y/z
407 WVPASS bup random 8k > $tmp/src/x/y/random-1
408 WVPASS bup random 8k > $tmp/src/x/y/z/random-2
409 WVPASS bup index -u $tmp/src
410 WVPASS bup save --strip -n foo $tmp/src/x/y
411 WVPASS bup restore -C $tmp/restore /foo/latest
412 WVPASS t/compare-trees $tmp/src/x/y/ "$tmp/restore/latest/"
415 WVSTART "save --strip-path (relative)"
420 export BUP_DIR="$(pwd)/$tmp/bup"
422 mkdir -p $tmp/src/x/y/z
423 WVPASS bup random 8k > $tmp/src/x/y/random-1
424 WVPASS bup random 8k > $tmp/src/x/y/z/random-2
425 WVPASS bup index -u $tmp/src
426 WVPASS bup save --strip-path $tmp/src -n foo $tmp/src/x
427 WVPASS bup restore -C $tmp/restore /foo/latest
428 WVPASS t/compare-trees $tmp/src/ "$tmp/restore/latest/"
431 WVSTART "save --strip-path (absolute)"
436 export BUP_DIR="$(pwd)/$tmp/bup"
438 mkdir -p $tmp/src/x/y/z
439 WVPASS bup random 8k > $tmp/src/x/y/random-1
440 WVPASS bup random 8k > $tmp/src/x/y/z/random-2
441 WVPASS bup index -u $tmp/src
442 WVPASS bup save --strip-path "$TOP" -n foo $tmp/src
443 WVPASS bup restore -C $tmp/restore /foo/latest
444 WVPASS t/compare-trees $tmp/src/ "$tmp/restore/latest/$tmp/src/"
447 WVSTART "save --strip-path (no match)"
452 export BUP_DIR="$(pwd)/$tmp/bup"
454 mkdir -p $tmp/src/x/y/z
455 WVPASS bup random 8k > $tmp/src/x/y/random-1
456 WVPASS bup random 8k > $tmp/src/x/y/z/random-2
457 WVPASS bup index -u $tmp/src
458 WVPASS bup save --strip-path $tmp/foo -n foo $tmp/src/x
459 WVPASS bup restore -C $tmp/restore /foo/latest
460 WVPASS t/compare-trees $tmp/src/ "$tmp/restore/latest/$TOP/$tmp/src/"
463 WVSTART "save --graft (empty graft points disallowed)"
468 export BUP_DIR="$(pwd)/$tmp/bup"
470 WVFAIL bup save --graft =/grafted -n graft-point-absolute $tmp
471 WVFAIL bup save --graft $TOP/$tmp= -n graft-point-absolute $tmp
474 WVSTART "save --graft /x/y=/a/b (relative paths)"
479 export BUP_DIR="$(pwd)/$tmp/bup"
481 mkdir -p $tmp/src/x/y/z
482 WVPASS bup random 8k > $tmp/src/x/y/random-1
483 WVPASS bup random 8k > $tmp/src/x/y/z/random-2
484 WVPASS bup index -u $tmp/src
485 WVPASS bup save --graft $tmp/src=x -n foo $tmp/src
486 WVPASS bup restore -C $tmp/restore /foo/latest
487 WVPASS t/compare-trees $tmp/src/ "$tmp/restore/latest/$TOP/x/"
490 WVSTART "save --graft /x/y=/a/b (matching structure)"
495 export BUP_DIR="$(pwd)/$tmp/bup"
497 mkdir -p $tmp/src/x/y/z
498 WVPASS bup random 8k > $tmp/src/x/y/random-1
499 WVPASS bup random 8k > $tmp/src/x/y/z/random-2
500 WVPASS bup index -u $tmp/src
501 WVPASS bup save -v --graft "$TOP/$tmp/src/x/y=$TOP/$tmp/src/a/b" \
503 WVPASS bup restore -C $tmp/restore /foo/latest
504 WVPASS t/compare-trees $tmp/src/x/y/ \
505 "$tmp/restore/latest/$TOP/$tmp/src/a/b/"
508 WVSTART "save --graft /x/y=/a (shorter target)"
513 export BUP_DIR="$(pwd)/$tmp/bup"
515 mkdir -p $tmp/src/x/y/z
516 WVPASS bup random 8k > $tmp/src/x/y/random-1
517 WVPASS bup random 8k > $tmp/src/x/y/z/random-2
518 WVPASS bup index -u $tmp/src
519 WVPASS bup save -v --graft "$TOP/$tmp/src/x/y=/a" -n foo $tmp/src/x/y
520 WVPASS bup restore -C $tmp/restore /foo/latest
521 WVPASS t/compare-trees $tmp/src/x/y/ "$tmp/restore/latest/a/"
524 WVSTART "save --graft /x=/a/b (longer target)"
527 export BUP_DIR="$(pwd)/$tmp/bup"
531 mkdir -p $tmp/src/x/y/z
532 WVPASS bup random 8k > $tmp/src/x/y/random-1
533 WVPASS bup random 8k > $tmp/src/x/y/z/random-2
534 WVPASS bup index -u $tmp/src
535 WVPASS bup save -v --graft "$TOP/$tmp/src=$TOP/$tmp/src/a/b/c" \
537 WVPASS bup restore -C $tmp/restore /foo/latest
538 WVPASS t/compare-trees $tmp/src/ "$tmp/restore/latest/$TOP/$tmp/src/a/b/c/"
541 WVSTART "save --graft /x=/ (root target)"
544 export BUP_DIR="$(pwd)/$tmp/bup"
548 mkdir -p $tmp/src/x/y/z
549 WVPASS bup random 8k > $tmp/src/x/y/random-1
550 WVPASS bup random 8k > $tmp/src/x/y/z/random-2
551 WVPASS bup index -u $tmp/src
552 WVPASS bup save -v --graft "$TOP/$tmp/src/x=/" -n foo $tmp/src/x
553 WVPASS bup restore -C $tmp/restore /foo/latest
554 WVPASS t/compare-trees $tmp/src/x/ "$tmp/restore/latest/"
557 #WVSTART "save --graft /=/x/ (root source)"
558 # FIXME: Not tested for now -- will require cleverness, or caution as root.
562 INDEXFILE=tmpindexfile.tmp
566 export BUP_DIR="$D/.bup"
571 WVPASS bup index -ux $D
572 bup save --strip -n bupdir $D
573 WVPASSEQ "$(bup ls bupdir/latest/)" "a
576 WVPASS bup index -f $INDEXFILE --exclude=$D/c -ux $D
577 bup save --strip -n indexfile -f $INDEXFILE $D
578 WVPASSEQ "$(bup ls indexfile/latest/)" "a
582 WVSTART "import-rsnapshot"
584 export BUP_DIR="$TOP/$D/.bup"
588 mkdir -p $D/hourly.0/buptest/a
589 touch $D/hourly.0/buptest/a/b
590 mkdir -p $D/hourly.0/buptest/c/d
591 touch $D/hourly.0/buptest/c/d/e
593 WVPASS bup import-rsnapshot $D/
594 WVPASSEQ "$(bup ls buptest/latest/)" "a/
598 if [ "$(which rdiff-backup)" != "" ]; then
599 WVSTART "import-rdiff-backup"
601 export BUP_DIR="$TOP/$D/.bup"
605 mkdir $D/rdiff-backup
606 rdiff-backup $TOP/cmd $D/rdiff-backup
608 rdiff-backup $TOP/Documentation $D/rdiff-backup
609 WVPASS bup import-rdiff-backup $D/rdiff-backup import-rdiff-backup
610 WVPASSEQ "$(bup ls import-rdiff-backup/ | wc -l)" "3"
611 WVPASSEQ "$(bup ls import-rdiff-backup/latest/ | sort)" "$(ls $TOP/Documentation | sort)"
615 WVSTART "compression"
617 export BUP_DIR="$TOP/$D/.bup"
621 WVPASS bup index $TOP/Documentation
622 WVPASS bup save -n compression -0 --strip $TOP/Documentation
623 # 'ls' on NetBSD sets -A by default when running as root, so we have to undo
624 # it by grepping out any dotfiles. (Normal OSes don't auto-set -A, but this
625 # is harmless there.)
626 WVPASSEQ "$(bup ls compression/latest/ | sort)" \
627 "$(ls $TOP/Documentation | grep -v '^\.' | sort)"
628 COMPRESSION_0_SIZE=$(du -k -s $D | cut -f1)
631 export BUP_DIR="$TOP/$D/.bup"
635 WVPASS bup index $TOP/Documentation
636 WVPASS bup save -n compression -9 --strip $TOP/Documentation
637 WVPASSEQ "$(bup ls compression/latest/ | sort)" "$(ls $TOP/Documentation | sort)"
638 COMPRESSION_9_SIZE=$(du -k -s $D | cut -f1)
640 WVPASS [ "$COMPRESSION_9_SIZE" -lt "$COMPRESSION_0_SIZE" ]
643 WVSTART "save disjoint top-level directories"
646 top_dir="$(echo $(pwd) | awk -F "/" '{print $2}')"
647 if [ "$top_dir" == tmp ]; then
648 echo "(running from within /tmp; skipping test)"
655 tmpdir="$(mktemp -d /tmp/bup-test-XXXXXXX)"
656 cleanup() { set -x; rm -rf "${tmpdir}"; set +x; }
660 export BUP_DIR="$TOP/buptest.tmp"
664 WVPASS bup index -vu $(pwd)/$D/x "$tmpdir"
665 WVPASS bup save -t -n src $(pwd)/$D/x "$tmpdir"
666 # For now, assume that "ls -a" and "sort" use the same order.
667 WVPASSEQ "$(bup ls -a src/latest)" "$(echo -e "$top_dir/\ntmp/" | sort)"
671 WVSTART "clear-index"
673 export BUP_DIR="$TOP/$D/.bup"
680 WVPASSEQ "$(bup index -p)" "$D/foo
685 WVPASS bup index --clear
687 WVPASSEQ "$(bup index -p)" "$D/bar