]> arthur.barton.de Git - bup.git/commitdiff
Move tree comparison to t/compare-trees; compare content by default.
authorRob Browning <rlb@defaultvalue.org>
Sat, 4 Aug 2012 21:58:45 +0000 (16:58 -0500)
committerRob Browning <rlb@defaultvalue.org>
Sun, 27 Jan 2013 22:29:33 +0000 (16:29 -0600)
Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Reviewed-by: Zoran Zaric <zz@zoranzaric.de>
README.md
t/compare-trees [new file with mode: 0755]
t/test-meta.sh

index cec2b4cbe4f65a675f293817c2f1b305a26b40aa..cac883c3dd7f00b01997d7adf1ce9eabb1282bd4 100644 (file)
--- 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 (executable)
index 0000000..b7fd28e
--- /dev/null
@@ -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
index 800a3cbd10ecbeb9ce5832e19b709599c0cde4f6..b9c507f4a1404814df752f7daa9508a641c18b68 100755 (executable)
@@ -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.
     #