5 TOP="$(WVPASS /bin/pwd)" || exit $?
6 export BUP_DIR="$TOP/buptest.tmp"
15 WVPASS rm -rf "$BUP_DIR"
20 WVPASS force-delete $D
22 WVFAIL bup index --exclude-from $D/cannot-exist $D
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
31 WVPASS mkdir $D/d $D/d/e
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 WVPASS mv $BUP_DIR/bupindex $BUP_DIR/bi.old
94 WVFAIL bup save -t $D/d/e/fifotest
95 WVPASS 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
99 WVPASS rm -f $D/d/e/fifotest
100 WVPASS bup index -u $D/d/e
101 WVFAIL bup save -t $D/d/e/fifotest
102 WVPASS 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 WVPASS bup save -r :$BUP_DIR -n r-test $D
124 WVFAIL bup save -r :$BUP_DIR/fake/path -n r-test $D
125 WVFAIL bup save -r :$BUP_DIR -n r-test $D/fake/path
130 WVPASS bup split -b a.tmp >taga.tmp
131 WVPASS bup split -b b.tmp >tagb.tmp
132 WVPASS cat a.tmp b.tmp | WVPASS bup split -b >tagab.tmp
133 WVPASSEQ $(cat taga.tmp | wc -l) 1
134 WVPASSEQ $(cat tagb.tmp | wc -l) 1
135 WVPASSEQ $(cat tagab.tmp | wc -l) 1
136 WVPASSEQ $(cat tag[ab].tmp | wc -l) 2
137 WVPASSEQ "$(bup split -b a.tmp b.tmp)" "$(cat tagab.tmp)"
138 WVPASSEQ "$(bup split -b --keep-boundaries a.tmp b.tmp)" "$(cat tag[ab].tmp)"
139 WVPASSEQ "$(cat tag[ab].tmp | bup split -b --keep-boundaries --git-ids)" \
141 WVPASSEQ "$(cat tag[ab].tmp | bup split -b --git-ids)" \
143 WVPASS bup split --bench -b <t/testfile1 >tags1.tmp
144 WVPASS bup split -vvvv -b t/testfile2 >tags2.tmp
147 WVPASS bup midx --check -a
148 WVPASS bup midx -o $BUP_DIR/objects/pack/test1.midx \
149 $BUP_DIR/objects/pack/*.idx
150 WVPASS bup midx --check -a
151 WVPASS bup midx -o $BUP_DIR/objects/pack/test1.midx \
152 $BUP_DIR/objects/pack/*.idx \
153 $BUP_DIR/objects/pack/*.idx
154 WVPASS bup midx --check -a
155 all=$(echo $BUP_DIR/objects/pack/*.idx $BUP_DIR/objects/pack/*.midx)
156 WVPASS bup midx -o $BUP_DIR/objects/pack/zzz.midx $all
158 WVPASS bup midx -o $BUP_DIR/objects/pack/yyy.midx $all
160 WVPASSEQ "$(echo $BUP_DIR/objects/pack/*.midx)" \
161 "$BUP_DIR/objects/pack/yyy.midx"
163 WVPASS bup split -t t/testfile2 >tags2t.tmp
164 WVPASS bup split -t t/testfile2 --fanout 3 >tags2tf.tmp
165 WVPASS bup split -r "$BUP_DIR" -c t/testfile2 >tags2c.tmp
166 WVPASS bup split -r :$BUP_DIR -c t/testfile2 >tags2c.tmp
168 | WVPASS bup split -r :$BUP_DIR -c --fanout 3 --max-pack-objects 3 -n lslr
170 WVFAIL bup ls /does-not-exist
172 WVPASS bup ls /lslr/latest
173 WVPASS bup ls /lslr/latest/
174 #WVPASS bup ls /lslr/1971-01-01 # all dates always exist
175 WVFAIL diff -u tags1.tmp tags2.tmp
177 # fanout must be different from non-fanout
178 WVFAIL diff tags2t.tmp tags2tf.tmp
179 WVPASS wc -c t/testfile1 t/testfile2
180 WVPASS wc -l tags1.tmp tags2.tmp
183 WVPASS bup bloom -c $(ls -1 $BUP_DIR/objects/pack/*.idx|head -n1)
184 WVPASS rm $BUP_DIR/objects/pack/bup.bloom
185 WVPASS bup bloom -k 4
186 WVPASS bup bloom -c $(ls -1 $BUP_DIR/objects/pack/*.idx|head -n1)
187 WVPASS bup bloom -d buptest.tmp/objects/pack --ruin --force
188 WVFAIL bup bloom -c $(ls -1 $BUP_DIR/objects/pack/*.idx|head -n1)
189 WVPASS bup bloom --force -k 5
190 WVPASS bup bloom -c $(ls -1 $BUP_DIR/objects/pack/*.idx|head -n1)
193 WVPASS bup memtest -c1 -n100
194 WVPASS bup memtest -c1 -n100 --existing
197 WVPASS bup join $(cat tags1.tmp) >out1.tmp
198 WVPASS bup join <tags2.tmp >out2.tmp
199 WVPASS bup join <tags2t.tmp -o out2t.tmp
200 WVPASS bup join -r "$BUP_DIR" <tags2c.tmp >out2c.tmp
201 WVPASS bup join -r ":$BUP_DIR" <tags2c.tmp >out2c.tmp
202 WVPASS diff -u t/testfile1 out1.tmp
203 WVPASS diff -u t/testfile2 out2.tmp
204 WVPASS diff -u t/testfile2 out2t.tmp
205 WVPASS diff -u t/testfile2 out2c.tmp
207 WVSTART "save/git-fsck"
212 (WVPASS cd "$TOP/t/sampledata" && WVPASS bup save -vvn master /) || exit $?
213 result="$(git fsck --full --strict 2>&1)" || exit $?
215 egrep -v 'dangling (commit|tree|blob)' |
216 WVPASS tee -a /dev/stderr |
217 WVPASS wc -l) || exit $?
218 WVPASS [ "$n" -eq 0 ]
222 WVPASS force-delete buprestore.tmp
223 WVFAIL bup restore boink
224 WVPASS touch $TOP/$D/$D
225 WVPASS bup index -u $TOP/$D
226 WVPASS bup save -n master /
227 WVPASS bup restore -C buprestore.tmp "/master/latest/$TOP/$D"
228 WVPASSEQ "$(ls buprestore.tmp)" "bupdata.tmp"
229 WVPASS force-delete buprestore.tmp
230 WVPASS bup restore -C buprestore.tmp "/master/latest/$TOP/$D/"
231 WVPASS touch $D/non-existent-file buprestore.tmp/non-existent-file # else diff fails
232 WVPASS diff -ur $D/ buprestore.tmp/
236 WVPASS force-delete $tmp
238 export BUP_DIR="$(pwd)/$tmp/bup"
239 WVPASS WVPASS bup init
240 WVPASS mkdir -p $tmp/src/x/y/z
241 WVPASS bup random 8k > $tmp/src/x/y/random-1
242 WVPASS bup random 8k > $tmp/src/x/y/z/random-2
243 WVPASS bup index -u $tmp/src
244 WVPASS bup save --strip -n foo $tmp/src
246 WVSTART "restore /foo/latest"
247 WVPASS bup restore -C $tmp/restore /foo/latest
248 WVPASS t/compare-trees $tmp/src/ $tmp/restore/latest/
250 WVSTART "restore /foo/latest/"
251 WVPASS force-delete "$tmp/restore"
252 WVPASS bup restore -C $tmp/restore /foo/latest/
253 for x in $tmp/src/*; do
254 WVPASS t/compare-trees $x/ $tmp/restore/$(basename $x);
257 WVSTART "restore /foo/latest/."
258 WVPASS force-delete "$tmp/restore"
259 WVPASS bup restore -C $tmp/restore /foo/latest/.
260 WVPASS t/compare-trees $tmp/src/ $tmp/restore/
262 WVSTART "restore /foo/latest/x"
263 WVPASS force-delete "$tmp/restore"
264 WVPASS bup restore -C $tmp/restore /foo/latest/x
265 WVPASS t/compare-trees $tmp/src/x/ $tmp/restore/x/
267 WVSTART "restore /foo/latest/x/"
268 WVPASS force-delete "$tmp/restore"
269 WVPASS bup restore -C $tmp/restore /foo/latest/x/
270 for x in $tmp/src/x/*; do
271 WVPASS t/compare-trees $x/ $tmp/restore/$(basename $x);
274 WVSTART "restore /foo/latest/x/."
275 WVPASS force-delete "$tmp/restore"
276 WVPASS bup restore -C $tmp/restore /foo/latest/x/.
277 WVPASS t/compare-trees $tmp/src/x/ $tmp/restore/
282 WVPASS bup ftp "cat /master/latest/$TOP/$D/b" >$D/b.new
283 WVPASS bup ftp "cat /master/latest/$TOP/$D/f" >$D/f.new
284 WVPASS bup ftp "cat /master/latest/$TOP/$D/f"{,} >$D/f2.new
285 WVPASS bup ftp "cat /master/latest/$TOP/$D/a" >$D/a.new
286 WVPASSEQ "$(sha1sum <$D/b)" "$(sha1sum <$D/b.new)"
287 WVPASSEQ "$(sha1sum <$D/f)" "$(sha1sum <$D/f.new)"
288 WVPASSEQ "$(cat $D/f.new{,} | sha1sum)" "$(sha1sum <$D/f2.new)"
289 WVPASSEQ "$(sha1sum <$D/a)" "$(sha1sum <$D/a.new)"
292 WVFAIL bup tag -d v0.n 2>/dev/null
293 WVFAIL bup tag v0.n non-existant 2>/dev/null
294 WVPASSEQ "$(bup tag)" ""
295 WVPASS bup tag v0.1 master
296 WVPASSEQ "$(bup tag)" "v0.1"
297 WVPASS bup tag -d v0.1
299 # This section destroys data in the bup repository, so it is done last.
302 WVPASS bup fsck --quick
303 if bup fsck --par2-ok; then
304 WVSTART "fsck (par2)"
306 WVSTART "fsck (PAR2 IS MISSING)"
310 WVPASS bup damage $BUP_DIR/objects/pack/*.pack -n10 -s1 -S0
311 WVFAIL bup fsck --quick
312 WVFAIL bup fsck --quick --disable-par2
313 WVPASS chmod u+w $BUP_DIR/objects/pack/*.idx
314 WVPASS bup damage $BUP_DIR/objects/pack/*.idx -n10 -s1 -S0
315 WVFAIL bup fsck --quick -j4
316 WVPASS bup damage $BUP_DIR/objects/pack/*.pack -n10 -s1024 --percent 0.4 -S0
317 WVFAIL bup fsck --quick
318 WVFAIL bup fsck --quick -rvv -j99 # fails because repairs were needed
319 if bup fsck --par2-ok; then
320 WVPASS bup fsck -r # ok because of repairs from last time
321 WVPASS bup damage $BUP_DIR/objects/pack/*.pack -n202 -s1 --equal -S0
323 WVFAIL bup fsck -rvv # too many errors to be repairable
324 WVFAIL bup fsck -r # too many errors to be repairable
326 WVFAIL bup fsck --quick -r # still fails because par2 was missing
329 WVSTART "exclude-bupdir"
331 WVPASS force-delete $D
333 export BUP_DIR="$D/.bup"
336 WVPASS bup random 128k >$D/b
337 WVPASS mkdir $D/d $D/d/e
338 WVPASS bup random 512 >$D/f
339 WVPASS bup index -ux $D
340 WVPASS bup save -n exclude-bupdir $D
341 WVPASSEQ "$(bup ls -a exclude-bupdir/latest/$TOP/$D/)" "a
349 WVPASS force-delete $D
351 export BUP_DIR="$D/.bup"
354 WVPASS bup random 128k >$D/b
355 WVPASS mkdir $D/d $D/d/e
356 WVPASS bup random 512 >$D/f
357 WVPASS bup random 512 >$D/j
358 WVPASS bup index -ux --exclude $D/d --exclude $D/j $D
359 WVPASS bup save -n exclude $D
360 WVPASSEQ "$(bup ls exclude/latest/$TOP/$D/)" "a
363 WVPASS mkdir $D/g $D/h
364 WVPASS bup index -ux --exclude $D/d --exclude $TOP/$D/g --exclude $D/h \
365 --exclude $TOP/$D/j $D
366 WVPASS bup save -n exclude $D
367 WVPASSEQ "$(bup ls exclude/latest/$TOP/$D/)" "a
372 WVSTART "exclude-from"
374 D=exclude-fromdir.tmp
375 EXCLUDE_FILE=exclude-from.tmp
379 $D/i" > $EXCLUDE_FILE
380 WVPASS force-delete $D
382 export BUP_DIR="$D/.bup"
385 WVPASS bup random 128k >$D/b
386 WVPASS mkdir $D/d $D/d/e
387 WVPASS bup random 512 >$D/f
388 WVPASS mkdir $D/g $D/h
389 WVPASS bup random 128k > $D/i
390 WVPASS bup index -ux --exclude-from $EXCLUDE_FILE $D
391 WVPASS bup save -n exclude-from $D
392 WVPASSEQ "$(bup ls exclude-from/latest/$TOP/$D/)" "a
395 WVPASS rm $EXCLUDE_FILE
398 WVSTART "save (no index)"
400 tmp=save-no-index.tmp
401 WVPASS force-delete $tmp
403 export BUP_DIR="$(WVPASS pwd)/$tmp/bup" || exit $?
405 WVFAIL bup save -n nothing /
409 WVSTART "save --strip"
412 WVPASS force-delete $tmp
414 export BUP_DIR="$(WVPASS pwd)/$tmp/bup" || exit $?
416 WVPASS mkdir -p $tmp/src/x/y/z
417 WVPASS bup random 8k > $tmp/src/x/y/random-1
418 WVPASS bup random 8k > $tmp/src/x/y/z/random-2
419 WVPASS bup index -u $tmp/src
420 WVPASS bup save --strip -n foo $tmp/src/x/y
421 WVPASS bup restore -C $tmp/restore /foo/latest
422 WVPASS t/compare-trees $tmp/src/x/y/ "$tmp/restore/latest/"
425 WVSTART "save --strip-path (relative)"
428 WVPASS force-delete $tmp
430 export BUP_DIR="$(WVPASS pwd)/$tmp/bup" || exit $?
432 WVPASS mkdir -p $tmp/src/x/y/z
433 WVPASS bup random 8k > $tmp/src/x/y/random-1
434 WVPASS bup random 8k > $tmp/src/x/y/z/random-2
435 WVPASS bup index -u $tmp/src
436 WVPASS bup save --strip-path $tmp/src -n foo $tmp/src/x
437 WVPASS bup restore -C $tmp/restore /foo/latest
438 WVPASS t/compare-trees $tmp/src/ "$tmp/restore/latest/"
441 WVSTART "save --strip-path (absolute)"
444 WVPASS force-delete $tmp
446 export BUP_DIR="$(WVPASS pwd)/$tmp/bup" || exit $?
448 WVPASS mkdir -p $tmp/src/x/y/z
449 WVPASS bup random 8k > $tmp/src/x/y/random-1
450 WVPASS bup random 8k > $tmp/src/x/y/z/random-2
451 WVPASS bup index -u $tmp/src
452 WVPASS bup save --strip-path "$TOP" -n foo $tmp/src
453 WVPASS bup restore -C $tmp/restore /foo/latest
454 WVPASS t/compare-trees $tmp/src/ "$tmp/restore/latest/$tmp/src/"
457 WVSTART "save --strip-path (no match)"
460 WVPASS force-delete $tmp
462 export BUP_DIR="$(WVPASS pwd)/$tmp/bup" || exit $?
464 WVPASS mkdir -p $tmp/src/x/y/z
465 WVPASS bup random 8k > $tmp/src/x/y/random-1
466 WVPASS bup random 8k > $tmp/src/x/y/z/random-2
467 WVPASS bup index -u $tmp/src
468 WVPASS bup save --strip-path $tmp/foo -n foo $tmp/src/x
469 WVPASS bup restore -C $tmp/restore /foo/latest
470 WVPASS t/compare-trees $tmp/src/ "$tmp/restore/latest/$TOP/$tmp/src/"
473 WVSTART "save --graft (empty graft points disallowed)"
476 WVPASS force-delete $tmp
478 export BUP_DIR="$(WVPASS pwd)/$tmp/bup" || exit $?
480 WVFAIL bup save --graft =/grafted -n graft-point-absolute $tmp
481 WVFAIL bup save --graft $TOP/$tmp= -n graft-point-absolute $tmp
484 WVSTART "save --graft /x/y=/a/b (relative paths)"
487 WVPASS force-delete $tmp
489 export BUP_DIR="$(WVPASS pwd)/$tmp/bup" || exit $?
491 WVPASS mkdir -p $tmp/src/x/y/z
492 WVPASS bup random 8k > $tmp/src/x/y/random-1
493 WVPASS bup random 8k > $tmp/src/x/y/z/random-2
494 WVPASS bup index -u $tmp/src
495 WVPASS bup save --graft $tmp/src=x -n foo $tmp/src
496 WVPASS bup restore -C $tmp/restore /foo/latest
497 WVPASS t/compare-trees $tmp/src/ "$tmp/restore/latest/$TOP/x/"
500 WVSTART "save --graft /x/y=/a/b (matching structure)"
503 WVPASS force-delete $tmp
505 export BUP_DIR="$(WVPASS pwd)/$tmp/bup" || exit $?
507 WVPASS mkdir -p $tmp/src/x/y/z
508 WVPASS bup random 8k > $tmp/src/x/y/random-1
509 WVPASS bup random 8k > $tmp/src/x/y/z/random-2
510 WVPASS bup index -u $tmp/src
511 WVPASS bup save -v --graft "$TOP/$tmp/src/x/y=$TOP/$tmp/src/a/b" \
513 WVPASS bup restore -C $tmp/restore /foo/latest
514 WVPASS t/compare-trees $tmp/src/x/y/ \
515 "$tmp/restore/latest/$TOP/$tmp/src/a/b/"
518 WVSTART "save --graft /x/y=/a (shorter target)"
521 WVPASS force-delete $tmp
523 export BUP_DIR="$(WVPASS pwd)/$tmp/bup" || exit $?
525 WVPASS mkdir -p $tmp/src/x/y/z
526 WVPASS bup random 8k > $tmp/src/x/y/random-1
527 WVPASS bup random 8k > $tmp/src/x/y/z/random-2
528 WVPASS bup index -u $tmp/src
529 WVPASS bup save -v --graft "$TOP/$tmp/src/x/y=/a" -n foo $tmp/src/x/y
530 WVPASS bup restore -C $tmp/restore /foo/latest
531 WVPASS t/compare-trees $tmp/src/x/y/ "$tmp/restore/latest/a/"
534 WVSTART "save --graft /x=/a/b (longer target)"
537 export BUP_DIR="$(WVPASS pwd)/$tmp/bup" || exit $?
538 WVPASS force-delete $tmp
541 WVPASS mkdir -p $tmp/src/x/y/z
542 WVPASS bup random 8k > $tmp/src/x/y/random-1
543 WVPASS bup random 8k > $tmp/src/x/y/z/random-2
544 WVPASS bup index -u $tmp/src
545 WVPASS bup save -v --graft "$TOP/$tmp/src=$TOP/$tmp/src/a/b/c" \
547 WVPASS bup restore -C $tmp/restore /foo/latest
548 WVPASS t/compare-trees $tmp/src/ "$tmp/restore/latest/$TOP/$tmp/src/a/b/c/"
551 WVSTART "save --graft /x=/ (root target)"
554 export BUP_DIR="$(WVPASS pwd)/$tmp/bup" || exit $?
555 WVPASS force-delete $tmp
558 WVPASS mkdir -p $tmp/src/x/y/z
559 WVPASS bup random 8k > $tmp/src/x/y/random-1
560 WVPASS bup random 8k > $tmp/src/x/y/z/random-2
561 WVPASS bup index -u $tmp/src
562 WVPASS bup save -v --graft "$TOP/$tmp/src/x=/" -n foo $tmp/src/x
563 WVPASS bup restore -C $tmp/restore /foo/latest
564 WVPASS t/compare-trees $tmp/src/x/ "$tmp/restore/latest/"
567 #WVSTART "save --graft /=/x/ (root source)"
568 # FIXME: Not tested for now -- will require cleverness, or caution as root.
572 INDEXFILE=tmpindexfile.tmp
573 WVPASS rm -f $INDEXFILE
574 WVPASS force-delete $D
576 export BUP_DIR="$D/.bup"
581 WVPASS bup index -ux $D
582 WVPASS bup save --strip -n bupdir $D
583 WVPASSEQ "$(bup ls bupdir/latest/)" "a
586 WVPASS bup index -f $INDEXFILE --exclude=$D/c -ux $D
587 WVPASS bup save --strip -n indexfile -f $INDEXFILE $D
588 WVPASSEQ "$(bup ls indexfile/latest/)" "a
592 WVSTART "import-rsnapshot"
594 export BUP_DIR="$TOP/$D/.bup"
595 WVPASS force-delete $D
598 WVPASS mkdir -p $D/hourly.0/buptest/a
599 WVPASS touch $D/hourly.0/buptest/a/b
600 WVPASS mkdir -p $D/hourly.0/buptest/c/d
601 WVPASS touch $D/hourly.0/buptest/c/d/e
603 WVPASS bup import-rsnapshot $D/
604 WVPASSEQ "$(bup ls buptest/latest/)" "a/
608 if [ "$(which rdiff-backup)" != "" ]; then
609 WVSTART "import-rdiff-backup"
611 export BUP_DIR="$TOP/$D/.bup"
612 WVPASS force-delete $D
615 WVPASS mkdir $D/rdiff-backup
616 WVPASS rdiff-backup $TOP/cmd $D/rdiff-backup
618 WVPASS rdiff-backup $TOP/Documentation $D/rdiff-backup
619 WVPASS bup import-rdiff-backup $D/rdiff-backup import-rdiff-backup
620 WVPASSEQ "$(bup ls import-rdiff-backup/ | wc -l)" "3"
621 WVPASSEQ "$(bup ls import-rdiff-backup/latest/ | sort)" "$(ls $TOP/Documentation | sort)"
625 WVSTART "compression"
627 export BUP_DIR="$TOP/$D/.bup"
628 WVPASS force-delete $D
631 WVPASS bup index $TOP/Documentation
632 WVPASS bup save -n compression -0 --strip $TOP/Documentation
633 # 'ls' on NetBSD sets -A by default when running as root, so we have to undo
634 # it by grepping out any dotfiles. (Normal OSes don't auto-set -A, but this
635 # is harmless there.)
636 expected="$(WVPASS ls $TOP/Documentation | grep -v '^\.' | WVPASS sort)" \
638 actual="$(WVPASS bup ls compression/latest/ | WVPASS sort)" || exit $?
639 WVPASSEQ "$actual" "$expected"
640 COMPRESSION_0_SIZE=$(WVPASS du -k -s $D | WVPASS cut -f1) || exit $?
643 export BUP_DIR="$TOP/$D/.bup"
644 WVPASS force-delete $D
647 WVPASS bup index $TOP/Documentation
648 WVPASS bup save -n compression -9 --strip $TOP/Documentation
649 WVPASSEQ "$(bup ls compression/latest/ | sort)" \
650 "$(ls $TOP/Documentation | grep -v '^\.' | sort)"
651 COMPRESSION_9_SIZE=$(WVPASS du -k -s $D | WVPASS cut -f1) || exit $?
653 WVPASS [ "$COMPRESSION_9_SIZE" -lt "$COMPRESSION_0_SIZE" ]
655 WVSTART "save disjoint top-level directories"
657 # Resolve any symlinks involving the top top-level dirs.
658 real_pwd="$(WVPASS realpath .)" || exit $?
659 real_tmp="$(WVPASS realpath /tmp/.)" || exit $?
660 pwd_top="$(echo $real_pwd | WVPASS awk -F "/" '{print $2}')" || exit $?
661 tmp_top="$(echo $real_tmp | WVPASS awk -F "/" '{print $2}')" || exit $?
663 if [ "$pwd_top" = "$tmp_top" ]; then
664 echo "(running from within /$tmp_top; skipping test)" 1>&2
668 WVPASS force-delete $D
671 tmpdir="$(WVPASS mktemp -d $real_tmp/bup-test-XXXXXXX)" || exit $?
672 cleanup() { WVPASS rm -r "${tmpdir}"; }
673 WVPASS trap cleanup EXIT
674 WVPASS date > "$tmpdir/2"
676 export BUP_DIR="$TOP/buptest.tmp"
677 WVPASS test -d "$BUP_DIR" && WVPASS rm -r "$BUP_DIR"
680 WVPASS bup index -vu $(pwd)/$D/x "$tmpdir"
681 WVPASS bup save -t -n src $(pwd)/$D/x "$tmpdir"
683 # For now, assume that "ls -a" and "sort" use the same order.
684 actual="$(WVPASS bup ls -a src/latest)" || exit $?
685 expected="$(echo -e "$pwd_top/\n$tmp_top/" | WVPASS sort)" || exit $?
686 WVPASSEQ "$actual" "$expected"
689 WVSTART "clear-index"
691 export BUP_DIR="$TOP/$D/.bup"
692 WVPASS force-delete $TOP/$D
695 WVPASS touch $TOP/$D/foo
696 WVPASS touch $TOP/$D/bar
697 WVPASS bup index -u $D
698 WVPASSEQ "$(bup index -p)" "$D/foo
702 WVPASS rm $TOP/$D/foo
703 WVPASS bup index --clear
704 WVPASS bup index -u $TOP/$D
705 expected="$(WVPASS bup index -p)" || exit $?
706 WVPASSEQ "$expected" "$D/bar
710 # bup index --exclude-rx ...
712 export BUP_DIR="$TOP/buptest.tmp"
715 WVSTART "index --exclude-rx '^/foo' (root anchor)"
716 WVPASS rm -rf "$D" "$BUP_DIR" buprestore.tmp
723 WVPASS touch $D/sub1/a
724 WVPASS touch $D/sub2/b
725 WVPASS bup index -u $D --exclude-rx "^$(pwd)/$D/sub1/"
726 WVPASS bup save --strip -n bupdir $D
727 WVPASS bup restore -C buprestore.tmp /bupdir/latest/
728 actual="$(WVPASS cd buprestore.tmp; WVPASS find . | WVPASS sort)" || exit $?
729 WVPASSEQ "$actual" ".
735 WVSTART "index --exclude-rx '/foo$' (non-dir, tail anchor)"
736 WVPASS rm -rf "$D" "$BUP_DIR" buprestore.tmp
743 WVPASS mkdir $D/sub/foo
744 WVPASS touch $D/sub/foo/a
745 WVPASS bup index -u $D --exclude-rx '/foo$'
746 WVPASS bup save --strip -n bupdir $D
747 WVPASS bup restore -C buprestore.tmp /bupdir/latest/
748 actual="$(WVPASS cd buprestore.tmp; WVPASS find . | WVPASS sort)" || exit $?
749 WVPASSEQ "$actual" ".
756 WVSTART "index --exclude-rx '/foo/$' (dir, tail anchor)"
757 WVPASS rm -rf "$D" "$BUP_DIR" buprestore.tmp
764 WVPASS mkdir $D/sub/foo
765 WVPASS touch $D/sub/foo/a
766 WVPASS bup index -u $D --exclude-rx '/foo/$'
767 WVPASS bup save --strip -n bupdir $D
768 WVPASS bup restore -C buprestore.tmp /bupdir/latest/
769 actual="$(WVPASS cd buprestore.tmp; WVPASS find . | WVPASS sort)" || exit $?
770 WVPASSEQ "$actual" ".
776 WVSTART "index --exclude-rx '/foo/.' (dir content)"
777 WVPASS rm -rf "$D" "$BUP_DIR" buprestore.tmp
784 WVPASS mkdir $D/sub/foo
785 WVPASS touch $D/sub/foo/a
786 WVPASS bup index -u $D --exclude-rx '/foo/.'
787 WVPASS bup save --strip -n bupdir $D
788 WVPASS bup restore -C buprestore.tmp /bupdir/latest/
789 actual="$(WVPASS cd buprestore.tmp; WVPASS find . | WVPASS sort)" || exit $?
790 WVPASSEQ "$actual" ".
799 # bup restore --exclude-rx ...
801 export BUP_DIR="$TOP/buptest.tmp"
804 WVSTART "restore --exclude-rx '^/foo' (root anchor)"
805 WVPASS rm -rf "$D" "$BUP_DIR" buprestore.tmp
812 WVPASS touch $D/sub1/a
813 WVPASS touch $D/sub2/b
814 WVPASS bup index -u $D
815 WVPASS bup save --strip -n bupdir $D
816 WVPASS bup restore -C buprestore.tmp --exclude-rx "^/sub1/" /bupdir/latest/
817 actual="$(WVPASS cd buprestore.tmp; WVPASS find . | WVPASS sort)" || exit $?
818 WVPASSEQ "$actual" ".
824 WVSTART "restore --exclude-rx '/foo$' (non-dir, tail anchor)"
825 WVPASS rm -rf "$D" "$BUP_DIR" buprestore.tmp
832 WVPASS mkdir $D/sub/foo
833 WVPASS touch $D/sub/foo/a
834 WVPASS bup index -u $D
835 WVPASS bup save --strip -n bupdir $D
836 WVPASS bup restore -C buprestore.tmp --exclude-rx '/foo$' /bupdir/latest/
837 actual="$(WVPASS cd buprestore.tmp; WVPASS find . | WVPASS sort)" || exit $?
838 WVPASSEQ "$actual" ".
845 WVSTART "restore --exclude-rx '/foo/$' (dir, tail anchor)"
846 WVPASS rm -rf "$D" "$BUP_DIR" buprestore.tmp
853 WVPASS mkdir $D/sub/foo
854 WVPASS touch $D/sub/foo/a
855 WVPASS bup index -u $D
856 WVPASS bup save --strip -n bupdir $D
857 WVPASS bup restore -C buprestore.tmp --exclude-rx '/foo/$' /bupdir/latest/
858 actual="$(WVPASS cd buprestore.tmp; WVPASS find . | WVPASS sort)" || exit $?
859 WVPASSEQ "$actual" ".
865 WVSTART "restore --exclude-rx '/foo/.' (dir content)"
866 WVPASS rm -rf "$D" "$BUP_DIR" buprestore.tmp
873 WVPASS mkdir $D/sub/foo
874 WVPASS touch $D/sub/foo/a
875 WVPASS bup index -u $D
876 WVPASS bup save --strip -n bupdir $D
877 WVPASS bup restore -C buprestore.tmp --exclude-rx '/foo/.' /bupdir/latest/
878 actual="$(WVPASS cd buprestore.tmp; WVPASS find . | WVPASS sort)" || exit $?
879 WVPASSEQ "$actual" ".