]> arthur.barton.de Git - bup.git/blob - t/compare-trees
Don't check ACLs in t/compare-trees on NetBSD.
[bup.git] / t / compare-trees
1 #!/usr/bin/env bash
2
3 # Test that src and dest trees are as identical as bup is capable of
4 # making them.  For now, use rsync -niaHAX ...
5
6 usage() {
7 cat <<EOF
8 Usage: compare-trees [-h] [-c] [-x] SOURCE DEST
9 OPTIONS:
10   -h
11     Display help
12   -c
13     Check file content (default)
14   -x
15     Don't check file content (rely on size/timestamps, etc.)
16 EOF
17 }
18
19 verify_content=" --checksum"
20
21 while getopts "hcx" OPTION
22 do
23     case "$OPTION" in
24         h) usage; exit 0;;
25         c) verify_content=" --checksum";;
26         x) verify_content="";;
27         ?) usage 1>&2; exit 1;;
28     esac
29 done
30
31 shift $(($OPTIND - 1)) || exit $?
32
33 if ! test $# -eq 2
34 then
35     usage 1>&2
36     exit 1
37 fi
38
39 src="$1"
40 dest="$2"
41
42 tmpfile="$(mktemp /tmp/bup-test-XXXXXXX)" || exit $?
43 trap "rm -rf '$tmpfile'" EXIT || exit $?
44
45 rsync_opts="-niaH$verify_content --delete"
46
47 rsync_version=$(rsync --version)
48 if [[ ! "$rsync_version" =~ "ACLs" ]] || [[ "$rsync_version" =~ "no ACLs" ]]; then
49     echo "Not comparing ACLs (not supported by available rsync)" 1>&2
50 else
51     case $OSTYPE in
52         cygwin|darwin|netbsd)
53             echo "Not comparing ACLs (not yet supported on $OSTYPE)" 1>&2
54             ;;
55         *)
56             rsync_opts="$rsync_opts -A"
57             ;;
58     esac
59 fi
60
61 if [[ ! "$rsync_version" =~ "xattrs" ]] || [[ "$rsync_version" =~ "no xattrs" ]]; then
62     echo "Not comparing xattrs (not supported by available rsync)" 1>&2
63 else
64     rsync_opts="$rsync_opts -X"
65 fi
66
67 rsync $rsync_opts "$src" "$dest" > "$tmpfile" || exit $?
68
69 if test $(wc -l < "$tmpfile") != 0; then
70     echo "Differences between $src and $dest"
71     cat "$tmpfile"
72     exit 1
73 fi
74
75 exit 0