8 top="$(WVPASS /bin/pwd)" || exit $?
9 tmpdir="$(WVPASS wvmktempdir)" || exit $?
10 export BUP_DIR="$tmpdir/bup"
12 bup() { "$top/bup" "$@"; }
22 WVPASS force-delete $D
24 WVFAIL bup index --exclude-from $D/cannot-exist $D
25 WVPASSEQ "$(bup index --check -p)" ""
26 WVPASSEQ "$(bup index --check -p $D)" ""
28 WVFAIL bup index --check -u $D.fake
29 WVPASS bup index --check -u $D
30 WVPASSEQ "$(bup index --check -p $D)" "$D/"
32 WVPASS bup random 128k >$D/b
33 WVPASS mkdir $D/d $D/d/e
34 WVPASS bup random 512 >$D/f
35 WVPASS ln -s non-existent-file $D/g
36 WVPASSEQ "$(bup index -s $D/)" "A $D/"
37 WVPASSEQ "$(bup index -s $D/b)" ""
38 WVPASSEQ "$(bup index --check -us $D/b)" "A $D/b"
39 WVPASSEQ "$(bup index --check -us $D/b $D/d)" \
45 WVPASSEQ "$(bup index --check -usx $D)" \
54 WVPASSEQ "$(bup index --check -us $D/a $D/b --fake-valid)" \
57 WVPASSEQ "$(bup index --check -us $D/a)" " $D/a" # stays unmodified
58 WVPASSEQ "$(bup index --check -us $D/d --fake-valid)" \
63 WVPASS bup index -u $D/d/z # becomes modified
64 WVPASSEQ "$(bup index -s $D/a $D $D/b)" \
74 WVPASS bup index -u $D/d/e $D/a --fake-invalid
75 WVPASSEQ "$(cd $D && bup index -m .)" \
83 WVPASSEQ "$(cd $D && bup index -m)" \
91 WVPASSEQ "$(cd $D && bup index -s .)" "$(cd $D && bup index -s .)"
93 WVFAIL bup save -t $D/doesnt-exist-filename
95 WVPASS mv "$BUP_DIR/bupindex" "$BUP_DIR/bi.old"
96 WVFAIL bup save -t $D/d/e/fifotest
97 WVPASS mkfifo $D/d/e/fifotest
98 WVPASS bup index -u $D/d/e/fifotest
99 WVPASS bup save -t $D/d/e/fifotest
100 WVPASS bup save -t $D/d/e
101 WVPASS rm -f $D/d/e/fifotest
102 WVPASS bup index -u $D/d/e
103 WVFAIL bup save -t $D/d/e/fifotest
104 WVPASS mv "$BUP_DIR/bi.old" "$BUP_DIR/bupindex"
106 WVPASS bup index -u $D/d/e
107 WVPASS bup save -t $D/d/e
108 WVPASSEQ "$(cd $D && bup index -m)" \
115 WVPASS bup save -t $D/d
116 WVPASS bup index --fake-invalid $D/d/z
117 WVPASS bup save -t $D/d/z
118 WVPASS bup save -t $D/d/z # test regenerating trees when no files are changed
119 WVPASS bup save -t $D/d
120 WVPASSEQ "$(cd $D && bup index -m)" \
125 WVPASS bup save -r ":$BUP_DIR" -n r-test $D
126 WVFAIL bup save -r ":$BUP_DIR/fake/path" -n r-test $D
127 WVFAIL bup save -r ":$BUP_DIR" -n r-test $D/fake/path
132 WVPASS bup split -b a.tmp >taga.tmp
133 WVPASS bup split -b b.tmp >tagb.tmp
134 WVPASS cat a.tmp b.tmp | WVPASS bup split -b >tagab.tmp
135 WVPASSEQ $(cat taga.tmp | wc -l) 1
136 WVPASSEQ $(cat tagb.tmp | wc -l) 1
137 WVPASSEQ $(cat tagab.tmp | wc -l) 1
138 WVPASSEQ $(cat tag[ab].tmp | wc -l) 2
139 WVPASSEQ "$(bup split -b a.tmp b.tmp)" "$(cat tagab.tmp)"
140 WVPASSEQ "$(bup split -b --keep-boundaries a.tmp b.tmp)" "$(cat tag[ab].tmp)"
141 WVPASSEQ "$(cat tag[ab].tmp | bup split -b --keep-boundaries --git-ids)" \
143 WVPASSEQ "$(cat tag[ab].tmp | bup split -b --git-ids)" \
145 WVPASS bup split --bench -b <"$top/t/testfile1" >tags1.tmp
146 WVPASS bup split -vvvv -b "$top/t/testfile2" >tags2.tmp
147 WVPASS echo -n "" | bup split -n split_empty_string.tmp
150 WVPASS bup midx --check -a
151 WVPASS bup midx -o "$BUP_DIR/objects/pack/test1.midx" \
152 "$BUP_DIR"/objects/pack/*.idx
153 WVPASS bup midx --check -a
154 WVPASS bup midx -o "$BUP_DIR"/objects/pack/test1.midx \
155 "$BUP_DIR"/objects/pack/*.idx \
156 "$BUP_DIR"/objects/pack/*.idx
157 WVPASS bup midx --check -a
158 all=$(echo "$BUP_DIR"/objects/pack/*.idx "$BUP_DIR"/objects/pack/*.midx)
159 WVPASS bup midx -o "$BUP_DIR"/objects/pack/zzz.midx $all
161 WVPASS bup midx -o "$BUP_DIR"/objects/pack/yyy.midx $all
163 WVPASSEQ "$(echo "$BUP_DIR"/objects/pack/*.midx)" \
164 ""$BUP_DIR"/objects/pack/yyy.midx"
166 WVPASS bup split -t "$top/t/testfile2" >tags2t.tmp
167 WVPASS bup split -t "$top/t/testfile2" --fanout 3 >tags2tf.tmp
168 WVPASS bup split -r "$BUP_DIR" -c "$top/t/testfile2" >tags2c.tmp
169 WVPASS bup split -r ":$BUP_DIR" -c "$top/t/testfile2" >tags2c.tmp
171 | WVPASS bup split -r ":$BUP_DIR" -c --fanout 3 --max-pack-objects 3 -n lslr \
174 WVFAIL bup ls /does-not-exist
176 WVPASS bup ls /lslr/latest
177 WVPASS bup ls /lslr/latest/
178 #WVPASS bup ls /lslr/1971-01-01 # all dates always exist
179 WVFAIL diff -u tags1.tmp tags2.tmp
181 # fanout must be different from non-fanout
182 WVFAIL diff tags2t.tmp tags2tf.tmp
183 WVPASS wc -c "$top/t/testfile1" "$top/t/testfile2"
184 WVPASS wc -l tags1.tmp tags2.tmp
187 WVPASS bup bloom -c $(ls -1 "$BUP_DIR"/objects/pack/*.idx|head -n1)
188 WVPASS rm "$BUP_DIR"/objects/pack/bup.bloom
189 WVPASS bup bloom -k 4
190 WVPASS bup bloom -c $(ls -1 "$BUP_DIR"/objects/pack/*.idx|head -n1)
191 WVPASS bup bloom -d "$BUP_DIR"/objects/pack --ruin --force
192 WVFAIL bup bloom -c $(ls -1 "$BUP_DIR"/objects/pack/*.idx|head -n1)
193 WVPASS bup bloom --force -k 5
194 WVPASS bup bloom -c $(ls -1 "$BUP_DIR"/objects/pack/*.idx|head -n1)
197 WVPASS bup memtest -c1 -n100
198 WVPASS bup memtest -c1 -n100 --existing
201 WVPASS bup join $(cat tags1.tmp) >out1.tmp
202 WVPASS bup join <tags2.tmp >out2.tmp
203 WVPASS bup join <tags2t.tmp -o out2t.tmp
204 WVPASS bup join -r "$BUP_DIR" <tags2c.tmp >out2c.tmp
205 WVPASS bup join -r ":$BUP_DIR" <tags2c.tmp >out2c.tmp
206 WVPASS diff -u "$top/t/testfile1" out1.tmp
207 WVPASS diff -u "$top/t/testfile2" out2.tmp
208 WVPASS diff -u "$top/t/testfile2" out2t.tmp
209 WVPASS diff -u "$top/t/testfile2" out2c.tmp
210 WVPASSEQ "$(bup join split_empty_string.tmp)" ""
212 WVSTART "save/git-fsck"
217 (WVPASS cd "$top/t/sampledata" && WVPASS bup save -vvn master /) || exit $?
218 result="$(git fsck --full --strict 2>&1)" || exit $?
220 WVFAIL egrep -v 'dangling (commit|tree|blob)' |
221 WVPASS tee -a /dev/stderr |
222 WVPASS wc -l) || exit $?
223 WVPASS [ "$n" -eq 0 ]
227 WVPASS force-delete buprestore.tmp
228 WVFAIL bup restore boink
229 WVPASS touch "$tmpdir/$D/$D"
230 WVPASS bup index -u "$tmpdir/$D"
231 WVPASS bup save -n master /
232 WVPASS bup restore -C buprestore.tmp "/master/latest/$tmpdir/$D"
233 WVPASSEQ "$(ls buprestore.tmp)" "bupdata.tmp"
234 WVPASS force-delete buprestore.tmp
235 WVPASS bup restore -C buprestore.tmp "/master/latest/$tmpdir/$D/"
236 WVPASS touch $D/non-existent-file buprestore.tmp/non-existent-file # else diff fails
237 WVPASS diff -ur $D/ buprestore.tmp/
238 WVPASS force-delete buprestore.tmp
239 WVPASS bup restore -C buprestore.tmp split_empty_string.tmp/latest/
240 WVPASSEQ "$(cat buprestore.tmp/data)" ""
244 WVPASS force-delete $tmp
246 export BUP_DIR="$(pwd)/$tmp/bup"
247 WVPASS WVPASS bup init
248 WVPASS 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 "$top/t/compare-trees" $tmp/src/ $tmp/restore/latest/
258 WVSTART "restore /foo/latest/"
259 WVPASS force-delete "$tmp/restore"
260 WVPASS bup restore -C $tmp/restore /foo/latest/
261 for x in $tmp/src/*; do
262 WVPASS "$top/t/compare-trees" $x/ $tmp/restore/$(basename $x);
265 WVSTART "restore /foo/latest/."
266 WVPASS force-delete "$tmp/restore"
267 WVPASS bup restore -C $tmp/restore /foo/latest/.
268 WVPASS "$top/t/compare-trees" $tmp/src/ $tmp/restore/
270 WVSTART "restore /foo/latest/x"
271 WVPASS force-delete "$tmp/restore"
272 WVPASS bup restore -C $tmp/restore /foo/latest/x
273 WVPASS "$top/t/compare-trees" $tmp/src/x/ $tmp/restore/x/
275 WVSTART "restore /foo/latest/x/"
276 WVPASS force-delete "$tmp/restore"
277 WVPASS bup restore -C $tmp/restore /foo/latest/x/
278 for x in $tmp/src/x/*; do
279 WVPASS "$top/t/compare-trees" $x/ $tmp/restore/$(basename $x);
282 WVSTART "restore /foo/latest/x/."
283 WVPASS force-delete "$tmp/restore"
284 WVPASS bup restore -C $tmp/restore /foo/latest/x/.
285 WVPASS "$top/t/compare-trees" $tmp/src/x/ $tmp/restore/
290 WVPASS bup ftp "cat /master/latest/$tmpdir/$D/b" >$D/b.new
291 WVPASS bup ftp "cat /master/latest/$tmpdir/$D/f" >$D/f.new
292 WVPASS bup ftp "cat /master/latest/$tmpdir/$D/f"{,} >$D/f2.new
293 WVPASS bup ftp "cat /master/latest/$tmpdir/$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 WVFAIL bup tag v0.1 master
306 WVPASS bup tag -f v0.1 master
307 WVPASS bup tag -d v0.1
308 WVPASS bup tag -f -d v0.1
309 WVFAIL bup tag -d v0.1
312 WVSTART "save (no index)"
314 tmp=save-no-index.tmp
315 WVPASS force-delete $tmp
317 export BUP_DIR="$(WVPASS pwd)/$tmp/bup" || exit $?
319 WVFAIL bup save -n nothing /
325 INDEXFILE=tmpindexfile.tmp
326 WVPASS rm -f $INDEXFILE
327 WVPASS force-delete $D
329 export BUP_DIR="$D/.bup"
334 WVPASS bup index -ux $D
335 WVPASS bup save --strip -n bupdir $D
336 WVPASSEQ "$(bup ls -F bupdir/latest/)" "a
339 WVPASS bup index -f $INDEXFILE --exclude=$D/c -ux $D
340 WVPASS bup save --strip -n indexfile -f $INDEXFILE $D
341 WVPASSEQ "$(bup ls indexfile/latest/)" "a
345 WVSTART "import-rsnapshot"
347 export BUP_DIR="$tmpdir/$D/.bup"
348 WVPASS force-delete $D
351 WVPASS mkdir -p $D/hourly.0/buptest/a
352 WVPASS touch $D/hourly.0/buptest/a/b
353 WVPASS mkdir -p $D/hourly.0/buptest/c/d
354 WVPASS touch $D/hourly.0/buptest/c/d/e
356 WVPASS bup import-rsnapshot $D/
357 WVPASSEQ "$(bup ls -F buptest/latest/)" "a/
361 WVSTART "save disjoint top-level directories"
363 # Resolve any symlinks involving the top top-level dirs.
364 real_pwd="$(WVPASS realpath .)" || exit $?
365 real_tmp="$(WVPASS realpath /tmp/.)" || exit $?
366 pwd_top="$(echo $real_pwd | WVPASS awk -F "/" '{print $2}')" || exit $?
367 tmp_top="$(echo $real_tmp | WVPASS awk -F "/" '{print $2}')" || exit $?
369 if [ "$pwd_top" = "$tmp_top" ]; then
370 echo "(running from within /$tmp_top; skipping test)" 1>&2
374 WVPASS force-delete $D
377 tmpdir2="$(WVPASS mktemp -d $real_tmp/bup-test-XXXXXXX)" || exit $?
378 cleanup() { WVPASS rm -r "$tmpdir2"; }
379 WVPASS trap cleanup EXIT
380 WVPASS date > "$tmpdir2/2"
382 export BUP_DIR="$tmpdir/bup"
383 WVPASS test -d "$BUP_DIR" && WVPASS rm -r "$BUP_DIR"
386 WVPASS bup index -vu $(pwd)/$D/x "$tmpdir2"
387 WVPASS bup save -t -n src $(pwd)/$D/x "$tmpdir2"
389 # For now, assume that "ls -a" and "sort" use the same order.
390 actual="$(WVPASS bup ls -AF src/latest)" || exit $?
391 expected="$(echo -e "$pwd_top/\n$tmp_top/" | WVPASS sort)" || exit $?
392 WVPASSEQ "$actual" "$expected"
395 WVPASS rm -rf "$tmpdir"