All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/3] fstests: dirent file type tests
@ 2016-12-20 13:17 Amir Goldstein
  2016-12-20 13:17 ` [PATCH v2 1/3] common/rc: factor out _supports_filetype() helper Amir Goldstein
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Amir Goldstein @ 2016-12-20 13:17 UTC (permalink / raw)
  To: Eryu Guan
  Cc: Dave Chinner, Christoph Hellwig, Darrick J . Wong,
	Miklos Szeredi, fstests

generic/396 runs some tests on directory file types.

_supports_filetype() helper is used by this test
and by overlayfs to check for file type support of upper
dir fs.

Tested with tmpfs, ext2, ext4, xfs for d_type supported fs
and with xfs -m crc=0 -n ftype=0 for d_type unsupported fs

Tested that overlay tests run over tmpfs (generic ftype check)
Tested that overlay tests run over xfs (ftype=1)
Tested that overlay tests do not run over xfs (ftype=0)

v2:
- use helper to test for file type support
- allow DT_UNKNOWN type, but only for all files
- verify . and .. have DT_DIR type

v1:
- verify that d_type matches actual file type

Amir Goldstein (3):
  common/rc: factor out _supports_filetype() helper
  common/rc: add generic file type support check
  generic/396: test correct d_type values

 .gitignore            |   1 +
 common/rc             |  42 +++++++++++++-------
 src/Makefile          |   2 +-
 src/t_dir_type.c      | 108 ++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/396     |  87 ++++++++++++++++++++++++++++++++++++++++
 tests/generic/396.out |   9 +++++
 tests/generic/group   |   1 +
 7 files changed, 235 insertions(+), 15 deletions(-)
 create mode 100644 src/t_dir_type.c
 create mode 100755 tests/generic/396
 create mode 100644 tests/generic/396.out

-- 
2.7.4

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2 1/3] common/rc: factor out _supports_filetype() helper
  2016-12-20 13:17 [PATCH v2 0/3] fstests: dirent file type tests Amir Goldstein
@ 2016-12-20 13:17 ` Amir Goldstein
  2016-12-20 13:17 ` [PATCH v2 2/3] common/rc: add generic file type support check Amir Goldstein
  2016-12-20 13:17 ` [PATCH v2 3/3] generic/396: test correct d_type values Amir Goldstein
  2 siblings, 0 replies; 6+ messages in thread
From: Amir Goldstein @ 2016-12-20 13:17 UTC (permalink / raw)
  To: Eryu Guan
  Cc: Dave Chinner, Christoph Hellwig, Darrick J . Wong,
	Miklos Szeredi, fstests

_overlay_mount_dirs() checks for the filetype feature
on upper dir fs.

factor out that feature test to a helper.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
 common/rc | 33 +++++++++++++++++++--------------
 1 file changed, 19 insertions(+), 14 deletions(-)

diff --git a/common/rc b/common/rc
index 2639fbd..288517f 100644
--- a/common/rc
+++ b/common/rc
@@ -264,6 +264,23 @@ _scratch_mount_options()
 					$SCRATCH_DEV $SCRATCH_MNT
 }
 
