Linux Test Project
 help / color / mirror / Atom feed
From: Petr Vorel <pvorel@suse.cz>
To: Cyril Hrubis <chrubis@suse.cz>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v5 3/7] lib: Add support for max_kver to struct tst_test and tst_fs
Date: Wed, 12 Aug 2026 14:30:07 +0200	[thread overview]
Message-ID: <20260812123007.GA1758016@pevik> (raw)
In-Reply-To: <anxTci_fnDEztVVT@yuki.lan>

Hi Cyril,

> Hi!
> > +/*
> > + * 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;
> > +
> > +	tst_parse_kver(max_kver, &v1, &v2, &v3);
> > +
> > +	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)) {

> Uff, this is quite ugly. What exactly are we trying to do?

I hoped that was explained in the comment above the code:
 .max_kver = "7.0" should run the test not only kernel <= 7.0,
but also all stable kernels: 7.0.x.
OTOH if there is something backported to stable kernel and one specifies:
.max_kver = "7.0.5" it will be compared just to <= 7.0.5.

Sure, this can be avoided if .max_kver = "7.0" is not inclusive,
i.e. < 7.0 (one would have to use .max_kver = "7.1"), which is less
intuitive, because .min_kver is inclusive).

> Also we are missing wiring for the shell test executor:

I deliberately did not add it and documented my intention in
doc/developers/writing_tests.rst LTP C And Shell Test API Comparison table
+    * - .max_kver
+      - not implemented

The reason is that it's not needed now for shell tests. But sure I can add it.

Kind regards,
Petr

> iff --git a/testcases/lib/tst_run_shell.c b/testcases/lib/tst_run_shell.c
> index 2778fb6d5..263a319bc 100644
> --- a/testcases/lib/tst_run_shell.c
> +++ b/testcases/lib/tst_run_shell.c
> @@ -57,6 +57,7 @@ enum test_attr_ids {
>         DEV_MIN_SIZE,
>         FILESYSTEMS,
>         FORMAT_DEVICE,
> +       MAX_KVER,
>         MIN_CPUS,
>         MIN_MEM_AVAIL,
>         MIN_KVER,
> @@ -91,6 +92,7 @@ static ujson_obj_attr test_attrs[] = {
>         UJSON_OBJ_ATTR_IDX(DEV_MIN_SIZE, "dev_min_size", UJSON_INT),
>         UJSON_OBJ_ATTR_IDX(FILESYSTEMS, "filesystems", UJSON_ARR),
>         UJSON_OBJ_ATTR_IDX(FORMAT_DEVICE, "format_device", UJSON_BOOL),
> +       UJSON_OBJ_ATTR_IDX(MAX_KVER, "max_kver", UJSON_STR),
>         UJSON_OBJ_ATTR_IDX(MIN_CPUS, "min_cpus", UJSON_INT),
>         UJSON_OBJ_ATTR_IDX(MIN_MEM_AVAIL, "min_mem_avail", UJSON_INT),
>         UJSON_OBJ_ATTR_IDX(MIN_KVER, "min_kver", UJSON_STR),
> @@ -462,6 +464,9 @@ static void parse_metadata(void)
>                 case FORMAT_DEVICE:
>                         test.format_device = val.val_bool;
>                 break;
> +               case MAX_KVER:
> +                       test.max_kver = strdup(val.val_str);
> +               break;
>                 case MIN_CPUS:
>                         if (val.val_int <= 0)
>                                 ujson_err(&reader, "Minimal number of cpus must be > 0");

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

  reply	other threads:[~2026-08-12 12:30 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-10 16:00 [LTP] [PATCH v5 0/7] Add support for .max_kver Petr Vorel
2026-08-10 16:00 ` [LTP] [PATCH v5 1/7] tst_kvercmp: Factor out error handling Petr Vorel
2026-08-10 16:57   ` [LTP] " linuxtestproject.agent
2026-08-10 17:03     ` Petr Vorel
2026-08-11  7:01   ` [LTP] [PATCH v5 1/7] " Andrea Cervesato via ltp
2026-08-12 10:50   ` Cyril Hrubis
2026-08-10 16:00 ` [LTP] [PATCH v5 2/7] lib: Rename function check_kver() => check_min_kver() Petr Vorel
2026-08-10 16:00 ` [LTP] [PATCH v5 3/7] lib: Add support for max_kver to struct tst_test and tst_fs Petr Vorel
2026-08-11  7:04   ` Andrea Cervesato via ltp
2026-08-12 11:05   ` Cyril Hrubis
2026-08-12 12:30     ` Petr Vorel [this message]
2026-08-12 12:36       ` Cyril Hrubis
2026-08-12 13:11         ` Petr Vorel
2026-08-12 12:44       ` Cyril Hrubis
2026-08-12 13:16         ` Petr Vorel
2026-08-12 11:06   ` Cyril Hrubis
2026-08-12 13:00     ` Petr Vorel
2026-08-10 16:00 ` [LTP] [PATCH v5 4/7] creat07: Avoid timeout on the test failure Petr Vorel
2026-08-11  7:04   ` Andrea Cervesato via ltp
2026-08-10 16:00 ` [LTP] [PATCH v5 5/7] creat07: execve04: Remove version check, add linux-git Petr Vorel
2026-08-10 16:00 ` [LTP] [PATCH v5 6/7] fanotify20: Skip on v7.2 Petr Vorel
2026-08-10 16:00 ` [LTP] [PATCH v5 7/7] lib: Add 2 basic tests for .min_kver && .max_kver Petr Vorel
2026-08-11  7:13   ` Andrea Cervesato via ltp
2026-08-11  8:49     ` Petr Vorel
2026-08-11  8:53       ` Andrea Cervesato via ltp
2026-08-11 10:10   ` Avinesh Kumar via ltp
2026-08-11  1:45 ` [LTP] [PATCH v5 0/7] Add support for .max_kver Li Wang

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=20260812123007.GA1758016@pevik \
    --to=pvorel@suse.cz \
    --cc=chrubis@suse.cz \
    --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