Re: [PATCH v3 2/5] lib: Add support for max_kver to struct tst_test and tst_fs
Avinesh Kumar via ltp <[email protected]> Fri, 31 Jul 2026 13:48:14 +0200
| Newsgroups | gmane.linux.ltp |
|---|---|
| Message-ID | <[email protected]> |
On 7/31/26 12:51 PM, Petr Vorel wrote: > max_kver adds a support to require a maximal kernel version the test can > run on. e.g. "7.2" (mainline release) or "6.1.180" (stable release). > > NOTE: Mainline release is sufficient on any stable release (test with > .min_kver = "7.1" runs also on kernel 7.1.5). Stable releases are > compared as expected. > > Signed-off-by: Petr Vorel <[email protected]> > --- > Changes v2->v3: > * Allow to pass mainline release (e.g. max_version = "7.1") on any stable > release (e.g. 7.1.5). Stable releases (e.g. 7.1.5) are compared as > expected. For this I'd like an explicit ack. > > include/tst_test.h | 13 ++++++++++++- > lib/tst_test.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 59 insertions(+), 1 deletion(-) > > diff --git a/include/tst_test.h b/include/tst_test.h > index c69362485e..318b2f79b7 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,13 @@ 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" (mainline > + * release) or "6.1.180" (stable release). > + * > + * @max_kver: A maximal kernel version the test can run on. e.g. "7.2" (mainline > + * release) or "6.1.180" (stable release). NOTE: Mainline release is sufficient > + * on any stable release (test with ``min_kver = "7.1"`` runs also on kernel > + * 7.1.5). Stable releases are compared as expected. > * > * @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 +561,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..8b9abe716a 100644 > --- a/lib/tst_test.c > +++ b/lib/tst_test.c > @@ -1087,6 +1087,44 @@ 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. > + */ > +static bool check_max_kver(const char *max_kver, const int brk_nosupp) > +{ > + char *msg; > + int dots, i, v1, v2, v3; > + > + if (tst_parse_kver(max_kver, &v1, &v2, &v3)) { > + tst_res(TWARN, > + "Invalid kernel version %s, expected %%d.%%d.%%d", > + max_kver); > + } > + > + for (i=0, dots=0; max_kver[i]; i++) > + dots += (max_kver[i] == '.'); > + > + /* > + * For mainline kernel release without patch level (single dot e.g. "7.1") > + * ignore v3 (the sublevel): 7.1.x is always ok. > + * Do *not* ignore v3 on stable kernel release (2 dots, e.g. 7.1.5). > + */ > + if (tst_kvercmp(v1, v2, v3) > (dots == 1 ? 1023 : 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; > +} Hi Petr, This looks good. I tested it (and other patches) as well. on my system, test runs fine - tst_test.c:2097: TINFO: Tested kernel: 7.1.4-1-default ... and on >=7.2 # ./fanotify20 tst_test.c:1118: TCONF: The test requires kernel 7.1 or older so feel free to add Tested-by: Avinesh Kumar <avinesh.kumar-IBi9RG/[email protected]> Reviewed-by: Avinesh Kumar <avinesh.kumar-IBi9RG/[email protected]> for whole series. Thanks, Avinesh -- Mailing list info: https://lists.linux.it/listinfo/ltp