~ubuntu-branches/ubuntu/utopic/coreutils/utopic-proposed

« back to all changes in this revision

Viewing changes to tests/touch/no-dereference.sh

  • Committer: Package Import Robot
  • Author(s): Colin Watson
  • Date: 2012-11-28 03:03:42 UTC
  • mfrom: (8.3.4 sid)
  • Revision ID: package-import@ubuntu.com-20121128030342-21zanj8354gas5gr
Tags: 8.20-3ubuntu1
* Resynchronise with Debian.  Remaining changes:
  - Make 'uname -i -p' return the real processor/hardware, instead of
    unknown.
  - Build-depend on gettext:any instead of on gettext, so that apt-get can
    properly resolve build-dependencies on the tool when cross-building.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
# Ensure that touch -h works.
 
3
 
 
4
# Copyright (C) 2009-2012 Free Software Foundation, Inc.
 
5
 
 
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.
 
10
 
 
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.
 
15
 
 
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/>.
 
18
 
 
19
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
 
20
print_ver_ touch
 
21
 
 
22
ln -s nowhere dangling || framework_failure_
 
23
touch file || framework_failure_
 
24
ln -s file link || framework_failure_
 
25
 
 
26
 
 
27
# These first tests should work on every platform.
 
28
# -h does not create files, but it warns.  Use -c to silence warning.
 
29
touch -h no-file 2> err && fail=1
 
30
test -s err || fail=1
 
31
touch -h -c no-file 2> err || fail=1
 
32
test -s err && fail=1
 
33
 
 
34
# -h works on regular files
 
35
touch -h file || fail=1
 
36
 
 
37
# -h coupled with -r uses timestamp of the symlink, not the referent.
 
38
touch -h -r dangling file || fail=1
 
39
test -f nowhere && fail=1
 
40
 
 
41
# The remaining tests of -h require kernel support for changing symlink times.
 
42
grep '^#define HAVE_UTIMENSAT 1' "$CONFIG_HEADER" > /dev/null ||
 
43
grep '^#define HAVE_LUTIMES 1' "$CONFIG_HEADER" > /dev/null ||
 
44
  skip_ 'this system lacks the utimensat function'
 
45
 
 
46
# Changing time of dangling symlink is okay.
 
47
# Skip the test if this fails, but the error text corresponds to
 
48
# ENOSYS (possible with old kernel but new glibc).
 
49
touch -h dangling 2> err
 
50
case $? in
 
51
  0) test -f nowhere && fail=1
 
52
     test -s err && fail=1;;
 
53
  1) grep 'Function not implemented' err \
 
54
       && skip_ 'this system lacks the utimensat function'
 
55
     fail=1;;
 
56
  *) fail=1;;
 
57
esac
 
58
 
 
59
# Change the mtime of a symlink.
 
60
touch -m -h -d 2009-10-10 link || fail=1
 
61
case $(stat --format=%y link) in
 
62
  2009-10-10*) ;;
 
63
  *) fail=1 ;;
 
64
esac
 
65
case $(stat --format=%y file) in
 
66
  2009-10-10*) fail=1;;
 
67
esac
 
68
 
 
69
# Test interactions with -.
 
70
touch -h - > file || fail=1
 
71
 
 
72
test="$abs_top_builddir/src/test"
 
73
 
 
74
# If >&- works, test "touch -ch -" etc.
 
75
# >&- apparently does not work in HP-UX 11.23.
 
76
# This test is ineffective unless /dev/stdout also works.
 
77
# If stdout is open, it is not a symlink.
 
78
if "$test" -w /dev/stdout >/dev/null &&
 
79
   "$test" ! -w /dev/stdout >&-; then
 
80
  touch -h - >&- && fail=1
 
81
  touch -h -c - >&- || fail=1
 
82
fi
 
83
 
 
84
Exit $fail