Avoid problems with timestamp rounding that cp -p and touch -r may do.
authorWayne Davison <wayned@samba.org>
Tue, 17 Jun 2008 22:59:47 +0000 (15:59 -0700)
committerWayne Davison <wayned@samba.org>
Tue, 17 Jun 2008 22:59:47 +0000 (15:59 -0700)
testsuite/backup.test
testsuite/devices.test
testsuite/exclude.test
testsuite/fuzzy.test
testsuite/merge.test
testsuite/rsync.fns
testsuite/xattrs.test

index dc53368..4227b86 100644 (file)
@@ -36,7 +36,7 @@ for fn in deep/name1 deep/name2; do
 done
 
 echo deleted-file >"$todir/dname"
 done
 
 echo deleted-file >"$todir/dname"
-cp -p "$todir/dname" "$chkdir"
+cp_touch "$todir/dname" "$chkdir"
 
 checkit "$RSYNC -avv --no-whole-file --delete-delay \
     --backup --backup-dir='$bakdir' '$fromdir/' '$todir/'" "$fromdir" "$todir" \
 
 checkit "$RSYNC -avv --no-whole-file --delete-delay \
     --backup --backup-dir='$bakdir' '$fromdir/' '$todir/'" "$fromdir" "$todir" \
index 8df0be6..23a8e5b 100644 (file)
@@ -76,7 +76,8 @@ mknod "$fromdir/block2" b 42 73 || test_skipped "Can't create block device node"
 mknod "$fromdir/block3" b 105 73 || test_skipped "Can't create block device node"
 ln "$fromdir/block3" "$fromdir/block2.5" || echo "Skipping hard-linked device test..."
 mkfifo "$fromdir/fifo" || mknod "$fromdir/fifo" p || test_skipped "Can't run mkfifo"
 mknod "$fromdir/block3" b 105 73 || test_skipped "Can't create block device node"
 ln "$fromdir/block3" "$fromdir/block2.5" || echo "Skipping hard-linked device test..."
 mkfifo "$fromdir/fifo" || mknod "$fromdir/fifo" p || test_skipped "Can't run mkfifo"
-touch -r "$fromdir/block" "$fromdir/block2"
+# 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"
 
 $RSYNC -ai "$fromdir/block" "$todir/block2" \
     | tee "$outfile"
index 2fef092..099344f 100644 (file)
@@ -153,13 +153,13 @@ checkit "$RSYNC -avvC --filter='merge $excl' --delete-excluded \
 
 rm "$chkdir"/foo/file1
 rm "$chkdir"/bar/down/to/bar/baz/*.deep
 
 rm "$chkdir"/foo/file1
 rm "$chkdir"/bar/down/to/bar/baz/*.deep
-cp -p "$fromdir"/bar/down/to/foo/*.junk "$chkdir"/bar/down/to/foo
-cp -p "$fromdir"/bar/down/to/foo/to "$chkdir"/bar/down/to/foo
+cp_touch "$fromdir"/bar/down/to/foo/*.junk "$chkdir"/bar/down/to/foo
+cp_touch "$fromdir"/bar/down/to/foo/to "$chkdir"/bar/down/to/foo
 
 $RSYNC -av --existing -f 'show .filt*' -f 'hide,! */' --del "$fromdir/" "$todir/"
 
 echo retained >"$todir"/bar/down/to/bar/baz/nodel.deep
 
 $RSYNC -av --existing -f 'show .filt*' -f 'hide,! */' --del "$fromdir/" "$todir/"
 
 echo retained >"$todir"/bar/down/to/bar/baz/nodel.deep
-cp -p "$todir"/bar/down/to/bar/baz/nodel.deep "$chkdir"/bar/down/to/bar/baz
+cp_touch "$todir"/bar/down/to/bar/baz/nodel.deep "$chkdir"/bar/down/to/bar/baz
 
 $RSYNC -av --existing --filter='-! */' "$fromdir/" "$chkdir/"
 
 
 $RSYNC -av --existing --filter='-! */' "$fromdir/" "$chkdir/"
 
index 0041629..1abfab5 100644 (file)
@@ -13,7 +13,7 @@ mkdir "$fromdir"
 mkdir "$todir"
 
 cp -p "$srcdir"/rsync.c "$fromdir"/rsync.c
 mkdir "$todir"
 
 cp -p "$srcdir"/rsync.c "$fromdir"/rsync.c
