2 # Ensure that the size of a long-named-symlink is > 0.
4 # Copyright (C) 2002-2007 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 2 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, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 if test "$VERBOSE" = yes; then
27 t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
28 trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0
29 trap '(exit $?); exit $?' 1 2 13 15
32 mkdir -p $tmp || framework_failure=1
33 cd $tmp || framework_failure=1
35 # Determine if `.' is on a local (would non-NFS be sufficient?) file system.
36 # On at least some NFS implementations, symlinks never take up space,
38 # So if this is a non-local file system, skip the test.
39 if df --local . >/dev/null 2>&1; then
42 echo "$0: skipping this test, since \`.' is on a non-local file system" 1>&2
46 if df --type=xfs . >/dev/null 2>&1; then
47 # At least on Irix-6.5.19, when using an xfs file system,
48 # each created symlink (name lengths up to 255) would have a size of `0'.
49 echo "$0: skipping this test, since \`.' is on an XFS file system" 1>&2
53 if df --type=nfsv3 . >/dev/null 2>&1; then
54 # At least on OSF/1 4.0d, when using an nfsv3 file system,
55 # each created symlink can end up having a size of 0.
56 echo "$0: skipping this test, since \`.' is on an NFS file system" 1>&2
60 if test $framework_failure = 1; then
61 echo "$0: failure in testing framework" 1>&2
66 symlink_name_lengths='1 15 16 31 32 59 60 63 64 127 128 255 256 511 512 1024'
67 for len in $symlink_name_lengths; do
68 name=`seq 1 $len|tr -c x y |head -c$len`
69 # Record the names of symlinks that are successfully created.
70 ln -fs $name $len > /dev/null 2>&1 \
71 && symlinks="$symlinks $len"
74 du -a $symlinks > out || fail=1
76 # Require that at least one of these symlinks has a non-zero size.
77 grep '^[1-9]' out > /dev/null || fail=1
79 (exit $fail); exit $fail