2 # Ensure that ls --file-type does not call stat unnecessarily.
3 # The trick is to create an un-stat'able symlink and to see if ls
4 # can report its type nonetheless, using dirent.d_type.
6 if test "$VERBOSE" = yes; then
11 . $srcdir/../envvar-check
13 # Skip this test unless "." is on a file system with useful d_type info.
14 # FIXME: use a more dynamic test for this, since whether d_type is useful
15 # depends on much more than the file system type. For example, with
16 # linux-2.6.15, at least tmpfs and ext3 work, but reiserfs and xfs don't.
17 # Also, tmpfs on Solaris 10 lacks d_type support.
19 fs_type=`stat -f --printf %T .`
20 test `uname -s` = Linux && test $fs_type = tmpfs && skip=no
21 test $fs_type = ext2/ext3 && skip=no
24 echo "$0: '.' is not on a suitable file system for this test" 1>&2
25 echo "$0: skipping this test" 1>&2
30 t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
31 trap 'status=$?; cd $pwd; chmod -R u+rwx $t0; rm -rf $t0 && exit $status' 0
32 trap '(exit $?); exit $?' 1 2 13 15
35 mkdir -p $tmp || framework_failure=1
36 cd $tmp || framework_failure=1
38 mkdir d || framework_failure=1
39 ln -s / d/s || framework_failure=1
40 chmod 600 d || framework_failure=1
42 if test $framework_failure = 1; then
43 echo "$0: failure in testing framework" 1>&2
49 ls --file-type d > out || fail=1
50 cat <<\EOF > exp || fail=1
55 test $fail = 1 && diff out exp 2> /dev/null
57 (exit $fail); exit $fail