generic/401: fix test in case of no filetype support

Xu Huan reported that this test fails on nfs in some setup.
Apparently, the assumptions made about xfs/ext* do not hold
for nfs.

Relax the verification of filetype not supported case to
allow either DT_UNKNOWN or actual file type on all files and
not only on special dir entires "." and "..".

Convert the unknown d_type replacement code from awk to bash
so it is a bit more readable and flexible.

Reported-by: Xu Huan <xuhuan.fnst@cn.fujitsu.com>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Tested-by: Xu Huan <xuhuan.fnst@cn.fujitsu.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
This commit is contained in:
Amir Goldstein
2018-06-05 11:08:50 +03:00
committed by Eryu Guan
parent 668a411a73
commit b22c18ca9c
+20 -22
View File
@@ -4,14 +4,13 @@
# Test filetype feature # Test filetype feature
# #
# This test does NOT require that file system support the d_type feature. # This test does NOT require that file system support the d_type feature.
# It verifies that either all file types are reported as DT_UNKNOWN # It verifies that file types are reported as either DT_UNKNOWN or as
# or all file types are reported correctly. # the actual file type. For example, special dir entries . and .. MAY be
# reported as DT_UNKNOWN IF filetype feature is disabled (ext4), but MAY
# also be reported as DT_DIR in this case (xfs).
# #
# For fs for which we know how to test the filetype feature (xfs|ext*) # For fs for which we know how to test the filetype feature (xfs|ext*)
# verify getting DT_UNKNOWN IFF feature is disabled. # verify getting DT_UNKNOWN IFF feature is disabled.
# Special dir entries . and .. MAY be reported as DT_UNKNOWN IF filetype
# feature is disabled (ext4), but MAY also be reported as DT_DIR in this
# case (xfs).
# #
#----------------------------------------------------------------------- #-----------------------------------------------------------------------
# #
@@ -73,23 +72,22 @@ mknod $testdir/c c 1 1
mknod $testdir/b b 1 1 mknod $testdir/b b 1 1
mknod $testdir/p p mknod $testdir/p p
# Test d_type of . and .. # Test d_type of test files - it must be the actual file type on fs
# it must be DT_DIR on fs with filetype support and it could be # with filetype support and it could be either the actual file type
# either DR_DIR or DT_UNKNOWN on fs without filetype support # or DT_UNKNOWN on fs without filetype support
src/t_dir_type $testdir d | grep -F '.' | sort ftype=
_supports_filetype $SCRATCH_MNT && ftype=1
# Test that either all file types are unknown or all are correct src/t_dir_type $testdir | \
if _supports_filetype $SCRATCH_MNT; then while read name type; do
# print real file types if [ "$ftype" != 1 -a "$type" = u ]; then
src/t_dir_type $testdir | grep -vF '.' | sort if [ "$name" = "." -o "$name" = ".." ]; then
else type=d
# print fake dir file type for . and .. if they are DT_UNKNOWN else
src/t_dir_type $testdir u | grep -F '.' | \ type=$name
awk '{ print $1, "d" }' | sort fi
# list unknown files and print filename as fake file type fi
src/t_dir_type $testdir u | grep -vF '.' | \ echo $name $type
awk '{ print $1, $1 }' | sort done | sort
fi
status=0 status=0
exit exit