fstests: use _require_symlinks on all necessary tests
[xfstests-dev.git] / tests / generic / 401
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2016 CTERA Networks. All Rights Reserved.
4 #
5 # FSQA Test No. 401
6 #
7 # Test filetype feature
8 #
9 # This test does NOT require that file system support the d_type feature.
10 # It verifies that file types are reported as either DT_UNKNOWN or as
11 # the actual file type. For example, special dir entries . and .. MAY be
12 # reported as DT_UNKNOWN IF filetype feature is disabled (ext4), but MAY
13 # also be reported as DT_DIR in this case (xfs).
14 #
15 # For fs for which we know how to test the filetype feature (xfs|ext*)
16 # verify getting DT_UNKNOWN IFF feature is disabled.
17 #
18 seq=`basename $0`
19 seqres=$RESULT_DIR/$seq
20 echo "QA output created by $seq"
21
22 tmp=/tmp/$$
23 status=1        # failure is the default!
24 trap "_cleanup; exit \$status" 0 1 2 3 15
25
26 _cleanup()
27 {
28         cd /
29         rm -f $tmp.*
30 }
31
32 # get standard environment, filters and checks
33 . ./common/rc
34 . ./common/filter
35
36 # real QA test starts here
37 _supported_fs generic
38 _supported_os Linux
39 _require_scratch
40 _require_symlinks
41 _require_test_program "t_dir_type"
42
43 rm -f $seqres.full
44
45 _scratch_mkfs >>$seqres.full 2>&1
46
47 _scratch_mount
48
49 # Create our test files.
50 testdir=$SCRATCH_MNT/find-by-type
51 mkdir -p $testdir
52 mkdir $testdir/d
53 touch $testdir/f
54 ln -s $testdir/f $testdir/l
55 mknod $testdir/c c 1 1
56 mknod $testdir/b b 1 1
57 mknod $testdir/p p
58
59 # Test d_type of test files - it must be the actual file type on fs
60 # with filetype support and it could be either the actual file type
61 # or DT_UNKNOWN on fs without filetype support
62 ftype=
63 _supports_filetype $SCRATCH_MNT && ftype=1
64 $here/src/t_dir_type $testdir | \
65 while read name type; do
66         if [ "$ftype" != 1 -a "$type" = u ]; then
67                 if [ "$name" = "." -o "$name" = ".." ]; then
68                         type=d
69                 else
70                         type=$name
71                 fi
72         fi
73         echo $name $type
74 done | sort
75
76 status=0
77 exit