+_supports_filetype()
+{
+	local dir=$1
+	shift 1
+
+	local upper_fst=$(df --output=fstype $dir | tail -1)
+	case "$upper_fst" in
+	xfs)
+		xfs_info $dir | grep -q "ftype=1"
+		;;
+	ext2|ext3|ext4)
+		tune2fs -l $(df --output=source $dir | tail -1) | \
+		   grep -q filetype
+		;;
+	esac
+}
+
 # helper function to do the actual overlayfs mount operation
 _overlay_mount_dirs()
 {
@@ -284,20 +301,8 @@ _overlay_mount()
 	local mnt=$2
 	shift 2
 
-	local upper_fst=$(df --output=fstype $dir | tail -1)
-	case "$upper_fst" in
-	xfs)
-		if ! xfs_info $dir | grep -q "ftype=1" ; then
-			_notrun "upper fs needs to support d_type"
-		fi
-		;;
-	ext2|ext3|ext4)
-		if ! tune2fs -l $(df --output=source $dir | tail -1) | \
-		   grep -q filetype ; then
-			_notrun "upper fs needs to support d_type"
-		fi
-		;;
-	esac
+	_supports_filetype $dir || \
+		_notrun "upper fs needs to support d_type"
 
 	mkdir -p $dir/$OVERLAY_UPPER_DIR
 	mkdir -p $dir/$OVERLAY_LOWER_DIR
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 2/3] common/rc: add generic file type support check
  2016-12-20 13:17 [PATCH v2 0/3] fstests: dirent file type tests Amir Goldstein
  2016-12-20 13:17 ` [PATCH v2 1/3] common/rc: factor out _supports_filetype() helper Amir Goldstein
@ 2016-12-20 13:17 ` Amir Goldstein
  2016-12-20 13:17 ` [PATCH v2 3/3] generic/396: test correct d_type values Amir Goldstein
  2 siblings, 0 replies; 6+ messages in thread
From: Amir Goldstein @ 2016-12-20 13:17 UTC (permalink / raw)
  To: Eryu Guan
  Cc: Dave Chinner, Christoph Hellwig, Darrick J . Wong,
	Miklos Szeredi, fstests

_supports_filetype() helper checks if the filetype feature
is enabled for xfs and ext* file sytems.

Add a check for the generic case where we don't know
how to test file system filetype feature.

Introduce a helper utility t_dir_type that lists directory
entries filtered by file type.

Check for filetype feature by expecting to find no directory
entries listed as DT_UNKNOWN inside a test directory.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
 .gitignore       |   1 +
 common/rc        |   9 +++++
 src/Makefile     |   2 +-
 src/t_dir_type.c | 108 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 119 insertions(+), 1 deletion(-)
 create mode 100644 src/t_dir_type.c

diff --git a/.gitignore b/.gitignore
index b8d13a0..7dcea14 100644
--- a/.gitignore
+++ b/.gitignore
@@ -94,6 +94,7 @@
 /src/t_access_root
 /src/t_dir_offset
 /src/t_dir_offset2
+/src/t_dir_type
 /src/t_futimens
 /src/t_getcwd
 /src/t_holes
diff --git a/common/rc b/common/rc
index 288517f..a779c50 100644
--- a/common/rc
+++ b/common/rc
@@ -278,6 +278,15 @@ _supports_filetype()
 		tune2fs -l $(df --output=source $dir | tail -1) | \
 		   grep -q filetype
 		;;
+	*)
+		testfile=$dir/$$.ftype
+		touch $testfile
+		# look for DT_UNKNOWN files
+		unknowns=$(src/t_dir_type $dir u | wc -l)
+		rm $testfile
+		# 0 unknowns is success
+		return $unknowns
+		;;
 	esac
 }
 
diff --git a/src/Makefile b/src/Makefile
index 4056496..94d74aa 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -21,7 +21,7 @@ LINUX_TARGETS = xfsctl bstat t_mtab getdevicesize preallo_rw_pattern_reader \
 	stale_handle pwrite_mmap_blocked t_dir_offset2 seek_sanity_test \
 	seek_copy_test t_readdir_1 t_readdir_2 fsync-tester nsexec cloner \
 	renameat2 t_getcwd e4compact test-nextquota punch-alternating \
-	attr-list-by-handle-cursor-test listxattr dio-interleaved
+	attr-list-by-handle-cursor-test listxattr dio-interleaved t_dir_type
 
 SUBDIRS =
 
diff --git a/src/t_dir_type.c b/src/t_dir_type.c
new file mode 100644
index 0000000..344bef8
--- /dev/null
+++ b/src/t_dir_type.c
@@ -0,0 +1,108 @@
+/*
+ * Copyright (C) 2016 CTERA Networks. All Rights Reserved.
+ * Author: Amir Goldstein <amir73il@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write the Free Software Foundation,
+ * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+/*
+ * t_dir_type
+ *
+ * print directory entries, optionally filtered by d_type
+ *
+ * ./t_dir_type <path> [u|f|d|c|b|l|p|s|w]
+ */
+
+#include <fcntl.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <dirent.h>
+#include <sys/stat.h>
+#include <sys/syscall.h>
+
+struct linux_dirent64 {
+	uint64_t	d_ino;
+	int64_t		d_off;
+	unsigned short	d_reclen;
+	unsigned char	d_type;
+	char		d_name[0];
+};
+
+#define DT_MASK 15
+#define DT_MAX 15
+unsigned char type_to_char[DT_MAX] = {
+	[DT_UNKNOWN] = 'u',
+	[DT_DIR] = 'd',
+	[DT_REG] = 'f',
+	[DT_LNK] = 'l',
+	[DT_CHR] = 'c',
+	[DT_BLK] = 'b',
+	[DT_FIFO] = 'p',
+	[DT_SOCK] = 's',
+	[DT_WHT] = 'w',
+};
+
+#define DT_CHAR(t) type_to_char[(t)&DT_MASK]
+
+#define BUF_SIZE 4096
+
+int
+main(int argc, char *argv[])
+{
+	int fd, nread;
+	char buf[BUF_SIZE];
+	struct linux_dirent64 *d;
+	int bpos;
+	int type = -1; /* -1 means all types */
+	int ret = 1;
+
+	fd = open(argv[1], O_RDONLY | O_DIRECTORY);
+	if (fd < 0) {
+		perror("open");
+		exit(EXIT_FAILURE);
+	}
+
+	if (argc > 2 && argv[2][0]) {
+		char t = argv[2][0];
+
+		for (type = DT_MAX-1; type >= 0; type--)
+			if (DT_CHAR(type) == t)
+				break;
+		/* no match ends up with type = -1 */
+	}
+
+	for ( ; ; ) {
+		nread = syscall(SYS_getdents64, fd, buf, BUF_SIZE);
+		if (nread == -1) {
+			perror("getdents");
+			exit(EXIT_FAILURE);
+		}
+
+		if (nread == 0)
+			break;
+
+		for (bpos = 0; bpos < nread;) {
+			d = (struct linux_dirent64 *) (buf + bpos);
+			if (type < 0 || type == (int)d->d_type) {
+				ret = 0;
+				printf("%s %c\n", d->d_name, DT_CHAR(d->d_type));
+			}
+			bpos += d->d_reclen;
+		}
+	}
+
+	return ret;
+}
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 3/3] generic/396: test correct d_type values
  2016-12-20 13:17 [PATCH v2 0/3] fstests: dirent file type tests Amir Goldstein
  2016-12-20 13:17 ` [PATCH v2 1/3] common/rc: factor out _supports_filetype() helper Amir Goldstein
  2016-12-20 13:17 ` [PATCH v2 2/3] common/rc: add generic file type support check Amir Goldstein
@ 2016-12-20 13:17 ` Amir Goldstein
  2016-12-21 13:50   ` [PATCH v3 " Amir Goldstein
  2 siblings, 1 reply; 6+ messages in thread
From: Amir Goldstein @ 2016-12-20 13:17 UTC (permalink / raw)
  To: Eryu Guan
  Cc: Dave Chinner, Christoph Hellwig, Darrick J . Wong,
	Miklos Szeredi, fstests

Verify correct d_type values of dir entries.

This test does NOT require that file system support the filetype feature.
It verifies that either all file types are reported as DT_UNKNOWN
or that all file types are reported correctly.

For fs for which we know how to test the filetype feature (xfs|ext*)
verify getting DT_UNKNOWN IFF feature is disabled.

Verify special dir entries . and .. are always reported as DT_DIR.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
 tests/generic/396     | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/396.out |  9 ++++++
 tests/generic/group   |  1 +
 3 files changed, 97 insertions(+)
 create mode 100755 tests/generic/396
 create mode 100644 tests/generic/396.out

diff --git a/tests/generic/396 b/tests/generic/396
new file mode 100755
index 0000000..fbd2e79
--- /dev/null
+++ b/tests/generic/396
@@ -0,0 +1,87 @@
+#! /bin/bash
+# FSQA Test No. 396
+#
+# Test filetype 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
+# or all file types are reported correctly.
+#
+# For fs for which we know how to test the filetype feature (xfs|ext*)
+# verify getting DT_UNKNOWN IFF feature is disabled.
+#
+# Verify special dir entries . and .. are always reported as DT_DIR.
+#
+#-----------------------------------------------------------------------
+#
+# Copyright (C) 2016 CTERA Networks. All Rights Reserved.
+# Author: Amir Goldstein <amir73il@gmail.com>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+#
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+tmp=/tmp/$$
+status=1	# failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	rm -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_fs generic
+_supported_os Linux
+_require_scratch
+
+rm -f $seqres.full
+
+_scratch_mkfs >>$seqres.full 2>&1
+
+_scratch_mount
+
+# Create our test files.
+testdir=$SCRATCH_MNT/find-by-type
+mkdir -p $testdir
+mkdir $testdir/d
+touch $testdir/f
+ln -s $testdir/f $testdir/l
+mknod $testdir/c c 1 1
+mknod $testdir/b b 1 1
+mknod $testdir/p p
+
+# Test d_type DT_DIR for . and ..
+# this should be correct on all fs regardless of filetype feature
+src/t_dir_type $testdir d | grep -F '.' | sort
+
+# Test that either all file type are unknown or all are valid
+if _supports_filetype $testdir; then
+	# print real file types
+	src/t_dir_type $testdir | grep -vF '.' | sort
+else
+	# list unknown files and print filename as fake file type
+	src/t_dir_type $testdir u | awk '{ print $1, $1 }' | sort
+fi
+
+status=0
+exit
diff --git a/tests/generic/396.out b/tests/generic/396.out
new file mode 100644
index 0000000..de11c24
--- /dev/null
+++ b/tests/generic/396.out
@@ -0,0 +1,9 @@
+QA output created by 396
+. d
+.. d
+b b
+c c
+d d
+f f
+l l
+p p
diff --git a/tests/generic/group b/tests/generic/group
index 20b31ef..24c242f 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -397,3 +397,4 @@
 392 auto quick metadata
 393 auto quick rw
 394 auto quick
+396 auto quick
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v3 3/3] generic/396: test correct d_type values
  2016-12-20 13:17 ` [PATCH v2 3/3] generic/396: test correct d_type values Amir Goldstein
