X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=t%2Ftest-gc.sh;h=2739ae78ef9e6571d6e6be964063ddebb37b1a4e;hb=ea0cb087050dc86bae886c0b2605b83aa819b7d3;hp=0119f467048f54b58161ebef61055bb59858e851;hpb=f5edecf2297433cd319dcc29e8dcf12f3c2f3b08;p=bup.git diff --git a/t/test-gc.sh b/t/test-gc.sh index 0119f46..2739ae7 100755 --- a/t/test-gc.sh +++ b/t/test-gc.sh @@ -175,4 +175,67 @@ WVPASS bup restore -C "$tmpdir/restore" /src-ab/latest WVPASS compare-trees src-ab/ "$tmpdir/restore/latest/" +WVSTART "gc (threshold)" + +WVPASS rm -rf "$BUP_DIR" +WVPASS bup init +WVPASS rm -rf src && mkdir src +WVPASS echo 0 > src/0 +WVPASS echo 1 > src/1 + +WVPASS bup index src +WVPASS bup save -n src-1 src +WVPASS rm src/0 +WVPASS bup index src +WVPASS bup save -n src-2 src + +WVPASS bup rm --unsafe src-1 +packs_before="$(ls "$BUP_DIR/objects/pack/"*.pack)" || exit $? +WVPASS bup gc -v $GC_OPTS --threshold 99 2>&1 | tee gc.log +packs_after="$(ls "$BUP_DIR/objects/pack/"*.pack)" || exit $? +WVPASSEQ 0 "$(grep -cE '^rewriting ' gc.log)" +WVPASSEQ "$packs_before" "$packs_after" + +WVPASS bup gc -v $GC_OPTS --threshold 1 2>&1 | tee gc.log +packs_after="$(ls "$BUP_DIR/objects/pack/"*.pack)" || exit $? +WVPASSEQ 1 "$(grep -cE '^rewriting ' gc.log)" + +# Check that only one pack was rewritten + +# Accommodate some systems that apparently used to change the default +# ls sort order which must match LC_COLLATE for comm to work. +packs_before="$(sort <(echo "$packs_before"))" || die $? +packs_after="$(sort <(echo "$packs_after"))" || die $? + +only_in_before="$(comm -2 -3 <(echo "$packs_before") <(echo "$packs_after"))" \ + || die $? + +only_in_after="$(comm -1 -3 <(echo "$packs_before") <(echo "$packs_after"))" \ + || die $? + +in_both="$(comm -1 -2 <(echo "$packs_before") <(echo "$packs_after"))" || die $? + +WVPASSEQ 1 $(echo "$only_in_before" | wc -l) +WVPASSEQ 1 $(echo "$only_in_after" | wc -l) +WVPASSEQ 1 $(echo "$in_both" | wc -l) + +WVSTART "gc (threshold 0)" + +WVPASS rm -rf "$BUP_DIR" +WVPASS bup init +WVPASS rm -rf src && mkdir src +WVPASS echo 0 > src/0 +WVPASS echo 1 > src/1 + +WVPASS bup index src +WVPASS bup save -n src-1 src + +packs_before="$(ls "$BUP_DIR/objects/pack/"*.pack)" || exit $? +WVPASS bup gc -v $GC_OPTS --threshold 0 2>&1 | tee gc.log +packs_after="$(ls "$BUP_DIR/objects/pack/"*.pack)" || exit $? +# Check that the pack was rewritten, but not removed (since the +# result-pack is equal to the source pack) +WVPASSEQ 1 "$(grep -cE '^rewriting ' gc.log)" +WVPASSEQ "$packs_before" "$packs_after" + WVPASS rm -rf "$tmpdir"