All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH v1] tst_filesystems01.c: Add test for .filesystems
@ 2025-05-29 10:51 Wei Gao via ltp
  2025-09-16 11:02 ` Petr Vorel
  2025-09-24  8:42 ` [LTP] [PATCH v2] " Wei Gao via ltp
  0 siblings, 2 replies; 33+ messages in thread
From: Wei Gao via ltp @ 2025-05-29 10:51 UTC (permalink / raw)
  To: ltp

Fixes: https://github.com/linux-test-project/ltp/issues/1243
Signed-off-by: Wei Gao <wegao@suse.com>
---
 lib/newlib_tests/tst_filesystems01.c | 118 +++++++++++++++++++++++++++
 1 file changed, 118 insertions(+)
 create mode 100644 lib/newlib_tests/tst_filesystems01.c

diff --git a/lib/newlib_tests/tst_filesystems01.c b/lib/newlib_tests/tst_filesystems01.c
new file mode 100644
index 000000000..96f4b2d93
--- /dev/null
+++ b/lib/newlib_tests/tst_filesystems01.c
@@ -0,0 +1,118 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2025 Wei Gao <wegao@suse.com>
+ */
+
+#include "tst_test.h"
+#include "tst_safe_stdio.h"
+
+#define MOUNT_POINT "mount_test_filesystems"
+
+static int check_inode_size(unsigned int size)
+{
+	char path[PATH_MAX];
+	char line[PATH_MAX];
+	FILE *tune2fs;
+	char str_size[NAME_MAX];
+
+	snprintf(str_size, sizeof(str_size), "%u", size);
+	snprintf(path, sizeof(path), "tune2fs -l %s 2>&1", tst_device->dev);
+	tune2fs = SAFE_POPEN(path, "r");
+	if (tune2fs == NULL)
+		tst_brk(TBROK, "Can not popen %s", path);
+
+	while (fgets(line, PATH_MAX, tune2fs)) {
+		if (*line && strstr(line, "Inode size:") && strstr(line, str_size)) {
+			tst_res(TPASS, "check inode size pass");
+			return 0;
+		}
+	}
+
+	pclose(tune2fs);
+	tst_res(TFAIL, "check inode size failed");
+	return -1;
+}
+
+static int check_mnt_data(char *opt)
+{
+	FILE *fp;
+	char line[PATH_MAX];
+
+	fp = SAFE_FOPEN("/proc/mounts", "r");
+	if (fp == NULL)
+		tst_brk(TBROK, "Can not open /proc/mounts");
+	while (fgets(line, PATH_MAX, fp)) {
+		if (*line && strstr(line, tst_device->dev) && strstr(line, opt)) {
+			tst_res(TPASS, "check mnt data pass");
+			return 0;
+		}
+	}
+	SAFE_FCLOSE(fp);
+	tst_res(TFAIL, "check mnt data failed");
+	return -1;
+}
+
+static int check_mkfs_size_opt(unsigned int size)
+{
+	char path[PATH_MAX];
+	char line[PATH_MAX];
+	FILE *dumpe2fs;
+	char str_size[NAME_MAX];
+
+	snprintf(str_size, sizeof(str_size), "%u", size);
+	snprintf(path, sizeof(path), "dumpe2fs -h %s 2>&1", tst_device->dev);
+	dumpe2fs = SAFE_POPEN(path, "r");
+	if (dumpe2fs == NULL)
+		tst_brk(TBROK, "Can not popen %s", path);
+
+	while (fgets(line, PATH_MAX, dumpe2fs)) {
+		if (*line && strstr(line, "Block count:") && strstr(line, str_size)) {
+			tst_res(TPASS, "check mkfs size opt pass");
+			return 0;
+		}
+	}
+
+	pclose(dumpe2fs);
+	tst_res(TFAIL, "check mkfs size opt failed");
+	return -1;
+}
+
+static void do_test(void)
+{
+	long fs_type;
+
+	fs_type = tst_fs_type(MOUNT_POINT);
+
+	if (fs_type == TST_EXT234_MAGIC) {
+		check_inode_size(128);
+		check_mkfs_size_opt(10240);
+	}
+
+	if (fs_type == TST_XFS_MAGIC)
+		check_mnt_data("usrquota");
+}
+
+static struct tst_test test = {
+	.test_all = do_test,
+	.needs_root = 1,
+	.mntpoint = MOUNT_POINT,
+	.mount_device = 1,
+	.needs_cmds = (const char *[]) {
+		"tune2fs",
+		"dumpe2fs",
+		NULL
+	},
+	.filesystems = (struct tst_fs []) {
+		{
+			.type = "ext3",
+			.mkfs_opts = (const char *const []){"-I", "128", NULL},
+			.mkfs_size_opt = "10240",
+		},
+		{
+			.type = "xfs",
+			.mnt_data = "usrquota",
+		},
+		{}
+	},
+
+};
-- 
2.49.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

