[LTP] [PATCH 2/2] testcase: make use of needs_cmd version parser
Yang Xu
xuyang2018.jy@fujitsu.com
Wed Dec 1 08:53:28 CET 2021
Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
---
testcases/kernel/syscalls/quotactl/quotactl04.c | 11 +----------
testcases/kernel/syscalls/statx/statx05.c | 13 ++-----------
2 files changed, 3 insertions(+), 21 deletions(-)
diff --git a/testcases/kernel/syscalls/quotactl/quotactl04.c b/testcases/kernel/syscalls/quotactl/quotactl04.c
index dab61cf4d..62c94d596 100644
--- a/testcases/kernel/syscalls/quotactl/quotactl04.c
+++ b/testcases/kernel/syscalls/quotactl/quotactl04.c
@@ -121,18 +121,9 @@ static void do_mount(const char *source, const char *target,
static void setup(void)
{
- FILE *f;
const char *const fs_opts[] = {"-I 256", "-O quota,project", NULL};
- int rc, major, minor, patch;
test_id = geteuid();
- f = SAFE_POPEN("mkfs.ext4 -V 2>&1", "r");
- rc = fscanf(f, "mke2fs %d.%d.%d", &major, &minor, &patch);
- if (rc != 3)
- tst_res(TWARN, "Unable parse version number");
- else if (major * 10000 + minor * 100 + patch < 14300)
- tst_brk(TCONF, "Test needs mkfs.ext4 >= 1.43 for quota,project option, test skipped");
- pclose(f);
SAFE_MKFS(tst_device->dev, tst_device->fs_type, fs_opts, NULL);
do_mount(tst_device->dev, MNTPOINT, tst_device->fs_type, 0, NULL);
}
@@ -184,7 +175,7 @@ static struct tst_test test = {
.dev_fs_type = "ext4",
.mntpoint = MNTPOINT,
.needs_cmds = (const char *[]) {
- "mkfs.ext4",
+ "mkfs.ext4 >= 1.43.0",
NULL
}
};
diff --git a/testcases/kernel/syscalls/statx/statx05.c b/testcases/kernel/syscalls/statx/statx05.c
index a948a30b0..6b9a1db59 100644
--- a/testcases/kernel/syscalls/statx/statx05.c
+++ b/testcases/kernel/syscalls/statx/statx05.c
@@ -85,18 +85,9 @@ static void run(unsigned int i)
static void setup(void)
{
- FILE *f;
char opt_bsize[32];
const char *const fs_opts[] = {"-O encrypt", opt_bsize, NULL};
- int ret, rc, major, minor, patch;
-
- f = SAFE_POPEN("mkfs.ext4 -V 2>&1", "r");
- rc = fscanf(f, "mke2fs %d.%d.%d", &major, &minor, &patch);
- if (rc != 3)
- tst_res(TWARN, "Unable parse version number");
- else if (major * 10000 + minor * 100 + patch < 14300)
- tst_brk(TCONF, "Test needs mkfs.ext4 >= 1.43 for encrypt option, test skipped");
- pclose(f);
+ int ret;
snprintf(opt_bsize, sizeof(opt_bsize), "-b %i", getpagesize());
@@ -129,7 +120,7 @@ static struct tst_test test = {
.mntpoint = MNTPOINT,
.dev_fs_type = "ext4",
.needs_cmds = (const char *[]) {
- "mkfs.ext4",
+ "mkfs.ext4 >= 1.43.0",
"e4crypt",
NULL
}
--
2.23.0
More information about the ltp
mailing list