2 # Ensure that ls --file-type does not call stat unnecessarily.
3 # Also check for the dtype-related (and fs-type dependent) bug
4 # in coreutils-6.0 that made ls -CF columns misaligned.
6 # Copyright (C) 2006-2009 Free Software Foundation, Inc.
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 # The trick is to create an un-stat'able symlink and to see if ls
22 # can report its type nonetheless, using dirent.d_type.
24 if test "$VERBOSE" = yes; then
31 # Skip this test unless "." is on a file system with useful d_type info.
32 # FIXME: This uses "ls -p" to decide whether to test "ls" with other options,
33 # but if ls's d_type code is buggy then "ls -p" might be buggy too.
34 mkdir -p c/d || framework_failure
35 chmod a-x c || framework_failure
36 if test "X`ls -p c 2>&1`" != Xd/; then
37 skip_test_ "'.' is not on a suitable file system for this test"
40 mkdir d || framework_failure
41 ln -s / d/s || framework_failure
42 chmod 600 d || framework_failure
44 mkdir -p e/a2345 e/b || framework_failure
45 chmod 600 e || framework_failure
48 ls --file-type d > out || fail=1
49 cat <<\EOF > exp || fail=1
53 compare out exp || fail=1
56 # Check for the ls -CF misaligned-columns bug:
57 ls -CF e > out || fail=1
59 # coreutils-6.0 would print two spaces after the first slash,
60 # rather than the appropriate TAB.
61 printf 'a2345/\tb/\n' > exp || fail=1
63 compare out exp || fail=1