Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Move tree comparison to t/compare-trees; compare content by default.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Reviewed-by: Zoran Zaric <zz@zoranzaric.de>
  • Loading branch information...
commit 637bf18323c031f97883bd83fbdb9c8a8228f65d 1 parent 7ccf0a9
@rlbdv rlbdv authored
Showing with 59 additions and 20 deletions.
  1. +2 −2 README.md
  2. +55 −0 t/compare-trees
  3. +2 −18 t/test-meta.sh
View
4 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
View
55 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 <<EOF
+Usage: compare-trees [-h] [-c] [-x] SOURCE DEST
+OPTIONS:
+ -h
+ Display help
+ -c
+ Check file content (default)
+ -x
+ Don't check file content (rely on size/timestamps, etc.)
+EOF
+}
+
+verify_content=" --checksum"
+
+while getopts "hc" OPTION
+do
+ case "$OPTION" in
+ h) usage; exit 0;;
+ c) verify_content=" --checksum";;
+ x) verify_content="";;
+ ?) usage 1>&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
View
20 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.
#
Please sign in to comment.
Something went wrong with that request. Please try again.