From: Cyril Hrubis <chrubis@suse.cz>
To: Andrea Cervesato <andrea.cervesato@suse.de>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v3 2/3] Add minimum kernel requirement for FS setup
Date: Fri, 4 Oct 2024 16:08:21 +0200 [thread overview]
Message-ID: <Zv_21V0x0Kv-ViJo@yuki.lan> (raw)
In-Reply-To: <20241002-ioctl_ficlone01_fix-v3-2-7e077918dfd4@suse.com>
Hi!
> In some cases, a filesystem that is going to be created and mounted
> by LTP can't be supported by certain kernel versions. This is the case
> of the CoW support: mkfs creates a CoW filesystem, while underlying
> kernel can't mount it.
>
> To cover this scenario, a new flag called .min_kver has been
> introduced in the tst_fs structure, giving the user a possibility to
> filter out certain kernels not supporting certain FS features.
>
> Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
> ---
> include/tst_test.h | 5 +++++
> lib/tst_test.c | 27 +++++++++++++++++++++------
> testcases/lib/tst_run_shell.c | 5 +++++
> 3 files changed, 31 insertions(+), 6 deletions(-)
>
> diff --git a/include/tst_test.h b/include/tst_test.h
> index 38d24f48c..8d1819f74 100644
> --- a/include/tst_test.h
> +++ b/include/tst_test.h
> @@ -270,6 +270,9 @@ struct tst_ulimit_val {
> *
> * @mnt_data: The data passed to mount(2) when the test library mounts a device
> * in the case of 'tst_test.mount_device'.
> + *
> + * @min_kver: A minimum kernel version supporting the filesystem which has been
> + * created with mkfs.
> */
> struct tst_fs {
> const char *type;
> @@ -280,6 +283,8 @@ struct tst_fs {
>
> unsigned int mnt_flags;
> const void *mnt_data;
> +
> + const char *min_kver;
> };
>
> /**
> diff --git a/lib/tst_test.c b/lib/tst_test.c
> index 192fee309..fe07c4d98 100644
> --- a/lib/tst_test.c
> +++ b/lib/tst_test.c
> @@ -950,20 +950,29 @@ static void do_exit(int ret)
> exit(ret);
> }
>
> -void check_kver(void)
> +int check_kver(const char *min_kver, const int brk_nosupp)
> {
> + char *msg;
> int v1, v2, v3;
>
> - if (tst_parse_kver(tst_test->min_kver, &v1, &v2, &v3)) {
> + if (tst_parse_kver(min_kver, &v1, &v2, &v3)) {
> tst_res(TWARN,
> "Invalid kernel version %s, expected %%d.%%d.%%d",
> - tst_test->min_kver);
> + min_kver);
> }
>
> if (tst_kvercmp(v1, v2, v3) < 0) {
> - tst_brk(TCONF, "The test requires kernel %s or newer",
> - tst_test->min_kver);
> + msg = "The test requires kernel %s or newer";
> +
> + if (brk_nosupp)
> + tst_brk(TCONF, msg, min_kver);
> + else
> + tst_res(TCONF, msg, min_kver);
> +
> + return 1;
> }
> +
> + return 0;
> }
>
> static int results_equal(struct results *a, struct results *b)
> @@ -1289,7 +1298,7 @@ static void do_setup(int argc, char *argv[])
> tst_brk(TCONF, "Test needs to be run as root");
>
> if (tst_test->min_kver)
> - check_kver();
> + check_kver(tst_test->min_kver, 1);
>
> if (tst_test->supported_archs && !tst_is_on_arch(tst_test->supported_archs))
> tst_brk(TCONF, "This arch '%s' is not supported for test!", tst_arch.name);
> @@ -1420,6 +1429,9 @@ static void do_setup(int argc, char *argv[])
> if (tst_test->filesystems->mkfs_ver)
> ret = tst_check_cmd(tst_test->filesystems->mkfs_ver, 0);
>
> + if (tst_test->filesystems->min_kver)
> + ret = check_kver(tst_test->filesystems->min_kver, 0);
Here as well, we should pass 1 as the last argument.
> if (ret)
> return;
>
> @@ -1816,6 +1828,9 @@ static int run_tcase_on_fs(struct tst_fs *fs, const char *fs_type)
> if (fs->mkfs_ver && tst_check_cmd(fs->mkfs_ver, 0))
> return TCONF;
>
> + if (fs->min_kver && check_kver(fs->min_kver, 0))
> + return TCONF;
> +
> prepare_device(fs);
>
> ret = fork_testrun();
> diff --git a/testcases/lib/tst_run_shell.c b/testcases/lib/tst_run_shell.c
> index ee029b666..6b714c51c 100644
> --- a/testcases/lib/tst_run_shell.c
> +++ b/testcases/lib/tst_run_shell.c
> @@ -156,6 +156,7 @@ enum fs_ids {
> MKFS_VER,
> MNT_FLAGS,
> TYPE,
> + FS_MIN_KVER,
> };
>
> static ujson_obj_attr fs_attrs[] = {
> @@ -164,6 +165,7 @@ static ujson_obj_attr fs_attrs[] = {
> UJSON_OBJ_ATTR_IDX(MKFS_VER, "mkfs_ver", UJSON_STR),
> UJSON_OBJ_ATTR_IDX(MNT_FLAGS, "mnt_flags", UJSON_ARR),
> UJSON_OBJ_ATTR_IDX(TYPE, "type", UJSON_STR),
> + UJSON_OBJ_ATTR_IDX(FS_MIN_KVER, "min_kver", UJSON_STR),
This is stil not sorted properly, the min_kver should go before the
mkfs_ver.
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2024-10-04 14:10 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-02 12:22 [LTP] [PATCH v3 0/3] Fix ioctl_ficlone(range) failures on certain FS Andrea Cervesato
2024-10-02 12:22 ` [LTP] [PATCH v3 1/3] Filter mkfs version in tst_fs Andrea Cervesato
2024-10-04 14:00 ` Cyril Hrubis
2024-10-02 12:22 ` [LTP] [PATCH v3 2/3] Add minimum kernel requirement for FS setup Andrea Cervesato
2024-10-04 14:08 ` Cyril Hrubis [this message]
2024-10-08 11:34 ` Andrea Cervesato via ltp
2024-10-08 11:50 ` Cyril Hrubis
2024-10-02 12:22 ` [LTP] [PATCH v3 3/3] Setup minimal kernel for ioctl_clone(range) tests Andrea Cervesato
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Zv_21V0x0Kv-ViJo@yuki.lan \
--to=chrubis@suse.cz \
--cc=andrea.cervesato@suse.de \
--cc=ltp@lists.linux.it \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox