]> git.ipfire.org Git - thirdparty/rsync.git/commitdiff
Check status of tests that pipe rsync's output & simplify output diffing.
authorWayne Davison <wayne@opencoder.net>
Mon, 21 Sep 2020 20:15:43 +0000 (13:15 -0700)
committerWayne Davison <wayne@opencoder.net>
Mon, 21 Sep 2020 20:32:41 +0000 (13:32 -0700)
testsuite/backup.test
testsuite/daemon.test
testsuite/devices.test
testsuite/duplicates.test
testsuite/exclude.test
testsuite/hardlinks.test
testsuite/itemize.test
testsuite/relative.test
testsuite/rsync.fns

index 87db33e5b6da4d4d1fbe50ecfd3685ded5d18a3a..3b49db94af08d017e505f69bbb677b26ae108dc8 100644 (file)
@@ -15,8 +15,6 @@ makepath "$fromdir/deep" "$bakdir/dname"
 name1="$fromdir/deep/name1"
 name2="$fromdir/deep/name2"
 
-outfile="$scratchdir/rsync.out"
-
 cat "$srcdir"/[gr]*.[ch] > "$name1"
 cat "$srcdir"/[et]*.[ch] > "$name2"
 
@@ -26,8 +24,7 @@ checkit "$RSYNC -ai --info=backup '$fromdir/' '$chkdir/'" "$fromdir" "$chkdir"
 cat "$srcdir"/[fgpr]*.[ch] > "$name1"
 cat "$srcdir"/[etw]*.[ch] > "$name2"
 
-$RSYNC -ai --info=backup --no-whole-file --backup "$fromdir/" "$todir/" \
-    | tee "$outfile"
+checktee "$RSYNC -ai --info=backup --no-whole-file --backup '$fromdir/' '$todir/'"
 for fn in deep/name1 deep/name2; do
     grep "backed up $fn to $fn~" "$outfile" >/dev/null || test_fail "no backup message output for $fn"
     diff $diffopt "$fromdir/$fn" "$todir/$fn" || test_fail "copy of $fn failed"
index 836ce33be69587d28816669bd581677a6a5bc832..80d2baf656894a375912622aeec727266a6297b5 100644 (file)
@@ -21,9 +21,6 @@
 
 . "$suitedir/rsync.fns"
 
-chkfile="$scratchdir/rsync.chk"
-outfile="$scratchdir/rsync.out"
-
 SSH="src/support/lsh.sh --no-cd"
 FILE_REPL='s/^\([^d][^ ]*\) *\(..........[0-9]\) /\1 \2 /'
 DIR_REPL='s/^\(d[^ ]*\)  *[0-9][.,0-9]* /\1         DIR /'
@@ -57,21 +54,17 @@ test-to             r/w
 test-scratch           NOCOMMENT
 EOT
 
-$RSYNC -ve "$SSH" --rsync-path="$RSYNC$confopt" localhost:: | tee "$outfile"
+checkdiff2 "$RSYNC -ve '$SSH' --rsync-path='$RSYNC$confopt' localhost::"
 echo '===='
-diff $diffopt "$chkfile" "$outfile" || test_fail "test 0 failed"
 
 RSYNC_CONNECT_PROG="$RSYNC --config=$conf --daemon"
 export RSYNC_CONNECT_PROG
 
-$RSYNC -v localhost:: | tee "$outfile"
+checkdiff2 "$RSYNC -v localhost::"
 echo '===='
-diff $diffopt "$chkfile" "$outfile" || test_fail "test 1 failed"
 
-$RSYNC -r localhost::test-hidden \
-    | sed "$FILE_REPL" | sed "$DIR_REPL" | sed "$LS_REPL" \
-    | tee "$outfile"
-cat <<EOT >"$chkfile"
+checkdiff "$RSYNC -r localhost::test-hidden" \
+       "sed -e '$FILE_REPL' -e '$DIR_REPL' -e '$LS_REPL'" <<EOT
 drwxr-xr-x         DIR ####/##/## ##:##:## .
 drwxr-xr-x         DIR ####/##/## ##:##:## bar
 -rw-r--r--           4 ####/##/## ##:##:## bar/two
@@ -80,24 +73,18 @@ drwxr-xr-x         DIR ####/##/## ##:##:## bar/baz
 drwxr-xr-x         DIR ####/##/## ##:##:## foo
 -rw-r--r--           4 ####/##/## ##:##:## foo/one
 EOT
-diff $diffopt "$chkfile" "$outfile" || test_fail "test 2 failed"
 
-$RSYNC -r localhost::test-from/f* \
-    | sed "$FILE_REPL" | sed "$DIR_REPL" | sed "$LS_REPL" \
-    | tee "$outfile"
-cat <<EOT >"$chkfile"
+checkdiff "$RSYNC -r localhost::test-from/f*" \
+       "sed -e '$FILE_REPL' -e '$DIR_REPL' -e '$LS_REPL'" <<EOT
 drwxr-xr-x         DIR ####/##/## ##:##:## foo
 -rw-r--r--           4 ####/##/## ##:##:## foo/one
 EOT
 diff $diffopt "$chkfile" "$outfile" || test_fail "test 3 failed"
 
 if $RSYNC --version | grep "[, ] atimes" >/dev/null; then
-    $RSYNC -rU localhost::test-from/f* \
-       | sed "$FILE_REPL" | sed "$DIR_REPL" | sed "$LS_REPL" \
-       | tee "$outfile"
-    cat <<EOT >"$chkfile"
+    checkdiff "$RSYNC -rU localhost::test-from/f*" \
+       "sed -e '$FILE_REPL' -e '$DIR_REPL' -e '$LS_REPL'" <<EOT
 drwxr-xr-x         DIR ####/##/## ##:##:##                     foo
 -rw-r--r--           4 ####/##/## ##:##:## ####/##/## ##:##:## foo/one
 EOT
-    diff $diffopt "$chkfile" "$outfile" || test_fail "test 3 failed"
 fi
index 56ab2c521fcd1f1ab2e3d616a6037f2d55fb167c..79dfdf178125d6de10fc51203ec1725e752509fe 100644 (file)
@@ -9,9 +9,6 @@
 
 . "$suitedir/rsync.fns"
 
-chkfile="$scratchdir/rsync.chk"
-outfile="$scratchdir/rsync.out"
-
 # Build some hardlinks
 
 case $0 in
@@ -116,33 +113,21 @@ mkfifo "$fromdir/fifo" || mknod "$fromdir/fifo" p || test_skipped "Can't run mkf
 # Work around time rounding/truncating issue by touching both files.
 touch -r "$fromdir/block" "$fromdir/block" "$fromdir/block2"
 
-$RSYNC -ai "$fromdir/block" "$todir/block2" \
-    | tee "$outfile"
-cat <<EOT >"$chkfile"
+checkdiff "$RSYNC -ai '$fromdir/block' '$todir/block2'" <<EOT
 cD$all_plus block
 EOT
-diff $diffopt "$chkfile" "$outfile" || test_fail "test 1 failed"
 
-$RSYNC -ai "$fromdir/block2" "$todir/block" \
-    | tee "$outfile"
-cat <<EOT >"$chkfile"
+checkdiff "$RSYNC -ai '$fromdir/block2' '$todir/block'" <<EOT
 cD$all_plus block2
 EOT
-diff $diffopt "$chkfile" "$outfile" || test_fail "test 2 failed"
 
 sleep 1
 
-$RSYNC -Di "$fromdir/block3" "$todir/block" \
-    | tee "$outfile"
-cat <<EOT >"$chkfile"
+checkdiff "$RSYNC -Di '$fromdir/block3' '$todir/block'" <<EOT
 cDc.T.$dots block3
 EOT
-diff $diffopt "$chkfile" "$outfile" || test_fail "test 3 failed"
 
-$RSYNC -aiHvv "$fromdir/" "$todir/" \
-    | tee "$outfile"
-filter_outfile
-cat <<EOT >"$chkfile"
+cat >"$chkfile" <<EOT
 .d..t.$dots ./
 cDc.t.$dots block
 cDc...$dots block2
@@ -157,7 +142,8 @@ if test "$CAN_HLINK_SPECIAL" = no; then
     grep -v block3.5 <"$chkfile" >"$chkfile.new"
     mv "$chkfile.new" "$chkfile"
 fi
-diff $diffopt "$chkfile" "$outfile" || test_fail "test 4 failed"
+
+checkdiff2 "$RSYNC -aiHvv '$fromdir/' '$todir/'" v_filt
 
 echo "check how the directory listings compare with diff:"
 echo ""
@@ -167,9 +153,7 @@ diff $diffopt "$tmpdir/ls-from" "$tmpdir/ls-to"
 
 if test "$CAN_HLINK_SPECIAL" = yes; then
     set -x
-    $RSYNC -aii --link-dest="$todir" "$fromdir/" "$chkdir/" \
-       | tee "$outfile"
-    cat <<EOT >"$chkfile"
+    checkdiff "$RSYNC -aii --link-dest='$todir' '$fromdir/' '$chkdir/'" <<EOT
 cd$allspace ./
 hD$allspace block
 hD$allspace block2
@@ -180,7 +164,6 @@ hD$allspace char2
 hD$allspace char3
 hS$allspace fifo
 EOT
-    diff $diffopt "$chkfile" "$outfile" || test_fail "test 5 failed"
 fi
 
 # The script would have aborted on error, so getting here means we've won.
index e64b808393f4b65eb172ef215470192f5c45ed45..cd2f713a7594fed9b49c9024f11b64246827dd51 100644 (file)
@@ -29,8 +29,6 @@ name2="$fromdir/name2"
 echo "This is the file" > "$name1"
 ln -s "$name1" "$name2" || test_fail "can't create symlink"
 
-outfile="$scratchdir/rsync.out"
-
 checkit "$RSYNC -avv '$fromdir/' '$fromdir/' '$fromdir/' '$fromdir/' '$fromdir/' '$fromdir/' '$fromdir/' '$fromdir/' '$fromdir/' '$fromdir/' '$todir/'" "$fromdir" "$todir" \
     | tee "$outfile"
 
index f9d1a99092fb5b1e63583cdaf5e65d6ede02e7af..c3f7185bd753673a069bdb4b827272a724b93d16 100644 (file)
@@ -12,9 +12,6 @@
 
 . "$suitedir/rsync.fns"
 
-chkfile="$scratchdir/rsync.chk"
-outfile="$scratchdir/rsync.out"
-
 CVSIGNORE='*.junk'
 export CVSIGNORE
 
@@ -228,16 +225,13 @@ checkit "$RSYNC -avv $relative_opts --exclude='$fromdir/foo/down' \
     '$fromdir/foo' '$todir'" "$chkdir$fromdir/foo" "$todir$fromdir/foo"
 
 # Now we'll test the --update option.
-$RSYNC -aiiO --update --info=skip "$scratchdir/up1/" "$scratchdir/up2/" \
-    | tee "$outfile"
-cat <<EOT >"$chkfile"
+checkdiff "$RSYNC -aiiO --update --info=skip '$scratchdir/up1/' '$scratchdir/up2/'" <<EOT
 dst-newness is newer
 .d          ./
 >f$all_plus extra-src
 .f$allspace same-newness
 >f..t.$dots src-newness
 EOT
-diff $diffopt "$chkfile" "$outfile" || test_fail "--update test failed"
 
 # The script would have aborted on error, so getting here means we've won.
 exit 0
index 740d725f1f72994999bf9a59d984420e8a5fed3b..6c4fafbc1cf7c7c95a6d40b9443086e380039259 100644 (file)
@@ -13,8 +13,6 @@
 
 SSH="$scratchdir/src/support/lsh.sh"
 
-outfile="$scratchdir/rsync.out"
-
 # Build some hardlinks
 
 fromdir="$scratchdir/from"
