]> git.ipfire.org Git - thirdparty/rsync.git/commitdiff
Combine some alt-dest tests.
authorWayne Davison <wayne@opencoder.net>
Sat, 26 Mar 2022 17:00:24 +0000 (10:00 -0700)
committerWayne Davison <wayne@opencoder.net>
Sat, 26 Mar 2022 17:01:12 +0000 (10:01 -0700)
testsuite/alt-dest.test
testsuite/copy-file-inplace.test [deleted file]
testsuite/copy-file.test [deleted file]
util1.c

index 126daedd706376507f6dcfb80b64d471b18d861c..d2fb5a1bbe11ea4fbfb5a604555c146e1a5b94c5 100644 (file)
@@ -5,12 +5,15 @@
 # This program is distributable under the terms of the GNU GPL (see
 # COPYING).
 
-# Test rsync handling of the --compare-dest option.
+# Test rsync handling of --compare-dest and similar options.
 
 . "$suitedir/rsync.fns"
 
 alt1dir="$tmpdir/alt1"
 alt2dir="$tmpdir/alt2"
+alt3dir="$tmpdir/alt3"
+
+SSH="$scratchdir/src/support/lsh.sh"
 
 # Build some files/dirs/links to copy
 
@@ -20,8 +23,14 @@ hands_setup
 $RSYNC -av --include=text --include='*/' --exclude='*' "$fromdir/" "$alt1dir/"
 $RSYNC -av --include=etc-ltr-list --include='*/' --exclude='*' "$fromdir/" "$alt2dir/"
 
+# Create a side dir where there is a candidate destfile of the same name as a sourcefile
+echo "This is a test file" >"$fromdir/likely"
+
+mkdir "$alt3dir"
+echo "This is a test file" >"$alt3dir/likely"
+
 sleep 1
-touch "$fromdir/dir/text"
+touch "$fromdir/dir/text" "$fromdir/likely"
 
 $RSYNC -av --exclude=/text --exclude=etc-ltr-list "$fromdir/" "$chkdir/"
 
@@ -29,9 +38,31 @@ $RSYNC -av --exclude=/text --exclude=etc-ltr-list "$fromdir/" "$chkdir/"
 checkit "$RSYNC -avv --no-whole-file \
     --compare-dest='$alt1dir' --compare-dest='$alt2dir' \
     '$fromdir/' '$todir/'" "$chkdir" "$todir"
+
+rm -rf "$todir"
 checkit "$RSYNC -avv --no-whole-file \
     --copy-dest='$alt1dir' --copy-dest='$alt2dir' \
     '$fromdir/' '$todir/'" "$fromdir" "$todir"
 
+# Test that copy_file() works correctly with tmpfiles
+for maybe_inplace in '' --inplace; do
+    rm -rf "$todir"
+    checkit "$RSYNC -av $maybe_inplace --copy-dest='$alt3dir' \
+       '$fromdir/' '$todir/'" "$fromdir" "$todir"
+
+    for srchost in '' 'localhost:'; do
+       if [ -z "$srchost" ]; then
+           desthost='localhost:'
+       else
+           desthost=''
+       fi
+
+       rm -rf "$todir"
+       checkit "$RSYNC -ave '$SSH' --rsync-path='$RSYNC' $maybe_inplace \
+           --copy-dest='$alt3dir' '$srchost$fromdir/' '$desthost$todir/'" \
+           "$fromdir" "$todir"
+    done
+done
+
 # The script would have aborted on error, so getting here means we've won.
 exit 0
diff --git a/testsuite/copy-file-inplace.test b/testsuite/copy-file-inplace.test
deleted file mode 100755 (executable)
index a3d124f..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-#!/bin/sh
-
-# Copyright (C) 2008-2022 Wayne Davison
-
-# This program is distributable under the terms of the GNU GPL (see
-# COPYING).
-
-# Test that copy_file works correctly with tmpfiles
-
-. "$suitedir/rsync.fns"
-
-SSH="$scratchdir/src/support/lsh.sh"
-
-hands_setup
-
-# Create a side dir where there is a candidate destfile of the same name as a sourcefile
-cat >"$scratchdir/from/likely" <<EOF
-This is a test file
-EOF
-
-mkdir "$scratchdir/demo"
-cat >"$scratchdir/demo/likely" <<EOF
-This is a test file
-EOF
-
-# Create a chkdir
-$RSYNC -a "$fromdir/" "$chkdir/"
-
-checkit "$RSYNC -av --inplace --copy-dest='$scratchdir/demo' '$fromdir/' '$todir/'" "$chkdir" "$todir"
-
-for filehost in '' 'localhost:'; do
-    for srchost in '' 'localhost:'; do
-       if [ -z "$srchost" ]; then
-           desthost='localhost:'
-       else
-           desthost=''
-       fi
-
-       rm -rf "$todir"
-       checkit "$RSYNC -avse '$SSH' --rsync-path='$RSYNC' --inplace --copy-dest='$desthost$scratchdir/demo' '$srchost$fromdir/' '$desthost$todir/'" "$chkdir" "$todir"
-    done
-done
-
-# The script would have aborted on error, so getting here means we've won.
-exit 0
diff --git a/testsuite/copy-file.test b/testsuite/copy-file.test
deleted file mode 100644 (file)
index b829fcf..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-#!/bin/sh
-
-# Copyright (C) 2008-2022 Wayne Davison
-
-# This program is distributable under the terms of the GNU GPL (see
-# COPYING).
-
-# Test that copy_file works correctly with tmpfiles
-
-. "$suitedir/rsync.fns"
-
-SSH="$scratchdir/src/support/lsh.sh"
-
-hands_setup
-
-# Create a side dir where there is a candidate destfile of the same name as a sourcefile
-cat >"$scratchdir/from/likely" <<EOF
-This is a test file
-EOF
-
-mkdir "$scratchdir/demo"
-cat >"$scratchdir/demo/likely" <<EOF
-This is a test file
-EOF
-
-# Create a chkdir
-$RSYNC -a "$fromdir/" "$chkdir/"
-
-checkit "$RSYNC -av --copy-dest='$scratchdir/demo' '$fromdir/' '$todir/'" "$chkdir" "$todir"
-
-for filehost in '' 'localhost:'; do
-    for srchost in '' 'localhost:'; do
-       if [ -z "$srchost" ]; then
-           desthost='localhost:'
-       else
-           desthost=''
-       fi
-
-       rm -rf "$todir"
-       checkit "$RSYNC -avse '$SSH' --rsync-path='$RSYNC' --copy-dest='$desthost$scratchdir/demo' '$srchost$fromdir/' '$desthost$todir/'" "$chkdir" "$todir"
-    done
-done
-
-# The script would have aborted on error, so getting here means we've won.
-exit 0
diff --git a/util1.c b/util1.c
index 7d0460ee95c1bb51e01808a2f58b20b12450e537..5f14723eb3723427d2eec3b92e66448ba6066d5c 100644 (file)
--- a/util1.c
+++ b/util1.c
@@ -348,7 +348,7 @@ static int unlink_and_reopen(const char *dest, mode_t mode)
 
 /* Copy contents of file @source to file @dest with mode @mode.
  *
- * If @tmpfilefd is <0, copy_file unlinks @dest and then opens a new
+ * If @tmpfilefd is < 0, copy_file unlinks @dest and then opens a new
  * file with name @dest.
  *
  * Otherwise, copy_file writes to and closes the provided file