@ 2016-12-21 13:50   ` Amir Goldstein
  2016-12-24 12:20     ` Eryu Guan
  0 siblings, 1 reply; 6+ messages in thread
From: Amir Goldstein @ 2016-12-21 13:50 UTC (permalink / raw)
  To: Eryu Guan
  Cc: Dave Chinner, Christoph Hellwig, Darrick J . Wong,
	Theodore Ts'o, fstests

Verify correct d_type values of dir entries.

This test does NOT require that file system support the filetype feature.
It verifies that either all file types are reported as DT_UNKNOWN
or that all file types are reported correctly.

For fs for which we know how to test the filetype feature (xfs|ext*)
verify getting DT_UNKNOWN IFF filetype 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).

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
 tests/generic/396     | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/396.out |  9 +++++
 tests/generic/group   |  1 +
 3 files changed, 103 insertions(+)
 create mode 100755 tests/generic/396
 create mode 100644 tests/generic/396.out

Added another test to the matrix, found another special case to handle:
ext4 vs. xfs returns DT_UNKNOWN for . and .. on ! _supports_filetype.

Fixes the test to correctly handle both cases.

Tested with tmpfs, ext2, ext4, xfs for d_type supported fs
Tested with xfs -m crc=0 -n ftype=0 for d_type unsupported fs
Tested with ext2/ext4 -O ^filetype  for d_type unsupported fs

