syscalls/statx04: use stx_attributes_mask before test
diff mbox series

Message ID 1564742081-2234-1-git-send-email-xuyang2018.jy@cn.fujitsu.com
State Changes Requested
Headers show
Series
  • syscalls/statx04: use stx_attributes_mask before test
Related show

Commit Message

Yang Xu Aug. 2, 2019, 10:34 a.m. UTC
stx_attributes_mask shows what's supported in stx_attributes.
we should check four attrbutes whether supports on tested filesystem
and report the non-supported attributes  before test.

Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
---
 testcases/kernel/syscalls/statx/statx04.c | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

Comments

Cyril Hrubis Aug. 2, 2019, 11:50 a.m. UTC | #1
Hi!
> +	/* Mask to show which attributes are supported on filesystem. */
> +	if ((buf.stx_attributes_mask & FS_COMPR_FL) == 0)
> +		tst_brk(TCONF, "filesystem doesn't support FS_COMPR_FL");
> +	if ((buf.stx_attributes_mask & FS_APPEND_FL) == 0)
> +		tst_brk(TCONF, "filesystem doesn't support FS_APPEND_FL");
> +	if ((buf.stx_attributes_mask & FS_IMMUTABLE_FL) == 0)
> +		tst_brk(TCONF, "filesystem doesn't support FS_IMMUTABLE_FL");
> +	if ((buf.stx_attributes_mask & FS_NODUMP_FL) == 0)
> +		tst_brk(TCONF, "filesystem doesn't support FS_NODUMP_FL");

I doubt that all these flags are either set or unset for a given
fileystem, can we rather than this set flags such as supp_compr etc and
disable only tests for a subset of unsupported flags rather than the
whole test?

Patch
diff mbox series

diff --git a/testcases/kernel/syscalls/statx/statx04.c b/testcases/kernel/syscalls/statx/statx04.c
index 71de734f5..e4b198c07 100644
--- a/testcases/kernel/syscalls/statx/statx04.c
+++ b/testcases/kernel/syscalls/statx/statx04.c
@@ -138,23 +138,37 @@  static void caid_flags_setup(void)
 	attr |= FS_COMPR_FL | FS_APPEND_FL | FS_IMMUTABLE_FL | FS_NODUMP_FL;
 
 	ret = ioctl(fd, FS_IOC_SETFLAGS, &attr);
-	if (ret < 0) {
-		if (errno == EOPNOTSUPP)
-			tst_brk(TCONF, "Flags not supported");
+	if (ret < 0)
 		tst_brk(TBROK | TERRNO, "ioctl(%i, FS_IOC_SETFLAGS, %i)", fd, attr);
-	}
 
 	clear_flags = 1;
 }
 
 static void setup(void)
 {
+	struct statx buf;
+
 	SAFE_MKDIR(TESTDIR_FLAGGED, 0777);
 	SAFE_MKDIR(TESTDIR_UNFLAGGED, 0777);
 
 	if (!strcmp(tst_device->fs_type, "btrfs") && tst_kvercmp(4, 13, 0) < 0)
 		tst_brk(TCONF, "Btrfs statx() supported since 4.13");
 
+	TEST(statx(AT_FDCWD, TESTDIR_FLAGGED, 0, 0, &buf));
+	if (TST_RET == -1)
+		tst_brk(TFAIL | TTERRNO,
+			"sys_statx(AT_FDCWD, %s, 0, 0, &buf)", TESTDIR_FLAGGED);
+
+	/* Mask to show which attributes are supported on filesystem. */
+	if ((buf.stx_attributes_mask & FS_COMPR_FL) == 0)
+		tst_brk(TCONF, "filesystem doesn't support FS_COMPR_FL");
+	if ((buf.stx_attributes_mask & FS_APPEND_FL) == 0)
+		tst_brk(TCONF, "filesystem doesn't support FS_APPEND_FL");
+	if ((buf.stx_attributes_mask & FS_IMMUTABLE_FL) == 0)
+		tst_brk(TCONF, "filesystem doesn't support FS_IMMUTABLE_FL");
+	if ((buf.stx_attributes_mask & FS_NODUMP_FL) == 0)
+		tst_brk(TCONF, "filesystem doesn't support FS_NODUMP_FL");
+
 	caid_flags_setup();
 }