* [LTP] [PATCH v2] lib: Check minimal supported kernel version
@ 2026-09-04 9:34 Andrea Cervesato
2026-09-04 9:44 ` Li Wang
` (3 more replies)
0 siblings, 4 replies; 9+ messages in thread
From: Andrea Cervesato @ 2026-09-04 9:34 UTC (permalink / raw)
To: Linux Test Project
From: Andrea Cervesato <andrea.cervesato@suse.com>
LTP does not support kernels older than 4.4, but this requirement was
only documented in static text without automated runtime validation.
Define the minimal supported kernel version in tst_kvercmp.h so that
the documentation fetches it dynamically and the core library aborts
unsupported kernels with TCONF during test setup.
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
Add a variable to check minimum kernel version before running tests.
Until now, the only place we have to verify the minimum kernel is to
read the documentation.
---
Changes in v2:
- TWARN when kernel is minimal
- Link to v1: https://lore.kernel.org/20260904-min_kernel-v1-1-47b556550780@suse.com
---
doc/conf.py | 15 +++++++++++++++
doc/users/supported_systems.rst | 2 +-
include/tst_kvercmp.h | 7 ++++++-
lib/tst_test.c | 17 +++++++++++++++++
4 files changed, 39 insertions(+), 2 deletions(-)
diff --git a/doc/conf.py b/doc/conf.py
index c28db7af1..69ea31b0c 100644
--- a/doc/conf.py
+++ b/doc/conf.py
@@ -21,6 +21,21 @@ ltp_repo = 'https://github.com/linux-test-project/ltp'
ltp_repo_base_url = f"{ltp_repo}/tree/master"
cve_url = "https://www.cve.org/CVERecord?id="
+def _get_min_kernel_version():
+ header_path = os.path.join(os.path.dirname(__file__), '../include/tst_kvercmp.h')
+ with open(header_path, 'r', encoding='utf-8') as f:
+ match = re.search(r'#define\s+TST_MIN_KVER\s+"([^"]+)"', f.read())
+ if match:
+ return match.group(1)
+ raise RuntimeError(f"Could not find TST_MIN_KVER in {header_path}")
+
+min_kernel_version = _get_min_kernel_version()
+
+rst_prolog = f"""
+.. |min_kernel_version| replace:: **{min_kernel_version}**
+.. |min_kernel_version_plain| replace:: {min_kernel_version}
+"""
+
# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
diff --git a/doc/users/supported_systems.rst b/doc/users/supported_systems.rst
index b5d792eeb..5765214b0 100644
--- a/doc/users/supported_systems.rst
+++ b/doc/users/supported_systems.rst
@@ -14,7 +14,7 @@ branch is build tested in
Kernel version
--------------
-Minimal supported kernel version is **4.4**.
+Minimal supported kernel version is |min_kernel_version|.
Oldest build tested distributions
---------------------------------
diff --git a/include/tst_kvercmp.h b/include/tst_kvercmp.h
index 26e8f8e3c..52267fd2b 100644
--- a/include/tst_kvercmp.h
+++ b/include/tst_kvercmp.h
@@ -1,12 +1,17 @@
/* SPDX-License-Identifier: GPL-2.0-or-later
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
* Copyright (c) 2009-2016 Cyril Hrubis chrubis@suse.cz
- * Copyright (c) Linux Test Project, 2020-2025
+ * Copyright (c) Linux Test Project, 2020-2026
*/
#ifndef TST_KVERCMP_H__
#define TST_KVERCMP_H__
+/**
+ * TST_MIN_KVER - Minimal kernel version supported by LTP.
+ */
+#define TST_MIN_KVER "4.4"
+
/**
* tst_kvcmp() - Compare given kernel version with kernel in string.
*
diff --git a/lib/tst_test.c b/lib/tst_test.c
index 166e0f672..7ec0d1d33 100644
--- a/lib/tst_test.c
+++ b/lib/tst_test.c
@@ -1087,6 +1087,21 @@ static bool check_kver(const char *min_kver, const int brk_nosupp)
return true;
}
+static void check_supported_kver(void)
+{
+ int v1, v2, v3;
+
+ if (tst_parse_kver(TST_MIN_KVER, &v1, &v2, &v3)) {
+ tst_res(TWARN,
+ "Invalid minimal kernel version %s, expected %%d.%%d.%%d",
+ TST_MIN_KVER);
+ return;
+ }
+
+ if (tst_kvercmp(v1, v2, v3) < 0)
+ tst_brk(TWARN, "Kernel is older than minimal supported %s", TST_MIN_KVER);
+}
+
/*
* Checks if the struct results values are equal.
*
@@ -1455,6 +1470,8 @@ static void do_setup(int argc, char *argv[])
if (context->tdebug)
tst_res(TINFO, "Enabling debug info (level %d)", context->tdebug);
+ check_supported_kver();
+
if (tst_test->needs_kconfigs && tst_kconfig_check(tst_test->needs_kconfigs))
tst_brk(TCONF, "Aborting due to unsuitable kernel config, see above!");
---
base-commit: 8de2c6f07037f600d1ee6c45f489ab4998feea0c
change-id: 20260904-min_kernel-22066a2e046c
Best regards,
--
Andrea Cervesato <andrea.cervesato@suse.com>
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [LTP] [PATCH v2] lib: Check minimal supported kernel version
2026-09-04 9:34 [LTP] [PATCH v2] lib: Check minimal supported kernel version Andrea Cervesato
@ 2026-09-04 9:44 ` Li Wang
2026-09-10 14:44 ` Cyril Hrubis
2026-09-04 10:41 ` [LTP] " linuxtestproject.agent
` (2 subsequent siblings)
3 siblings, 1 reply; 9+ messages in thread
From: Li Wang @ 2026-09-04 9:44 UTC (permalink / raw)
To: Andrea Cervesato; +Cc: Linux Test Project
> Define the minimal supported kernel version in tst_kvercmp.h so that
> the documentation fetches it dynamically and the core library aborts
> unsupported kernels with TCONF during test setup.
The description doesn't match the code.
Other than that, it looks good to me.
--
Regards,
Li Wang
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [LTP] lib: Check minimal supported kernel version
2026-09-04 9:34 [LTP] [PATCH v2] lib: Check minimal supported kernel version Andrea Cervesato
2026-09-04 9:44 ` Li Wang
@ 2026-09-04 10:41 ` linuxtestproject.agent
2026-09-04 10:45 ` Andrea Cervesato via ltp
2026-09-11 6:41 ` [LTP] [PATCH v2] " Andrea Cervesato via ltp
2026-09-11 7:16 ` Andrea Cervesato via ltp
3 siblings, 1 reply; 9+ messages in thread
From: linuxtestproject.agent @ 2026-09-04 10:41 UTC (permalink / raw)
To: Andrea Cervesato; +Cc: ltp
Hi Andrea,
On Fri, 4 Sep 2026, Andrea Cervesato wrote:
> lib: Check minimal supported kernel version
> + if (tst_kvercmp(v1, v2, v3) < 0)
> + tst_brk(TWARN, "Kernel is older than minimal supported %s", TST_MIN_KVER);
This exits with TWARN, contrary to the commit message's stated TCONF
behavior. Use tst_brk(TCONF, ...) so unsupported kernels are reported as
skipped configurations.
Verdict - Needs revision
---
Note:
The agent can sometimes produce false positives although often its
findings are genuine. If you find issues with the review, please
comment this email or ignore the suggestions.
Regards,
LTP AI Reviewer
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [LTP] lib: Check minimal supported kernel version
2026-09-04 10:41 ` [LTP] " linuxtestproject.agent
@ 2026-09-04 10:45 ` Andrea Cervesato via ltp
0 siblings, 0 replies; 9+ messages in thread
From: Andrea Cervesato via ltp @ 2026-09-04 10:45 UTC (permalink / raw)
To: linuxtestproject.agent; +Cc: ltp
> This exits with TWARN, contrary to the commit message's stated TCONF
> behavior. Use tst_brk(TCONF, ...) so unsupported kernels are reported as
> skipped configurations.
@Petr @Cyril @Li This can be fixed before merge if you agree with it.
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
andrea.cervesato@suse.com
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [LTP] [PATCH v2] lib: Check minimal supported kernel version
2026-09-04 9:44 ` Li Wang
@ 2026-09-10 14:44 ` Cyril Hrubis
0 siblings, 0 replies; 9+ messages in thread
From: Cyril Hrubis @ 2026-09-10 14:44 UTC (permalink / raw)
To: Andrea Cervesato, Linux Test Project
Hi!
> > Define the minimal supported kernel version in tst_kvercmp.h so that
> > the documentation fetches it dynamically and the core library aborts
> > unsupported kernels with TCONF during test setup.
>
> The description doesn't match the code.
> Other than that, it looks good to me.
Indeed. Feel free to add my reviewed by with this description adjusted.
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [LTP] [PATCH v2] lib: Check minimal supported kernel version
2026-09-04 9:34 [LTP] [PATCH v2] lib: Check minimal supported kernel version Andrea Cervesato
2026-09-04 9:44 ` Li Wang
2026-09-04 10:41 ` [LTP] " linuxtestproject.agent
@ 2026-09-11 6:41 ` Andrea Cervesato via ltp
2026-09-11 6:44 ` Cyril Hrubis
2026-09-11 7:16 ` Andrea Cervesato via ltp
3 siblings, 1 reply; 9+ messages in thread
From: Andrea Cervesato via ltp @ 2026-09-11 6:41 UTC (permalink / raw)
To: Andrea Cervesato; +Cc: Linux Test Project
Hi,
> +
> + if (tst_kvercmp(v1, v2, v3) < 0)
> + tst_brk(TWARN, "Kernel is older than minimal supported %s", TST_MIN_KVER);
> +}
@Cyril @Petr I'm wondering if this should be tst_res(TWARN, ..) instead.
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
andrea.cervesato@suse.com
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [LTP] [PATCH v2] lib: Check minimal supported kernel version
2026-09-11 6:41 ` [LTP] [PATCH v2] " Andrea Cervesato via ltp
@ 2026-09-11 6:44 ` Cyril Hrubis
2026-09-11 10:12 ` Petr Vorel
0 siblings, 1 reply; 9+ messages in thread
From: Cyril Hrubis @ 2026-09-11 6:44 UTC (permalink / raw)
To: Andrea Cervesato; +Cc: Linux Test Project
Hi!
> > +
> > + if (tst_kvercmp(v1, v2, v3) < 0)
> > + tst_brk(TWARN, "Kernel is older than minimal supported %s", TST_MIN_KVER);
> > +}
>
> @Cyril @Petr I'm wondering if this should be tst_res(TWARN, ..) instead.
Sorry missed that, yes, that was the point I was trying to make, that
this shouldn't exit the test. Only produce a message.
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [LTP] [PATCH v2] lib: Check minimal supported kernel version
2026-09-04 9:34 [LTP] [PATCH v2] lib: Check minimal supported kernel version Andrea Cervesato
` (2 preceding siblings ...)
2026-09-11 6:41 ` [LTP] [PATCH v2] " Andrea Cervesato via ltp
@ 2026-09-11 7:16 ` Andrea Cervesato via ltp
3 siblings, 0 replies; 9+ messages in thread
From: Andrea Cervesato via ltp @ 2026-09-11 7:16 UTC (permalink / raw)
To: Andrea Cervesato; +Cc: Linux Test Project
Merged, Thanks!
Changed tst_brk(TWARN, ..) with tst_res(TWARN, ..)
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
andrea.cervesato@suse.com
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [LTP] [PATCH v2] lib: Check minimal supported kernel version
2026-09-11 6:44 ` Cyril Hrubis
@ 2026-09-11 10:12 ` Petr Vorel
0 siblings, 0 replies; 9+ messages in thread
From: Petr Vorel @ 2026-09-11 10:12 UTC (permalink / raw)
To: Cyril Hrubis; +Cc: Linux Test Project
> Hi!
> > > +
> > > + if (tst_kvercmp(v1, v2, v3) < 0)
> > > + tst_brk(TWARN, "Kernel is older than minimal supported %s", TST_MIN_KVER);
> > > +}
> > @Cyril @Petr I'm wondering if this should be tst_res(TWARN, ..) instead.
> Sorry missed that, yes, that was the point I was trying to make, that
> this shouldn't exit the test. Only produce a message.
As I pointed in v1 even tst_res(TWARN) might be too aggressive as it makes all
tests exit with 4 (=> non-zero) due TWARN.
tst_res(TINFO, "WARNING: ...") would not do that and still warn users.
But since we at SUSE are probably the users of the oldest kernels we don't have
to worry that much. (+ I know it's already merged.)
Kind regards,
Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2026-09-11 10:13 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-04 9:34 [LTP] [PATCH v2] lib: Check minimal supported kernel version Andrea Cervesato
2026-09-04 9:44 ` Li Wang
2026-09-10 14:44 ` Cyril Hrubis
2026-09-04 10:41 ` [LTP] " linuxtestproject.agent
2026-09-04 10:45 ` Andrea Cervesato via ltp
2026-09-11 6:41 ` [LTP] [PATCH v2] " Andrea Cervesato via ltp
2026-09-11 6:44 ` Cyril Hrubis
2026-09-11 10:12 ` Petr Vorel
2026-09-11 7:16 ` Andrea Cervesato via ltp
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox