2 # Ensure that touch -h works.
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
26 ln -s nowhere dangling || framework_failure
27 touch file || framework_failure
28 ln -s file link || framework_failure
31 # These first tests should work on every platform.
32 # -h does not create files, but it warns. Use -c to silence warning.
33 touch -h no-file 2> err && fail=1
35 touch -h -c no-file 2> err || fail=1
38 # -h works on regular files
39 touch -h file || fail=1
41 # -h coupled with -r uses timestamp of the symlink, not the referent.
42 touch -h -r dangling file || fail=1
43 test -f nowhere && fail=1
45 # The remaining tests of -h require kernel support for changing symlink times.
46 grep '^#define HAVE_UTIMENSAT' "$CONFIG_HEADER" > /dev/null ||
47 grep '^#define HAVE_LUTIMES' "$CONFIG_HEADER" > /dev/null ||
48 skip_test_ 'this system lacks the utimensat function'
50 # Changing time of dangling symlink is okay.
51 touch -h dangling || fail=1
52 test -f nowhere && fail=1
54 # Change the mtime of a symlink.
55 touch -m -h -d 2009-10-10 link || fail=1
56 case `stat --format=%y link` in
60 case `stat --format=%y file` in
64 # Test interactions with -.
65 touch -h - > file || fail=1
67 test="$abs_top_builddir/src/test"
69 # If >&- works, test "touch -ch -" etc.
70 # >&- apparently does not work in HP-UX 11.23.
71 # This test is ineffective unless /dev/stdout also works.
72 # If stdout is open, it is not a symlink.
73 if "$test" -w /dev/stdout >/dev/null &&
74 "$test" ! -w /dev/stdout >&-; then
75 touch -h - >&- && fail=1
76 touch -h -c - >&- || fail=1