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/
242 WVPASS bup ftp "cat /master/latest/$TOP/$D/b" >$D/b.new
243 WVPASS bup ftp "cat /master/latest/$TOP/$D/f" >$D/f.new
244 WVPASS bup ftp "cat /master/latest/$TOP/$D/f"{,} >$D/f2.new
245 WVPASS bup ftp "cat /master/latest/$TOP/$D/a" >$D/a.new
246 WVPASSEQ "$(sha1sum <$D/b)" "$(sha1sum <$D/b.new)"
247 WVPASSEQ "$(sha1sum <$D/f)" "$(sha1sum <$D/f.new)"
248 WVPASSEQ "$(cat $D/f.new{,} | sha1sum)" "$(sha1sum <$D/f2.new)"
249 WVPASSEQ "$(sha1sum <$D/a)" "$(sha1sum <$D/a.new)"
252 WVFAIL bup tag -d v0.n 2>/dev/null
253 WVFAIL bup tag v0.n non-existant 2>/dev/null
254 WVPASSEQ "$(bup tag)" ""
255 WVPASS bup tag v0.1 master
256 WVPASSEQ "$(bup tag)" "v0.1"
257 WVPASS bup tag -d v0.1
259 # This section destroys data in the bup repository, so it is done last.
262 WVPASS bup fsck --quick
263 if bup fsck --par2-ok; then
264 WVSTART "fsck (par2)"
266 WVSTART "fsck (PAR2 IS MISSING)"
270 WVPASS bup damage $BUP_DIR/objects/pack/*.pack -n10 -s1 -S0
271 WVFAIL bup fsck --quick
272 WVFAIL bup fsck --quick --disable-par2
273 chmod u+w $BUP_DIR/objects/pack/*.idx
274 WVPASS bup damage $BUP_DIR/objects/pack/*.idx -n10 -s1 -S0
275 WVFAIL bup fsck --quick -j4
276 WVPASS bup damage $BUP_DIR/objects/pack/*.pack -n10 -s1024 --percent 0.4 -S0
277 WVFAIL bup fsck --quick
278 WVFAIL bup fsck --quick -rvv -j99 # fails because repairs were needed
279 if bup fsck --par2-ok; then
280 WVPASS bup fsck -r # ok because of repairs from last time
281 WVPASS bup damage $BUP_DIR/objects/pack/*.pack -n202 -s1 --equal -S0
283 WVFAIL bup fsck -rvv # too many errors to be repairable
284 WVFAIL bup fsck -r # too many errors to be repairable
286 WVFAIL bup fsck --quick -r # still fails because par2 was missing
289 WVSTART "exclude-bupdir"
293 export BUP_DIR="$D/.bup"
296 WVPASS bup random 128k >$D/b
298 WVPASS bup random 512 >$D/f
299 WVPASS bup index -ux $D
300 bup save -n exclude-bupdir $D
301 WVPASSEQ "$(bup ls -a exclude-bupdir/latest/$TOP/$D/)" "a
310 export BUP_DIR="$D/.bup"
313 WVPASS bup random 128k >$D/b
315 WVPASS bup random 512 >$D/f
316 WVPASS bup index -ux --exclude $D/d $D
317 bup save -n exclude $D
318 WVPASSEQ "$(bup ls exclude/latest/$TOP/$D/)" "a
322 WVPASS bup index -ux --exclude $D/d --exclude $TOP/$D/g --exclude $D/h $D
323 bup save -n exclude $D
324 WVPASSEQ "$(bup ls exclude/latest/$TOP/$D/)" "a
328 WVSTART "exclude-from"
329 D=exclude-fromdir.tmp
330 EXCLUDE_FILE=exclude-from.tmp
333 $D/h" > $EXCLUDE_FILE
336 export BUP_DIR="$D/.bup"
339 WVPASS bup random 128k >$D/b
341 WVPASS bup random 512 >$D/f
343 WVPASS bup index -ux --exclude-from $EXCLUDE_FILE $D
344 bup save -n exclude-from $D
345 WVPASSEQ "$(bup ls exclude-from/latest/$TOP/$D/)" "a
354 export BUP_DIR="$D/.bup"
357 WVPASS bup random 128k >$D/b
359 WVPASS bup random 512 >$D/f
360 WVPASS bup index -ux $D
361 bup save --strip -n strip $D
362 WVPASSEQ "$(bup ls strip/latest/)" "a
371 export BUP_DIR="$D/.bup"
374 WVPASS bup random 128k >$D/b
376 WVPASS bup random 512 >$D/f
377 WVPASS bup index -ux $D
378 bup save --strip-path $TOP -n strip-path $D
379 WVPASSEQ "$(bup ls strip-path/latest/$D/)" "a
384 WVSTART "graft_points"
388 export BUP_DIR="$D/.bup"
391 WVPASS bup random 128k >$D/b
393 WVPASS bup random 512 >$D/f
394 WVPASS bup index -ux $D
395 WVFAIL bup save --graft =/grafted -n graft-point-absolute $D
396 WVFAIL bup save --graft $TOP/$D= -n graft-point-absolute $D
397 bup save --graft $TOP/$D=/grafted -n graft-point-absolute $D
398 WVPASSEQ "$(bup ls graft-point-absolute/latest/grafted/)" "a
402 bup save --graft $D=grafted -n graft-point-relative $D
403 WVPASSEQ "$(bup ls graft-point-relative/latest/$TOP/grafted/)" "a
410 INDEXFILE=tmpindexfile.tmp
414 export BUP_DIR="$D/.bup"
419 WVPASS bup index -ux $D
420 bup save --strip -n bupdir $D
421 WVPASSEQ "$(bup ls bupdir/latest/)" "a
424 WVPASS bup index -f $INDEXFILE --exclude=$D/c -ux $D
425 bup save --strip -n indexfile -f $INDEXFILE $D
426 WVPASSEQ "$(bup ls indexfile/latest/)" "a
430 WVSTART "import-rsnapshot"
432 export BUP_DIR="$TOP/$D/.bup"
436 mkdir -p $D/hourly.0/buptest/a
437 touch $D/hourly.0/buptest/a/b
438 mkdir -p $D/hourly.0/buptest/c/d
439 touch $D/hourly.0/buptest/c/d/e
441 WVPASS bup import-rsnapshot $D/
442 WVPASSEQ "$(bup ls buptest/latest/)" "a/
446 if [ "$(which rdiff-backup)" != "" ]; then
447 WVSTART "import-rdiff-backup"
449 export BUP_DIR="$TOP/$D/.bup"
453 mkdir $D/rdiff-backup
454 rdiff-backup $TOP/cmd $D/rdiff-backup
456 rdiff-backup $TOP/Documentation $D/rdiff-backup
457 WVPASS bup import-rdiff-backup $D/rdiff-backup import-rdiff-backup
458 WVPASSEQ "$(bup ls import-rdiff-backup/ | wc -l)" "3"
459 WVPASSEQ "$(bup ls import-rdiff-backup/latest/ | sort)" "$(ls $TOP/Documentation | sort)"
463 WVSTART "compression"
465 export BUP_DIR="$TOP/$D/.bup"
469 WVPASS bup index $TOP/Documentation
470 WVPASS bup save -n compression -0 --strip $TOP/Documentation
471 # 'ls' on NetBSD sets -A by default when running as root, so we have to undo
472 # it by grepping out any dotfiles. (Normal OSes don't auto-set -A, but this
473 # is harmless there.)
474 WVPASSEQ "$(bup ls compression/latest/ | sort)" \
475 "$(ls $TOP/Documentation | grep -v '^\.' | sort)"
476 COMPRESSION_0_SIZE=$(du -s $D | cut -f1)
479 export BUP_DIR="$TOP/$D/.bup"
483 WVPASS bup index $TOP/Documentation
484 WVPASS bup save -n compression -9 --strip $TOP/Documentation
485 WVPASSEQ "$(bup ls compression/latest/ | sort)" "$(ls $TOP/Documentation | sort)"
486 COMPRESSION_9_SIZE=$(du -s $D | cut -f1)
488 WVPASS [ "$COMPRESSION_9_SIZE" -lt "$COMPRESSION_0_SIZE" ]
491 WVSTART "save disjoint top-level directories"
494 top_dir="$(echo $(pwd) | awk -F "/" '{print $2}')"
495 if [ "$top_dir" == tmp ]; then
496 echo "(running from within /tmp; skipping test)"
503 tmpdir="$(mktemp --tmpdir=/tmp -d bup-test-XXXXXXX)"
504 cleanup() { set -x; rm -rf "${tmpdir}"; set +x; }
508 export BUP_DIR="$TOP/buptest.tmp"
512 WVPASS bup index -vu $(pwd)/$D/x "$tmpdir"
513 WVPASS bup save -t -n src $(pwd)/$D/x "$tmpdir"
514 WVPASSEQ "$(bup ls -a src/latest)" \