common/fuzzy: try to clear blocking flags first in _scratch_fuzz_modify
[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_mknod
42 _require_test_program "t_dir_type"
43
44 rm -f $seqres.full
45
46 _scratch_mkfs >>$seqres.full 2>&1
47
48 _scratch_mount
49
50 # Create our test files.
51 testdir=$SCRATCH_MNT/find-by-type
52 mkdir -p $testdir
53 mkdir $testdir/d
54 touch $testdir/f
55 ln -s $testdir/f $testdir/l
56 mknod $testdir/c c 1 1
57 mknod $testdir/b b 1 1
58 mknod $testdir/p p
59
60 # Test d_type of test files - it must be the actual file type on fs
61 # with filetype support and it could be either the actual file type
62 # or DT_UNKNOWN on fs without filetype support
63 ftype=
64 _supports_filetype $SCRATCH_MNT && ftype=1
65 $here/src/t_dir_type $testdir | \
66 while read name type; do
67         if [ "$ftype" != 1 -a "$type" = u ]; then
68                 if [ "$name" = "." -o "$name" = ".." ]; then
69                         type=d
70                 else
71                         type=$name
72                 fi
73         fi
74         echo $name $type
75 done | sort
76
77 status=0
78 exit