v3:
- allow DT_UNKNOWN type for . and .. when filetype feature is disabled (ext4)

v2:
- use helper to test for file type support
- allow DT_UNKNOWN type, but only for all files
- verify . and .. have DT_DIR type

v1:
- verify that d_type matches actual file type

diff --git a/tests/generic/396 b/tests/generic/396
new file mode 100755
index 0000000..0d4a17d
--- /dev/null
+++ b/tests/generic/396
@@ -0,0 +1,93 @@
+#! /bin/bash
+# FSQA Test No. 396
+#
+# Test filetype 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
+# or all file types are reported correctly.
+#
+# For fs for which we know how to test the filetype feature (xfs|ext*)
+# 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).
+#
+#-----------------------------------------------------------------------
+#
+# Copyright (C) 2016 CTERA Networks. All Rights Reserved.
+# Author: Amir Goldstein <amir73il@gmail.com>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+#
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+tmp=/tmp/$$
+status=1	# failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	rm -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_fs generic
+_supported_os Linux
+_require_scratch
+
+rm -f $seqres.full
+
+_scratch_mkfs >>$seqres.full 2>&1
+
+_scratch_mount
+
+# Create our test files.
+testdir=$SCRATCH_MNT/find-by-type
+mkdir -p $testdir
+mkdir $testdir/d
+touch $testdir/f
+ln -s $testdir/f $testdir/l
+mknod $testdir/c c 1 1
+mknod $testdir/b b 1 1
+mknod $testdir/p p
+
+# Test d_type of . and ..
+# it must be DT_DIR on fs with filetype support and it could be
+# either DR_DIR or DT_UNKNOWN on fs without filetype support
+src/t_dir_type $testdir d | grep -F '.' | sort
+
+# Test that either all file types are unknown or all are correct
+if _supports_filetype $testdir; then
+	# print real file types
+	src/t_dir_type $testdir | grep -vF '.' | sort
+else
+	# print fake dir file type for . and .. if they are DT_UNKNOWN
+	src/t_dir_type $testdir u | grep -F '.' | \
+		awk '{ print $1, "d" }' | sort
+	# list unknown files and print filename as fake file type
+	src/t_dir_type $testdir u | grep -vF '.' | \
+		awk '{ print $1, $1 }' | sort
+fi
+
+status=0
+exit
diff --git a/tests/generic/396.out b/tests/generic/396.out
new file mode 100644
index 0000000..de11c24
--- /dev/null
+++ b/tests/generic/396.out
@@ -0,0 +1,9 @@
+QA output created by 396
+. d
+.. d
+b b
+c c
+d d
+f f
+l l
+p p
diff --git a/tests/generic/group b/tests/generic/group
index 20b31ef..24c242f 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -397,3 +397,4 @@
 392 auto quick metadata
 393 auto quick rw
 394 auto quick
