Re: [LTP] [PATCH v2 2/5] lib: Add support for max_kver to struct tst_test and tst_fs
Avinesh Kumar via ltp <[email protected]> Wed, 29 Jul 2026 12:40:44 +0200
| Newsgroups | it.linux.lists.ltp |
|---|---|
| Message-ID | <[email protected]> |
Hi Petr, few comments below On 7/29/26 11:57 AM, Petr Vorel wrote: > Signed-off-by: Petr Vorel <[email protected]> > --- > The same as v1. > > include/tst_test.h | 9 ++++++++- > lib/tst_test.c | 39 +++++++++++++++++++++++++++++++++++++++ > 2 files changed, 47 insertions(+), 1 deletion(-) > > diff --git a/include/tst_test.h b/include/tst_test.h > index c69362485e..0910660827 100644 > --- a/include/tst_test.h > +++ b/include/tst_test.h > @@ -280,6 +280,9 @@ struct tst_ulimit_val { > * > * @min_kver: A minimum kernel version supporting the filesystem which has been > * created with mkfs. > + * > + * @max_kver: A maximum kernel version supporting the filesystem which has been > + * created with mkfs. > */ > struct tst_fs { > const char *type; > @@ -292,6 +295,7 @@ struct tst_fs { > const void *mnt_data; > > const char *min_kver; > + const char *max_kver; > }; > > /** > @@ -301,7 +305,9 @@ struct tst_fs { > * and each time passed an increasing counter value. > * @options: An NULL optstr terminated array of struct tst_option. > * > - * @min_kver: A minimal kernel version the test can run on. e.g. "3.10". > + * @min_kver: A minimal kernel version the test can run on. e.g. "4.4". s/minimal/minimum > + * > + * @max_kver: A maximal kernel version the test can run on. e.g. "7.2". s/maximal/maximum Also, I assume test will *not be skipped* on kernel versions 7.1.1, 7.1.2 etc just with .max_kver="7.1" maybe we should clarify. > * > * @supported_archs: A NULL terminated array of architectures the test runs on > * e.g. {"x86_64, "x86", NULL}. Calls tst_is_on_arch() to > @@ -551,6 +557,7 @@ struct tst_fs { > struct tst_option *options; > > const char *min_kver; > + const char *max_kver; > > const char *const *supported_archs; > > diff --git a/lib/tst_test.c b/lib/tst_test.c > index 778a1fed40..fa38b3a7a3 100644 > --- a/lib/tst_test.c > +++ b/lib/tst_test.c > @@ -1087,6 +1087,36 @@ static bool check_min_kver(const char *min_kver, const int brk_nosupp) > return true; > } > > +/* > + * Check for the maximal required kernel version. > + * > + * return: true if the kernel version is low enough, false otherwise. This sounds a bit confusing. How about- Check the running kernel against the last version the test applies to. return: true if the kernel is old enough, false otherwise. > + */ > +static bool check_max_kver(const char *max_kver, const int brk_nosupp) > +{ > + char *msg; > + int v1, v2, v3; > + > + if (tst_parse_kver(max_kver, &v1, &v2, &v3)) { > + tst_res(TWARN, > + "Invalid kernel version %s, expected %%d.%%d.%%d", I wouldn't say 'kernel version is invalid'. maybe test isn't supported/applicable on.. > + max_kver); > + } > + > + if (tst_kvercmp(v1, v2, v3) > 0) { > + msg = "The test requires kernel %s or older"; > + > + if (brk_nosupp) > + tst_brk(TCONF, msg, max_kver); > + else > + tst_res(TCONF, msg, max_kver); > + > + return false; > + } > + > + return true; > +} > + > /* > * Checks if the struct results values are equal. > * > @@ -1463,6 +1493,9 @@ static void do_setup(int argc, char *argv[]) > if (tst_test->min_kver) > check_min_kver(tst_test->min_kver, 1); > > + if (tst_test->max_kver) > + check_max_kver(tst_test->max_kver, 1); > + > if (tst_test->skip_in_lockdown && tst_lockdown_enabled() > 0) > tst_brk(TCONF, "Kernel is locked down, skipping test"); > > @@ -1586,6 +1619,9 @@ static void do_setup(int argc, char *argv[]) > if (tst_test->filesystems && tst_test->filesystems->min_kver) > check_min_kver(tst_test->filesystems->min_kver, 1); > > + if (tst_test->filesystems && tst_test->filesystems->max_kver) > + check_max_kver(tst_test->filesystems->max_kver, 1); > + > prepare_device(tst_test->filesystems); > } > } > @@ -1991,6 +2027,9 @@ static void run_tcase_on_fs(struct tst_fs *fs, const char *fs_type) > if (fs->min_kver && !check_min_kver(fs->min_kver, 0)) > return; > > + if (fs->max_kver && !check_max_kver(fs->max_kver, 0)) > + return; > + > prepare_device(fs); > > fork_testrun(); Thanks, Avinesh -- Mailing list info: https://lists.linux.it/listinfo/ltp