maint: update all copyright year number ranges
[platform/upstream/coreutils.git] / tests / touch / no-dereference
index 7adacc4..6f03142 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # Ensure that touch -h works.
 
-# Copyright (C) 2009-2010 Free Software Foundation, Inc.
+# Copyright (C) 2009-2012 Free Software Foundation, Inc.
 
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-if test "$VERBOSE" = yes; then
-  set -x
-  touch --version
-fi
-
-. $srcdir/test-lib.sh
+. "${srcdir=.}/init.sh"; path_prepend_ ../src
+print_ver_ touch
 
-ln -s nowhere dangling || framework_failure
-touch file || framework_failure
-ln -s file link || framework_failure
+ln -s nowhere dangling || framework_failure_
+touch file || framework_failure_
+ln -s file link || framework_failure_
 
 
 # These first tests should work on every platform.
@@ -43,13 +39,22 @@ touch -h -r dangling file || fail=1
 test -f nowhere && fail=1
 
 # The remaining tests of -h require kernel support for changing symlink times.
-grep '^#define HAVE_UTIMENSAT' "$CONFIG_HEADER" > /dev/null ||
-grep '^#define HAVE_LUTIMES' "$CONFIG_HEADER" > /dev/null ||
-  skip_test_ 'this system lacks the utimensat function'
+grep '^#define HAVE_UTIMENSAT 1' "$CONFIG_HEADER" > /dev/null ||
+grep '^#define HAVE_LUTIMES 1' "$CONFIG_HEADER" > /dev/null ||
+  skip_ 'this system lacks the utimensat function'
 
 # Changing time of dangling symlink is okay.
-touch -h dangling || fail=1
-test -f nowhere && fail=1
+# Skip the test if this fails, but the error text corresponds to
+# ENOSYS (possible with old kernel but new glibc).
+touch -h dangling 2> err
+case $? in
+  0) test -f nowhere && fail=1
+     test -s err && fail=1;;
+  1) grep 'Function not implemented' err \
+       && skip_ 'this system lacks the utimensat function'
+     fail=1;;
+  *) fail=1;;
+esac
 
 # Change the mtime of a symlink.
 touch -m -h -d 2009-10-10 link || fail=1