From: Rob Browning Date: Sat, 4 Aug 2012 21:58:45 +0000 (-0500) Subject: Move tree comparison to t/compare-trees; compare content by default. X-Git-Tag: bup-0.25-rc2~79 X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=bup.git;a=commitdiff_plain;h=637bf18323c031f97883bd83fbdb9c8a8228f65d Move tree comparison to t/compare-trees; compare content by default. Signed-off-by: Rob Browning Reviewed-by: Zoran Zaric --- diff --git a/README.md b/README.md index cec2b4c..cac883c 100644 --- a/README.md +++ b/README.md @@ -327,8 +327,8 @@ mailing list (see below) if you'd like to help. On the plus side, they actually do have support now, but it's new, and not remotely as well tested as tar/rsync/whatever's. If you'd - like to help test, please do; something like 'rsync -niaHAX src/ - restore/' may be useful on that front. + like to help test, please do (see t/compare-trees for one + comparison method). In addition, at the moment, if any strip or graft-style options are specified to 'bup save', then no metadata will be written for diff --git a/t/compare-trees b/t/compare-trees new file mode 100755 index 0000000..b7fd28e --- /dev/null +++ b/t/compare-trees @@ -0,0 +1,55 @@ +#!/usr/bin/env bash + +# Test that src and dest trees are as identical as bup is capable of +# making them. For now, use rsync -niaHAX ... + +set -e +set -o pipefail + +usage() { +cat <&2; exit 1;; + esac +done + +shift $(($OPTIND - 1)) + +if ! test $# -eq 2 +then + usage 1>&2 + exit 1 +fi + +src="$1" +dest="$2" + +tmpfile="$(mktemp)" +trap "rm -rf '${tmpfile}'" EXIT + +rsync -niaHAX$verify_content --delete "$src" "$dest" > "${tmpfile}" +if test $(wc -l < "${tmpfile}") != 0; then + echo "Differences between $src and $dest" + cat "${tmpfile}" + exit 1 +fi + +exit 0 diff --git a/t/test-meta.sh b/t/test-meta.sh index 800a3cb..b9c507f 100755 --- a/t/test-meta.sh +++ b/t/test-meta.sh @@ -49,22 +49,6 @@ force-delete() fi } -compare-trees() -{ - ( - set -e - set -o pipefail - tmpfile="$(mktemp)" - trap "rm -rf '${tmpfile}'" EXIT - rsync -ni -aHAX "$1" "$2" > "${tmpfile}" - if test $(wc -l < "${tmpfile}") != 0; then - echo "ERROR: detected differences between $1 and $2" - cat "${tmpfile}" - false - fi - ) -} - test-src-create-extract() { # Test bup meta create/extract for ./src -> ./src-restore. @@ -109,7 +93,7 @@ test-src-save-restore() mkdir src-restore WVPASS bup restore -C src-restore "/src/latest$(pwd)/" WVPASS test -d src-restore/src - WVPASS compare-trees src/ src-restore/src/ + WVPASS "$TOP/t/compare-trees" -c src/ src-restore/src/ rm -rf src.bup set +x ) @@ -215,7 +199,7 @@ WVSTART 'metadata save/restore (hardlinks)' WVPASS bup index src WVPASS bup save -t -n src src hardlink-test-run-restore - WVPASS compare-trees src/ src-restore/src/ + WVPASS "$TOP/t/compare-trees" -c src/ src-restore/src/ # Test hardlink changes between index runs. #