cp -pP (and e.g., -a): preserve time stamps on symlinks, too
[coreutils.git] / tests / cp / preserve-slink-time
blobc5c21a5e1ca652f639304e80dc08218f92feaf5b
1 #!/bin/sh
2 # Verify that cp -Pp preserves times even on symlinks.
4 # Copyright (C) 2009 Free Software Foundation, Inc.
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 if test "$VERBOSE" = yes; then
20 set -x
21 cp --version
24 . $srcdir/test-lib.sh
26 grep '^#define HAVE_UTIMENSAT' "$CONFIG_HEADER" > /dev/null ||
27 skip_test_ 'this system lacks the utimensat function'
29 ln -s no-such dangle || framework_failure
31 # If the current file system lacks sub-second resolution, sleep for 2s to
32 # ensure that the times on the copy are different from those of the original.
33 case $(stat --format=%y dangle) in
34 ??:??:??.000000000) sleep 2;;
35 esac
37 cp -Pp dangle d2 || framework_failure
38 stat --format=%y dangle > t1 || framework_failure
39 stat --format=%y d2 > t2 || framework_failure
41 fail=0
42 compare t1 t2 || fail=1
44 Exit $fail