+396 auto quick
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v3 3/3] generic/396: test correct d_type values
  2016-12-21 13:50   ` [PATCH v3 " Amir Goldstein
@ 2016-12-24 12:20     ` Eryu Guan
  0 siblings, 0 replies; 6+ messages in thread
From: Eryu Guan @ 2016-12-24 12:20 UTC (permalink / raw)
  To: Amir Goldstein
  Cc: Dave Chinner, Christoph Hellwig, Darrick J . Wong,
	Theodore Ts'o, fstests

On Wed, Dec 21, 2016 at 03:50:21PM +0200, Amir Goldstein wrote:
> Verify correct d_type values of dir entries.
> 
> This test does NOT require that file system support the filetype feature.
> It verifies that either all file types are reported as DT_UNKNOWN
> or that all file types are reported correctly.
> 
> For fs for which we know how to test the filetype feature (xfs|ext*)
> verify getting DT_UNKNOWN IFF filetype 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).
> 
> Signed-off-by: Amir Goldstein <amir73il@gmail.com>
> ---
>  tests/generic/396     | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++
>  tests/generic/396.out |  9 +++++
>  tests/generic/group   |  1 +
>  3 files changed, 103 insertions(+)
>  create mode 100755 tests/generic/396
>  create mode 100644 tests/generic/396.out
> 
> Added another test to the matrix, found another special case to handle:
> ext4 vs. xfs returns DT_UNKNOWN for . and .. on ! _supports_filetype.
> 
> Fixes the test to correctly handle both cases.
> 
> Tested with tmpfs, ext2, ext4, xfs for d_type supported fs
> Tested with xfs -m crc=0 -n ftype=0 for d_type unsupported fs
> Tested with ext2/ext4 -O ^filetype  for d_type unsupported fs
> 
> v3:
> - allow DT_UNKNOWN type for . and .. when filetype feature is disabled (ext4)
> 
> v2:
> - use helper to test for file type support
> - allow DT_UNKNOWN type, but only for all files
> - verify . and .. have DT_DIR type
> 
> v1:
> - verify that d_type matches actual file type
> 
> diff --git a/tests/generic/396 b/tests/generic/396
> new file mode 100755
> index 0000000..0d4a17d
> --- /dev/null
> +++ b/tests/generic/396
> @@ -0,0 +1,93 @@
> +#! /bin/bash
> +# FSQA Test No. 396
> +#
> +# Test filetype 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
> +# or all file types are reported correctly.
> +#
> +# For fs for which we know how to test the filetype feature (xfs|ext*)
> +# 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).
> +#
> +#-----------------------------------------------------------------------
> +#
> +# Copyright (C) 2016 CTERA Networks. All Rights Reserved.
> +# Author: Amir Goldstein <amir73il@gmail.com>
> +#
> +# This program is free software; you can redistribute it and/or
> +# modify it under the terms of the GNU General Public License as
> +# published by the Free Software Foundation.
> +#
> +# This program is distributed in the hope that it would be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program; if not, write the Free Software Foundation,
> +# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
> +#-----------------------------------------------------------------------
> +#
> +
> +seq=`basename $0`
> +seqres=$RESULT_DIR/$seq
> +echo "QA output created by $seq"
> +
> +tmp=/tmp/$$
> +status=1	# failure is the default!
> +trap "_cleanup; exit \$status" 0 1 2 3 15
> +
> +_cleanup()
> +{
> +	rm -f $tmp.*
> +}
> +
> +# get standard environment, filters and checks
> +. ./common/rc
> +. ./common/filter
> +
> +# real QA test starts here
> +_supported_fs generic
> +_supported_os Linux
> +_require_scratch

I added a "_require_test_program t_dir_type" here and merged.

Thanks,
Eryu

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-12-24 12:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-20 13:17 [PATCH v2 0/3] fstests: dirent file type tests Amir Goldstein
2016-12-20 13:17 ` [PATCH v2 1/3] common/rc: factor out _supports_filetype() helper Amir Goldstein
2016-12-20 13:17 ` [PATCH v2 2/3] common/rc: add generic file type support check Amir Goldstein
2016-12-20 13:17 ` [PATCH v2 3/3] generic/396: test correct d_type values Amir Goldstein
2016-12-21 13:50   ` [PATCH v3 " Amir Goldstein
2016-12-24 12:20     ` Eryu Guan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.