From: Wayne Davison Date: Tue, 17 Jun 2008 22:59:47 +0000 (-0700) Subject: Avoid problems with timestamp rounding that cp -p and touch -r may do. X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/commitdiff_plain/844810d6099d5c7fc837ea1bad4470cfdd801c66 Avoid problems with timestamp rounding that cp -p and touch -r may do. --- diff --git a/testsuite/backup.test b/testsuite/backup.test index dc53368c..4227b868 100644 --- a/testsuite/backup.test +++ b/testsuite/backup.test @@ -36,7 +36,7 @@ for fn in deep/name1 deep/name2; do 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" \ diff --git a/testsuite/devices.test b/testsuite/devices.test index 8df0be62..23a8e5b9 100644 --- a/testsuite/devices.test +++ b/testsuite/devices.test @@ -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" -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" diff --git a/testsuite/exclude.test b/testsuite/exclude.test index 2fef0922..099344f2 100644 --- a/testsuite/exclude.test +++ b/testsuite/exclude.test @@ -153,13 +153,13 @@ checkit "$RSYNC -avvC --filter='merge $excl' --delete-excluded \ 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 -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/" diff --git a/testsuite/fuzzy.test b/testsuite/fuzzy.test index 0041629f..1abfab52 100644 --- a/testsuite/fuzzy.test +++ b/testsuite/fuzzy.test @@ -13,7 +13,7 @@ mkdir "$fromdir" 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! diff --git a/testsuite/merge.test b/testsuite/merge.test index 1720a181..4e76102d 100644 --- a/testsuite/merge.test +++ b/testsuite/merge.test @@ -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 -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 -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 @@ -36,11 +36,11 @@ echo "not-dir" >from3/dir-and-not-dir 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 diff --git a/testsuite/rsync.fns b/testsuite/rsync.fns index b982461b..e17fe5ac 100644 --- a/testsuite/rsync.fns +++ b/testsuite/rsync.fns @@ -52,6 +52,29 @@ runtest() { 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. diff --git a/testsuite/xattrs.test b/testsuite/xattrs.test index 8a311c4a..86758fac 100644 --- a/testsuite/xattrs.test +++ b/testsuite/xattrs.test @@ -46,7 +46,7 @@ echo deeper >"$fromdir/foo/bar/file5" 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'