Linux Test Project
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: Petr Vorel <pvorel@suse.cz>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v4 9/9] [RFC] metaparse: Check {min, max}_kver validity
Date: Thu, 6 Aug 2026 09:23:27 +0200	[thread overview]
Message-ID: <anQ2b1STktuhnLrP@rei> (raw)
In-Reply-To: <20260805151451.648990-10-pvorel@suse.cz>

Hi!
> diff --git a/metadata/Makefile b/metadata/Makefile
> index af194bcc94..9ee2441669 100644
> --- a/metadata/Makefile
> +++ b/metadata/Makefile
> @@ -3,13 +3,15 @@
>  
>  top_srcdir		?= ..
>  
> -include $(top_srcdir)/include/mk/env_pre.mk
> -include $(top_srcdir)/include/mk/functions.mk
> +include $(top_srcdir)/include/mk/testcases.mk
>  
>  MAKE_TARGETS		:= ltp.json
>  HOST_MAKE_TARGETS	:= metaparse metaparse-sh
>  INSTALL_DIR		= metadata
>  
> +metaparse: HOST_CFLAGS		+= -I$(abs_srcdir)/../include -L$(abs_builddir)/../lib
> +metaparse: HOST_LDLIBS		+= -lltp
> +
>  .PHONY: ltp.json
>  
>  ltp.json: metaparse metaparse-sh
> diff --git a/metadata/metaparse.c b/metadata/metaparse.c
> index cb141c3831..07a452a5a1 100644
> --- a/metadata/metaparse.c
> +++ b/metadata/metaparse.c
> @@ -6,6 +6,7 @@
>  
>  #define _GNU_SOURCE
>  
> +#include <assert.h>
>  #include <search.h>
>  #include <stdio.h>
>  #include <string.h>
> @@ -15,6 +16,7 @@
>  #include <errno.h>
>  
>  #include "data_storage.h"
> +#include "tst_kvercmp.h"
>  
>  #define INCLUDE_PATH_MAX 5
>  #define GROUPS_TAG "@groups"
> @@ -1372,6 +1374,37 @@ int main(int argc, char *argv[])
>  		}
>  	}
>  
> +	/* Check max_kver >= min_kver */
> +	struct data_node *max_kver = data_node_hash_get(res, "max_kver");
> +	struct data_node *min_kver = data_node_hash_get(res, "min_kver");
> +	int a1, a2, a3, b1, b2, b3;
> +
> +	if (min_kver) {
> +		assert(min_kver->type == DATA_STRING);
> +		if (tst_parse_kver(min_kver->string.val, &b1, &b2, &b3)) {
> +			fprintf(stderr, "%s: wrong min_kver: '%s'\n",
> +				argv[optind], min_kver->string.val);
> +			return 1;
> +		}
> +	}
> +
> +	if (max_kver) {
> +		assert(max_kver->type == DATA_STRING);
> +		if (tst_parse_kver(max_kver->string.val, &a1, &a2, &a3)) {
> +			fprintf(stderr, "%s: wrong max_kver: '%s'\n",
> +					argv[optind], max_kver->string.val);
> +			return 1;
> +		}
> +	}
> +
> +	if (min_kver && max_kver) {
> +		if (tst_kver_cmp(a1, a2, a3, b1, b2, b3) < 0) {
> +			fprintf(stderr, "%s: min_kver (%s) > max_kver (%s)\n",
> +					argv[optind], min_kver->string.val, max_kver->string.val);
> +			return 1;
> +		}
> +	}
> +

Andrea is working on metadata linter, that does much more than this,
e.g. checks that CVE record is valid.

This looks like a check that could be added more easily there.


-- 
Cyril Hrubis
chrubis@suse.cz

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

      parent reply	other threads:[~2026-08-06  7:25 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-05 15:14 [LTP] [PATCH v4 0/6] Add support for .max_kver Petr Vorel
2026-08-05 15:14 ` [LTP] [PATCH v4 1/9] tst_kvercmp: Factor out error handling Petr Vorel
2026-08-05 17:33   ` [LTP] " linuxtestproject.agent
2026-08-05 17:33   ` linuxtestproject.agent
2026-08-05 17:34   ` linuxtestproject.agent
2026-08-05 17:35   ` linuxtestproject.agent
2026-08-06  7:02   ` [LTP] [PATCH v4 1/9] " Andrea Cervesato via ltp
2026-08-05 15:14 ` [LTP] [PATCH v4 2/9] lib: Rename function check_kver() => check_min_kver() Petr Vorel
2026-08-05 15:14 ` [LTP] [PATCH v4 3/9] lib: Add support for max_kver to struct tst_test and tst_fs Petr Vorel
2026-08-05 15:14 ` [LTP] [PATCH v4 4/9] creat07: execve04: Remove version check, add linux-git Petr Vorel
2026-08-05 15:14 ` [LTP] [PATCH v4 5/9] fanotify20: Skip on v7.2 Petr Vorel
2026-08-05 15:14 ` [LTP] [PATCH v4 6/9] lib: Add basic test for .min_kver && .max_kver Petr Vorel
2026-08-05 15:14 ` [LTP] [PATCH v4 7/9] tst_kvercmp: Factor out 2 kernels integer comparison Petr Vorel
2026-08-05 15:14 ` [LTP] [PATCH v4 8/9] [RFC] make: Allow to add LTP library as a dependency for host Petr Vorel
2026-08-05 15:14 ` [LTP] [PATCH v4 9/9] [RFC] metaparse: Check {min, max}_kver validity Petr Vorel
2026-08-06  5:37   ` Petr Vorel
2026-08-06  7:23   ` Cyril Hrubis [this message]

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=anQ2b1STktuhnLrP@rei \
    --to=chrubis@suse.cz \
    --cc=ltp@lists.linux.it \
    --cc=pvorel@suse.cz \
    /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