-cp -p "$fromdir"/rsync.c "$todir"/rsync2.c
+cp_touch "$fromdir"/rsync.c "$todir"/rsync2.c
 sleep 1
 
 # Let's do it!
 sleep 1
 
 # Let's do it!
index 1720a18..4e76102 100644 (file)
@@ -19,15 +19,15 @@ mkdir from2/sub1 from3/sub1
 mkdir from3/sub2 from1/dir-and-not-dir
 mkdir chk chk/sub1 chk/sub2 chk/dir-and-not-dir
 echo "one" >from1/one
 mkdir from3/sub2 from1/dir-and-not-dir
 mkdir chk chk/sub1 chk/sub2 chk/dir-and-not-dir
 echo "one" >from1/one
-cp -p from1/one from2/one
-cp -p from1/one from3/one
+cp_touch from1/one from2/one
+cp_touch from1/one from3/one
 echo "two" >from1/two
 echo "three" >from2/three
 echo "four" >from3/four
 echo "five" >from1/five
 echo "six" >from3/six
 echo "sub1" >from2/sub1/uno
 echo "two" >from1/two
 echo "three" >from2/three
 echo "four" >from3/four
 echo "five" >from1/five
 echo "six" >from3/six
 echo "sub1" >from2/sub1/uno
-cp -p from2/sub1/uno from3/sub1/uno
+cp_touch from2/sub1/uno from3/sub1/uno
 echo "sub2" >from3/sub1/dos
 echo "sub3" >from2/sub1/tres
 echo "subby" >from3/sub2/subby
 echo "sub2" >from3/sub1/dos
 echo "sub3" >from2/sub1/tres
 echo "subby" >from3/sub2/subby
@@ -36,11 +36,11 @@ echo "not-dir" >from3/dir-and-not-dir
 echo "arg-test" >deep/arg-test
 echo "shallow" >shallow
 
 echo "arg-test" >deep/arg-test
 echo "shallow" >shallow
 
-cp -p from1/one from1/two from2/three from3/four from1/five from3/six chk
-cp -p deep/arg-test shallow chk
-cp -p from1/dir-and-not-dir/inside chk/dir-and-not-dir
-cp -p from2/sub1/uno from3/sub1/dos from2/sub1/tres chk/sub1
-cp -p from3/sub2/subby chk/sub2
+cp_touch from1/one from1/two from2/three from3/four from1/five from3/six chk
+cp_touch deep/arg-test shallow chk
+cp_touch from1/dir-and-not-dir/inside chk/dir-and-not-dir
+cp_touch from2/sub1/uno from3/sub1/dos from2/sub1/tres chk/sub1
+cp_touch from3/sub2/subby chk/sub2
 
 # Make sure that time has moved on.
 sleep 1
 
 # Make sure that time has moved on.
 sleep 1
index b982461..e17fe5a 100644 (file)
@@ -52,6 +52,29 @@ runtest() {
     fi
 }
 
     fi
 }
 
+set_cp_destdir() {
+    while test $# -gt 1; do
+       shift
+    done
+    destdir="$1"
+}
+
+# Perform a "cp -p", making sure that timestamps are really the same,
+# even if the copy rounded microsecond times on the destination file.
+cp_touch() {
+    cp -p "${@}" || test_fail "cp -p failed"
+    if test $# -gt 2 -o -d "$2"; then
+       set_cp_destdir "${@}" # sets destdir var
+       while test $# -gt 1; do
+           destname="$destdir/`basename $1`"
+           touch -r "$destname" "$1" "$destname"
+           shift
+       done
+    else
+       touch -r "$2" "$1" "$2"
+    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.
 # 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.
index 8a311c4..86758fa 100644 (file)
@@ -46,7 +46,7 @@ echo deeper >"$fromdir/foo/bar/file5"
 
 makepath "$chkdir/foo"
 echo wow >"$chkdir/file1"
 
 makepath "$chkdir/foo"
 echo wow >"$chkdir/file1"
-cp -p "$fromdir/foo/file3" "$chkdir/foo"
+cp_touch "$fromdir/foo/file3" "$chkdir/foo"
 
 files='foo file0 file1 file2 foo/file3 file4 foo/bar/file5'
 
 
 files='foo file0 file1 file2 foo/file3 file4 foo/bar/file5'