[LTP] [PATCH v8] fsconfig03: SKIP check return value for old kernel

Wei Gao wegao@suse.com
Sat Mar 4 03:03:15 CET 2023


Signed-off-by: Wei Gao <wegao@suse.com>
Reviewed-by: Petr Vorel <pvorel@suse.cz>
---
 .../kernel/syscalls/fsconfig/fsconfig03.c     | 37 ++++++++++++-------
 1 file changed, 24 insertions(+), 13 deletions(-)

diff --git a/testcases/kernel/syscalls/fsconfig/fsconfig03.c b/testcases/kernel/syscalls/fsconfig/fsconfig03.c
index 7ee37f4ae..f421b5802 100644
--- a/testcases/kernel/syscalls/fsconfig/fsconfig03.c
+++ b/testcases/kernel/syscalls/fsconfig/fsconfig03.c
@@ -22,36 +22,47 @@
 #define MNTPOINT	"mntpoint"
 
 static int fd = -1;
+static long pagesize;
 
 static void setup(void)
 {
-	fsopen_supported_by_kernel();
-}
+	pagesize = sysconf(_SC_PAGESIZE);
 
-static void run(void)
-{
-	char *val = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
-	long pagesize;
+	if (pagesize == -1)
+		tst_brk(TBROK, "sysconf(_SC_PAGESIZE) failed");
+
+	fsopen_supported_by_kernel();
 
 	TEST(fd = fsopen(tst_device->fs_type, 0));
 	if (fd == -1)
 		tst_brk(TBROK | TTERRNO, "fsopen() failed");
+}
 
-	pagesize = sysconf(_SC_PAGESIZE);
-	if (pagesize == -1)
-		tst_brk(TBROK, "sysconf(_SC_PAGESIZE) failed");
+static void do_fsconfig(size_t i)
+{
+	char *val = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
 
-	for (size_t i = 0; i < 5000; i++) {
-		/* use same logic in kernel legacy_parse_param function */
-		const size_t len = i * (strlen(val) + 2) + (strlen(val) + 1) + 2;
+	/* use same logic in kernel legacy_parse_param function */
+	const size_t len = i * (strlen(val) + 2) + (strlen(val) + 1) + 2;
 
+	if ((tst_kvercmp(5, 17, 0)) >= 0) {
 		if (!strcmp(tst_device->fs_type, "btrfs") && len <= (size_t)pagesize)
 			TST_EXP_PASS_SILENT(fsconfig(fd, FSCONFIG_SET_STRING, "\x00", val, 0));
 		else
 			TST_EXP_FAIL_SILENT(fsconfig(fd, FSCONFIG_SET_STRING, "\x00", val, 0),
-					    EINVAL);
+					EINVAL);
+	} else {
+		fsconfig(fd, FSCONFIG_SET_STRING, "\x00", val, 0);
 	}
 
+}
+
+static void run(void)
+{
+
+	for (size_t i = 0; i < 5000; i++)
+		do_fsconfig(i);
+
 	if (fd != -1)
 		SAFE_CLOSE(fd);
 
-- 
2.35.3



More information about the ltp mailing list