@@ -70,7 +68,7 @@ echo "This is another file" >"$fromdir/solo"
 ln "$fromdir/solo" "$chkdir/solo" || test_fail "Can't create hardlink"
 
 # Make sure that the checksum data doesn't slide due to an HLINK_BUMP() change.
-$RSYNC -aHivc --debug=HLINK5 "$fromdir/" "$chkdir/" | tee "$outfile"
+checktee "$RSYNC -aHivc --debug=HLINK5 '$fromdir/' '$chkdir/'"
 grep solo "$outfile" && test_fail "Erroneous copy of solo file occurred!"
 
 # Make sure there's nothing wrong with sending a single file with -H
index 9988cb725b7a12776dc21be03789cb518624a20d..146ed2ed720cf4d65fac1534b2fa79cbe68e1cdf 100644 (file)
@@ -12,9 +12,6 @@
 
 to2dir="$tmpdir/to2"
 
-chkfile="$scratchdir/rsync.chk"
-outfile="$scratchdir/rsync.out"
-
 makepath "$fromdir/foo"
 makepath "$fromdir/bar/baz"
 cp_p "$srcdir/configure.ac" "$fromdir/foo/config1"
@@ -28,10 +25,18 @@ ln "$fromdir/foo/config1" "$fromdir/foo/extra"
 rm -f "$to2dir"
 
 # Check if rsync is set to hard-link symlinks.
-if egrep '^#define CAN_HARDLINK_SYMLINK 1' config.h >/dev/null; then
+if $RSYNC --version | grep "[, ] hardlink-symlinks" >/dev/null; then
     L=hL
+    sym_dots="$allspace"
+    L_sym_dots=".L$allspace"
+    is_uptodate='is uptodate'
+    touch "$chkfile.extra"
 else
     L=cL
+    sym_dots="c.t.$dots"
+    L_sym_dots="cL$sym_dots"
+    is_uptodate='-> ../bar/baz/rsync'
+    echo "cL$sym_dots foo/sym $is_uptodate" >"$chkfile.extra"
 fi
 
 # Check if rsync can preserve time on symlinks
@@ -48,9 +53,7 @@ case "$RSYNC" in
     ;;
 esac
 
-$RSYNC -iplr "$fromdir/" "$todir/" \
-    | tee "$outfile"
-cat <<EOT >"$chkfile"
+checkdiff "$RSYNC -iplr '$fromdir/' '$todir/'" <<EOT
 cd$all_plus ./
 cd$all_plus bar/
 cd$all_plus bar/baz/
@@ -61,22 +64,18 @@ cd$all_plus foo/
 >f$all_plus foo/extra
 cL$all_plus foo/sym -> ../bar/baz/rsync
 EOT
-diff $diffopt "$chkfile" "$outfile" || test_fail "test 1 failed"
 
 # Ensure there are no accidental directory-time problems.
 $RSYNC -a -f '-! */' "$fromdir/" "$todir"
 
 cp_p "$srcdir/configure.ac" "$fromdir/foo/config2"
 chmod 601 "$fromdir/foo/config2"
-$RSYNC -iplrH "$fromdir/" "$todir/" \
-    | tee "$outfile"
-cat <<EOT >"$chkfile"
+checkdiff "$RSYNC -iplrH '$fromdir/' '$todir/'" <<EOT
 >f..T.$dots bar/baz/rsync
 >f..T.$dots foo/config1
 >f.sTp$dots foo/config2
 hf..T.$dots foo/extra => foo/config1
 EOT
-diff $diffopt "$chkfile" "$outfile" || test_fail "test 2 failed"
 
 $RSYNC -a -f '-! */' "$fromdir/" "$todir"
 cp_p "$srcdir/config.sub" "$fromdir/foo/config2"
@@ -88,38 +87,30 @@ umask 022
 chmod 600 "$fromdir/foo/config2"
 chmod 777 "$todir/bar/baz/rsync"
 
-$RSYNC -iplrtc "$fromdir/" "$todir/" \
-    | tee "$outfile"
-cat <<EOT >"$chkfile"
+checkdiff "$RSYNC -iplrtc '$fromdir/' '$todir/'" <<EOT
 .f..tp$dots bar/baz/rsync
 .d..t.$dots foo/
 .f..t.$dots foo/config1
 >fcstp$dots foo/config2
 cLc$T.$dots foo/sym -> ../bar/baz/rsync
 EOT
-diff $diffopt "$chkfile" "$outfile" || test_fail "test 3 failed"
 
 cp_p "$srcdir/configure.ac" "$fromdir/foo/config2"
 chmod 600 "$fromdir/foo/config2"
 # Lack of -t is for unchanged hard-link stress-test!
-$RSYNC -vvplrH "$fromdir/" "$todir/" \
-    | tee "$outfile"
-filter_outfile
-cat <<EOT >"$chkfile"
+checkdiff "$RSYNC -vvplrH '$fromdir/' '$todir/'" \
+       v_filt <<EOT
 bar/baz/rsync is uptodate
 foo/config1 is uptodate
 foo/extra is uptodate
 foo/sym is uptodate
 foo/config2
 EOT
-diff $diffopt "$chkfile" "$outfile" || test_fail "test 4 failed"
 
 chmod 747 "$todir/bar/baz/rsync"
 $RSYNC -a -f '-! */' "$fromdir/" "$todir"
-$RSYNC -ivvplrtH "$fromdir/" "$todir/" \
-    | tee "$outfile"
-filter_outfile
-cat <<EOT >"$chkfile"
+checkdiff "$RSYNC -ivvplrtH '$fromdir/' '$todir/'" \
+       v_filt <<EOT
 .d$allspace ./
 .d$allspace bar/
 .d$allspace bar/baz/
@@ -130,47 +121,23 @@ cat <<EOT >"$chkfile"
 hf$allspace foo/extra
 .L$allspace foo/sym -> ../bar/baz/rsync
 EOT
-diff $diffopt "$chkfile" "$outfile" || test_fail "test 5 failed"
 
 chmod 757 "$todir/foo/config1"
 touch "$todir/foo/config2"
-$RSYNC -vplrtH "$fromdir/" "$todir/" \
-    | tee "$outfile"
-filter_outfile
-cat <<EOT >"$chkfile"
+checkdiff "$RSYNC -vplrtH '$fromdir/' '$todir/'" \
+       v_filt <<EOT
 foo/config2
 EOT
-diff $diffopt "$chkfile" "$outfile" || test_fail "test 6 failed"
 
 chmod 757 "$todir/foo/config1"
 touch "$todir/foo/config2"
-$RSYNC -iplrtH "$fromdir/" "$todir/" \
-    | tee "$outfile"
-cat <<EOT >"$chkfile"
+checkdiff "$RSYNC -iplrtH '$fromdir/' '$todir/'" <<EOT
 .f...p$dots foo/config1
 >f..t.$dots foo/config2
 EOT
-diff $diffopt "$chkfile" "$outfile" || test_fail "test 7 failed"
 
-$RSYNC -ivvplrtH --copy-dest=../to "$fromdir/" "$to2dir/" \
-    | tee "$outfile"
-filter_outfile
-case `tail -1 "$outfile"` in
-cLc.t*)
-    sym_dots="c.t.$dots"
-    L_sym_dots="cL$sym_dots"
-    is_uptodate='-> ../bar/baz/rsync'
-    echo "cL$sym_dots foo/sym $is_uptodate" >"$chkfile.extra"
-    L=cL
-    ;;
-*)
-    sym_dots="$allspace"
-    L_sym_dots=".L$allspace"
-    is_uptodate='is uptodate'
-    touch "$chkfile.extra"
-    ;;
-esac
-cat <<EOT >"$chkfile"
+checkdiff "$RSYNC -ivvplrtH --copy-dest=../to '$fromdir/' '$to2dir/'" \
+       v_filt <<EOT
 cd$allspace ./
 cd$allspace bar/
 cd$allspace bar/baz/
