lib: Check minimal supported kernel version
PATCH 1/1 lib: Check minimal supported kernel version
From: Andrea Cervesato <[email protected]>
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.
---
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.
--- 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(-)
doc/conf.py +15 -0
@@ -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
doc/users/supported_systems.rst +1 -1
@@ -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 ---------------------------------
include/tst_kvercmp.h +6 -1
@@ -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 [email protected] -* 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. *
lib/tst_test.c +17 -0
@@ -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 (TCONF ,"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: d377d1cff1ec393459a136eec85088ffd5729430
change-id: 20260904-min_kernel-22066a2e046c
Best regards,
Signature · 5 lines
Andrea Cervesato <[email protected]> -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Andrea,
Quoted 1 line · Andrea Cervesato
lib: Check minimal supported kernel version
Verdict - Reviewed
---
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
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi!
Quoted 6 lines
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.hso that the documentation fetches it dynamically and the core library aborts unsupported kernels with TCONF during test setup.
Great idea, but I wouldn't tst_brk() on older kernels, I would just print a message that there may be failures becuase older kernels are not supported or tested.
LTP has been historically used for many different purposes, e.g. for testing BSD compatibility layout for running Linux binaries and I fear that hard stop on older kernel versions would break these usecases.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Cyril,
Quoted 8 lines
Hi!
Quoted 6 lines
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.hso that the documentation fetches it dynamically and the core library aborts unsupported kernels with TCONF during test setup.
Quoted 7 lines
Great idea, but I wouldn't
tst_brk()on older kernels, I would just print a message that there may be failures becuase older kernels are not supported or tested.LTP has been historically used for many different purposes, e.g. for testing BSD compatibility layout for running Linux binaries and I fear that hard stop on older kernel versions would break these usecases.
makes sense, I will send v2.
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 11 lines
Hi!
Quoted 6 lines
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.hso that the documentation fetches it dynamically and the core library aborts unsupported kernels with TCONF during test setup.Great idea, but I wouldn't
tst_brk()on older kernels, I would just print a message that there may be failures becuase older kernels are not supported or tested.
Yes, exactly, tst_brk() is way too aggressive. tst_res(TINFO) is good enough to give the information without deliberately break all the tests.
Quoted 3 lines
LTP has been historically used for many different purposes, e.g. for testing BSD compatibility layout for running Linux binaries and I fear that hard stop on older kernel versions would break these usecases.
+1.
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
W dniu pią, 04.09.2026 o godzinie 11∶20 +0200, użytkownik Cyril Hrubis
Quoted 17 lines · napisał:
Hi!
Quoted 10 lines
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.hso that
the documentation fetches it dynamically and the core library aborts
unsupported kernels with TCONF during test setup.Great idea, but I wouldn't
tst_brk()on older kernels, I would just print a message that there may be failures becuase older kernels are not
supported or tested.
Quoted 8 lines
LTP has been historically used for many different purposes, e.g. for testing BSD compatibility layout for running Linux binaries and I fear
that hard stop on older kernel versions would break these usecases.Signature · 2 lines
Cyril Hrubis [email protected]
Hi,
speaking with my [email protected] hat on, see
https://cgit.freebsd.org/src/tree/sys/compat/linux/linux_mib.h
The current claimed compatibility level is Linux 5.15.0. Even if you look at
https://cgit.freebsd.org/src/tree/sys/compat/linux/linux_mib.h?h=releng%2F14.4
(which is the oldest still-supported version), it's also 5.15.0.
I think NetBSD also has a Linux compatibility layer, but I'm not sure
how up-to-date it is.
---------------------------------------------------------------------
Intel Technology Poland sp. z o.o.
ul. Slowackiego 173 | 80-298 Gdansk | Sad Rejonowy Gdansk Polnoc | VII Wydzial Gospodarczy Krajowego Rejestru Sadowego - KRS 101882 | NIP 957-07-52-316 | Kapital zakladowy 200.000 PLN. Spolka oswiadcza, ze posiada status duzego przedsiebiorcy w rozumieniu ustawy z dnia 8 marca 2013 r. o przeciwdzialaniu nadmiernym opoznieniom w transakcjach handlowych.
Ta wiadomosc wraz z zalacznikami jest przeznaczona dla okreslonego adresata i moze zawierac informacje poufne. W razie przypadkowego otrzymania tej wiadomosci, prosimy o powiadomienie nadawcy oraz trwale jej usuniecie; jakiekolwiek przegladanie lub rozpowszechnianie jest zabronione. This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). If you are not the intended recipient, please contact the sender and delete all copies; any review or distribution by others is strictly prohibited.
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp