Fix xattrs test on OS X.
[rsync/rsync.git] / testsuite / rsync.fns
index 1983877..ca05297 100644 (file)
@@ -26,6 +26,7 @@ chkdir="$tmpdir/chk"
 all_plus='+++++++++'
 allspace='         '
 dots='.....' # trailing dots after changes
+tab_ch='       ' # a single tab character
 
 # Berkley's nice.
 PATH="$PATH:/usr/ucb"
@@ -99,6 +100,10 @@ rsync_ls_lR() {
     find "$@" -print | sort | sed 's/ /\\ /g' | xargs "$TOOLDIR/tls" $TLS_ARGS
 }
 
+get_testuid() {
+    id 2>/dev/null | sed 's/^[^0-9]*\([0-9][0-9]*\).*/\1/'
+}
+
 check_perms() {
     perms=`"$TOOLDIR/tls" "$1" | sed 's/^[-d]\(.........\).*/\1/'`
     if test $perms = $2; then
@@ -218,7 +223,7 @@ checkit() {
     eval "$1" 
     status=$?
     if [ $status != 0 ]; then
-       failed="YES";
+       failed="$failed status=$status"
     fi
 
     echo "-------------"
@@ -226,7 +231,7 @@ checkit() {
     echo ""
     ( cd "$2" && rsync_ls_lR . ) > "$tmpdir/ls-from"
     ( cd "$3" && rsync_ls_lR . ) > "$tmpdir/ls-to"
-    diff $diffopt "$tmpdir/ls-from" "$tmpdir/ls-to" || failed=YES
+    diff $diffopt "$tmpdir/ls-from" "$tmpdir/ls-to" || failed="$failed dir-diff"
 
     echo "-------------"
     echo "check how the files compare with diff:"
@@ -234,15 +239,16 @@ checkit() {
     if [ "x$4" != x ]; then
        echo "  === Skipping (as directed) ==="
     else
-       diff -r $diffopt "$2" "$3" || failed=YES
+       diff -r $diffopt "$2" "$3" || failed="$failed file-diff"
     fi
 
     echo "-------------"
     if [ -z "$failed" ] ; then
        return 0
-    else
-       return 1
     fi
+
+    echo "Failed: $failed"
+    return 1
 }
 
 
@@ -256,6 +262,17 @@ build_rsyncd_conf() {
     logfile="$scratchdir/rsyncd.log"
     hostname=`uname -n`
 
+    uid_setting='uid = 0'
+    gid_setting='gid = 0'
+    case `get_testuid` in
+    0) ;;
+    *)
+       # Non-root cannot specify uid & gid settings
+       uid_setting="#$uid_setting"
+       gid_setting="#$gid_setting"
+       ;;
+    esac
+
     cat >"$conf" <<EOF
 # rsyncd configuration file autogenerated by $0
 
@@ -268,8 +285,8 @@ log format = %i %h [%a] %m (%u) %l %f%L
 transfer logging = yes
 exclude = ? foobar.baz
 max verbosity = 4
-#uid = 0
-#gid = 0
+$uid_setting
+$gid_setting
 
 [test-from]
        path = $fromdir