ls: --color now highlights hard linked files, too
[coreutils/bo.git] / tests / du / slink
blob5bf0349cbb462a7f89bfd49165fe6efbb35bc34e
1 #!/bin/sh
2 # Ensure that the size of a long-named-symlink is > 0.
4 # Copyright (C) 2002-2008 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 du --version
24 . $srcdir/test-lib.sh
26 # Determine if `.' is on a local (would non-NFS be sufficient?) file system.
27 # On at least some NFS implementations, symlinks never take up space,
29 # So if this is a non-local file system, skip the test.
30 if df --local . >/dev/null 2>&1; then
31 : # Ok.
32 else
33 skip_test_ "\`.' is on a non-local file system"
36 if df --type=xfs . >/dev/null 2>&1; then
37 # At least on Irix-6.5.19, when using an xfs file system,
38 # each created symlink (name lengths up to 255) would have a size of `0'.
39 skip_test_ "\`.' is on an XFS file system"
42 if df --type=nfsv3 . >/dev/null 2>&1; then
43 # At least on OSF/1 4.0d, when using an nfsv3 file system,
44 # each created symlink can end up having a size of 0.
45 skip_test_ "\`.' is on an NFS file system"
48 fail=0
49 symlink_name_lengths='1 15 16 31 32 59 60 63 64 127 128 255 256 511 512 1024'
50 for len in $symlink_name_lengths; do
51 name=`seq 1 $len|tr -c x y |head -c$len`
52 # Record the names of symlinks that are successfully created.
53 ln -fs $name $len > /dev/null 2>&1 \
54 && symlinks="$symlinks $len"
55 done
57 du -a $symlinks > out || fail=1
59 # Require that at least one of these symlinks has a non-zero size.
60 grep '^[1-9]' out > /dev/null || fail=1
62 Exit $fail