@@ -181,21 +148,16 @@ cf$allspace foo/config2
 hf$allspace foo/extra => foo/config1
 cL$sym_dots foo/sym -> ../bar/baz/rsync
 EOT
-diff $diffopt "$chkfile" "$outfile" || test_fail "test 8 failed"
 
 rm -rf "$to2dir"
-$RSYNC -iplrtH --copy-dest=../to "$fromdir/" "$to2dir/" \
-    | tee "$outfile"
 cat - "$chkfile.extra" <<EOT >"$chkfile"
 hf$allspace foo/extra => foo/config1
 EOT
-diff $diffopt "$chkfile" "$outfile" || test_fail "test 9 failed"
+checkdiff2 "$RSYNC -iplrtH --copy-dest=../to '$fromdir/' '$to2dir/'"
 
 rm -rf "$to2dir"
-$RSYNC -vvplrtH --copy-dest="$todir" "$fromdir/" "$to2dir/" \
-    | tee "$outfile"
-filter_outfile
-cat <<EOT >"$chkfile"
+checkdiff "$RSYNC -vvplrtH --copy-dest='$todir' '$fromdir/' '$to2dir/'" \
+       v_filt <<EOT
 ./ is uptodate
 bar/ is uptodate
 bar/baz/ is uptodate
@@ -206,13 +168,10 @@ foo/config2 is uptodate
 foo/sym $is_uptodate
 foo/extra => foo/config1
 EOT
-diff $diffopt "$chkfile" "$outfile" || test_fail "test 10 failed"
 
 rm -rf "$to2dir"
-$RSYNC -ivvplrtH --link-dest="$todir" "$fromdir/" "$to2dir/" \
-    | tee "$outfile"
-filter_outfile
-cat <<EOT >"$chkfile"
+checkdiff "$RSYNC -ivvplrtH --link-dest='$todir' '$fromdir/' '$to2dir/'" \
+       v_filt <<EOT
 cd$allspace ./
 cd$allspace bar/
 cd$allspace bar/baz/
@@ -223,27 +182,16 @@ hf$allspace foo/config2
 hf$allspace foo/extra => foo/config1
 $L$sym_dots foo/sym -> ../bar/baz/rsync
 EOT
-diff $diffopt "$chkfile" "$outfile" || test_fail "test 11 failed"
 
 rm -rf "$to2dir"
-$RSYNC -iplrtH --dry-run --link-dest=../to "$fromdir/" "$to2dir/" \
-    | tee "$outfile"
-cat - "$chkfile.extra" <<EOT >"$chkfile"
-EOT
-diff $diffopt "$chkfile" "$outfile" || test_fail "test 12 failed"
+checkdiff "$RSYNC -iplrtH --dry-run --link-dest=../to '$fromdir/' '$to2dir/'" <"$chkfile.extra"
 
 rm -rf "$to2dir"
-$RSYNC -iplrtH --link-dest=../to "$fromdir/" "$to2dir/" \
-    | tee "$outfile"
-cat - "$chkfile.extra" <<EOT >"$chkfile"
-EOT
-diff $diffopt "$chkfile" "$outfile" || test_fail "test 13 failed"
+checkdiff "$RSYNC -iplrtH --link-dest=../to '$fromdir/' '$to2dir/'" <"$chkfile.extra"
 
 rm -rf "$to2dir"
-$RSYNC -vvplrtH --link-dest="$todir" "$fromdir/" "$to2dir/" \
-    | tee "$outfile"
-filter_outfile
-cat <<EOT >"$chkfile"
+checkdiff "$RSYNC -vvplrtH --link-dest='$todir' '$fromdir/' '$to2dir/'" \
+       v_filt <<EOT
 ./ is uptodate
 bar/ is uptodate
 bar/baz/ is uptodate
@@ -254,13 +202,10 @@ foo/config2 is uptodate
 foo/extra is uptodate
 foo/sym $is_uptodate
 EOT
-diff $diffopt "$chkfile" "$outfile" || test_fail "test 14 failed"
 
 rm -rf "$to2dir"
-$RSYNC -ivvplrtH --compare-dest="$todir" "$fromdir/" "$to2dir/" \
-    | tee "$outfile"
-filter_outfile
-cat <<EOT >"$chkfile"
+checkdiff "$RSYNC -ivvplrtH --compare-dest='$todir' '$fromdir/' '$to2dir/'" \
+       v_filt <<EOT
 cd$allspace ./
 cd$allspace bar/
 cd$allspace bar/baz/
@@ -271,20 +216,13 @@ cd$allspace foo/
 .f$allspace foo/extra
 $L_sym_dots foo/sym -> ../bar/baz/rsync
 EOT
-diff $diffopt "$chkfile" "$outfile" || test_fail "test 15 failed"
 
 rm -rf "$to2dir"
-$RSYNC -iplrtH --compare-dest="$todir" "$fromdir/" "$to2dir/" \
-    | tee "$outfile"
-cat - "$chkfile.extra" <<EOT >"$chkfile"
-EOT
-diff $diffopt "$chkfile" "$outfile" || test_fail "test 16 failed"
+checkdiff "$RSYNC -iplrtH --compare-dest='$todir' '$fromdir/' '$to2dir/'" <"$chkfile.extra"
 
 rm -rf "$to2dir"
-$RSYNC -vvplrtH --compare-dest="$todir" "$fromdir/" "$to2dir/" \
-    | tee "$outfile"
-filter_outfile
-cat <<EOT >"$chkfile"
+checkdiff "$RSYNC -vvplrtH --compare-dest='$todir' '$fromdir/' '$to2dir/'" \
+       v_filt <<EOT
 ./ is uptodate
 bar/ is uptodate
 bar/baz/ is uptodate
@@ -295,7 +233,6 @@ foo/config2 is uptodate
 foo/extra is uptodate
 foo/sym $is_uptodate
 EOT
-diff $diffopt "$chkfile" "$outfile" || test_fail "test 17 failed"
 
 # The script would have aborted on error, so getting here means we've won.
 exit 0
index 89e4ce17f6dfb9fce62a55fdba042fc94db810da..5546291b61c35a5e5f881393929da67f64b235d7 100644 (file)
@@ -20,8 +20,6 @@ echo wowza >"$extrafile"
 
 $RSYNC -av --existing --include='*/' --exclude='*' "$fromdir/" "$extradir/"
 
-outfile="$scratchdir/rsync.out"
-
 cd "$fromdir"
 
 # Main script starts here
index 68389e702c725cf4bd85ad412e980822407b7fcc..4a7cd3d370a2a44ff73d6464a8e1aff55138de7a 100644 (file)
@@ -12,7 +12,7 @@
 # WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 # Lesser General Public License for more details.
-# 
+#
 # You should have received a copy of the GNU Lesser General Public
 # License along with this program; if not, write to the Free Software
 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -22,6 +22,9 @@ fromdir="$tmpdir/from"
 todir="$tmpdir/to"
 chkdir="$tmpdir/chk"
 
+chkfile="$scratchdir/rsync.chk"
+outfile="$scratchdir/rsync.out"
+
 # For itemized output:
 all_plus='+++++++++'
 allspace='         '
@@ -75,10 +78,10 @@ cp_touch() {
     fi
 }
 
-# Call this if you want to filter out verbose messages (-v or -vv) from
-# the output of an rsync run (whittling the output down to just the file
-# messages).  This isn't needed if you use -i without -v.
-filter_outfile() {
+# Call this if you want to filter (stdin -> stdout) verbose messages (-v or
+# -vv) from an rsync run (whittling the output down to just the file messages).
+# This isn't needed if you use -i without -v.
+v_filt() {
     sed -e '/^building file list /d' \
        -e '/^sending incremental file list/d' \
        -e '/^created directory /d' \
@@ -87,9 +90,7 @@ filter_outfile() {
        -e '/^total: /d' \
        -e '/^client charset: /d' \
        -e '/^server charset: /d' \
-       -e '/^$/,$d' \
-       <"$outfile" >"$outfile.new"
-    mv "$outfile.new" "$outfile"
+       -e '/^$/,$d'
 }
 
 printmsg() {
@@ -149,7 +150,7 @@ check_perms() {
     test_fail "failed test $3"
 }
 
-rsync_getgroups() { 
+rsync_getgroups() {
     "$TOOLDIR/getgroups"
 }
 
@@ -171,7 +172,7 @@ hands_setup() {
     # the links behave in the future, and it cannot be changed using
     # chmod!  rsync always sets its umask to 000 so that it can
     # accurately recreate permissions, but this script is probably run
-    # with a different umask. 
+    # with a different umask.
 
     # This causes a little problem that "ls -l" of the two will not be
     # the same.  So, we need to set our umask before doing any creations.
@@ -213,7 +214,7 @@ hands_setup() {
 
 ####################
 # Many machines do not have "mkdir -p", so we have to build up long paths.
-# How boring.  
+# How boring.
 makepath() {
     for p in "${@}"; do
        (echo "        makepath $p"
@@ -223,11 +224,11 @@ makepath() {
        then
            cd /
        fi
-    
+
        # This will break if $p contains a space.
        for c in `echo $p | tr '/' ' '`
-       do 
-           if [ -d "$c" ] || mkdir "$c" 
+       do
+           if [ -d "$c" ] || mkdir "$c"
            then
                cd "$c" || return $?
            else
@@ -262,8 +263,8 @@ checkit() {
        ;;
     esac
 
-    echo "Running: \"$1\""  
-    eval "$1" 
+    echo "Running: \"$1\""
+    eval "$1"
     status=$?
     if [ $status != 0 ]; then
        failed="$failed status=$status"
@@ -302,6 +303,57 @@ checkit() {
 }
 
 
+# Run a test in $1 and make sure it has a zero exit status.  Capture the
+# output into $outfile and echo it to stdout.
+checktee() {
+    echo "Running: \"$1\""
+    eval "$1" >"$outfile"
+    status=$?
+    cat "$outfile"
+    if [ $status != 0 ]; then
+       echo "Failed: status=$status"
+       return 1
+    fi
+    return 0
+}
+
+
+# Slurp stdin into $chkfile and then call checkdiff2().
+checkdiff() {
+    cat >"$chkfile" # Save off stdin
+    checkdiff2 "${@}"
+}
+
+
+# Run a test in $1 and make sure it has a zero exit status.  Capture the output
+# into $outfile.  If $2 is set, use it to filter the outfile.  If resulting
+# outfile differs from the chkfile data, fail with an error.
+checkdiff2() {
+    failed=
+
+    echo "Running: \"$1\""
+    eval "$1" >"$outfile"
+    status=$?
+    cat "$outfile"
+    if [ $status != 0 ]; then
+       failed="$failed status=$status"
+    fi
+
+    if [ "$2" ]; then
+       eval "cat '$outfile' | $2 >'$outfile.new'"
+       mv "$outfile.new" "$outfile"
+    fi
+
+    diff $diffopt "$chkfile" "$outfile" || failed="$failed output differs"
+
+    if [ "$failed" ] ; then
+       echo "Failed: $failed"
+       return 1
+    fi
+    return 0
+}
+
+
 build_rsyncd_conf() {
     # Build an appropriate configuration file
     conf="$scratchdir/test-rsyncd.conf"
@@ -404,7 +456,7 @@ test_skipped() {
     exit 77
 }
 
-# It failed, but we expected that.  don't dump out error logs, 
+# It failed, but we expected that.  Don't dump out error logs,
 # because most users won't want to see them.  But do leave
 # the working directory around.
 test_xfail() {
@@ -437,7 +489,7 @@ then
 else
     echo "Testing for symlinks using '$TEST_SYMLINK_CMD'"
 fi
-       
+
 
 # Test whether something is a link, allowing for shell peculiarities
 is_a_link() {
@@ -451,5 +503,5 @@ is_a_link() {
 # directory has to be writable by the nobody user in some cases.  The
 # best thing is probably to explicitly chmod those directories after
 # creation.
+
 umask 022