end of thread, other threads:[~2026-01-28  0:50 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-29 10:51 [LTP] [PATCH v1] tst_filesystems01.c: Add test for .filesystems Wei Gao via ltp
2025-09-16 11:02 ` Petr Vorel
2025-09-24  8:42 ` [LTP] [PATCH v2] " Wei Gao via ltp
2025-10-30 20:17   ` Petr Vorel
2025-10-31  6:33     ` Wei Gao via ltp
2025-10-31  9:13       ` Petr Vorel
2025-11-01  1:20   ` [LTP] [PATCH v3 0/2] " Wei Gao via ltp
2025-11-01  1:20     ` [LTP] [PATCH v3 1/2] " Wei Gao via ltp
2025-11-11 12:06       ` Petr Vorel
2025-11-12  6:51         ` Wei Gao via ltp
2025-11-12  9:22           ` Petr Vorel
2025-11-12 10:32             ` Cyril Hrubis
2025-11-12 11:34               ` Wei Gao via ltp
2025-11-12 11:44                 ` Cyril Hrubis
2025-11-12 12:14                   ` Wei Gao via ltp
2025-11-12 12:21               ` Petr Vorel
2025-11-13  1:28                 ` Wei Gao via ltp
2025-11-01  1:20     ` [LTP] [PATCH v3 2/2] tst_format_device.sh: Add e2fsprogs package for CI test Wei Gao via ltp
2025-11-11 12:22       ` Petr Vorel
2025-11-13  1:52     ` [LTP] [PATCH v4 0/3] tst_filesystems01.c: Add test for .filesystems Wei Gao via ltp
2025-11-13  1:52       ` [LTP] [PATCH v4 1/3] " Wei Gao via ltp
2026-01-22  3:37         ` Li Wang via ltp
2026-01-22  8:02           ` Petr Vorel
2026-01-22  8:54             ` Wei Gao via ltp
2025-11-13  1:52       ` [LTP] [PATCH v4 2/3] ci: Add mount operation for busybox Wei Gao via ltp
2025-11-13  1:52       ` [LTP] [PATCH v4 3/3] ci: Add e2fsprogs package for CI test Wei Gao via ltp
2025-12-18 13:49         ` Andrea Cervesato via ltp
2025-12-18 13:51           ` Andrea Cervesato via ltp
2026-01-23  2:36       ` [LTP] [PATCH v5 0/3] tst_filesystems01.c: Add test for .filesystems Wei Gao via ltp
2026-01-23  2:36         ` [LTP] [PATCH v5 1/3] " Wei Gao via ltp
2026-01-28  0:49           ` Li Wang via ltp
2026-01-23  2:36         ` [LTP] [PATCH v5 2/3] ci: Add mount operation for busybox Wei Gao via ltp
2026-01-23  2:36         ` [LTP] [PATCH v5 3/3] ci: Add e2fsprogs package for CI test Wei Gao via ltp

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.