All of lore.kernel.org
 help / color / mirror / Atom feed
From: Li Wang via ltp <ltp@lists.linux.it>
To: Cyril Hrubis <chrubis@suse.cz>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH 04/17] lib: tst_kconfig: Add module presence checks
Date: Fri, 3 Apr 2026 11:09:42 +0800	[thread overview]
Message-ID: <ac8vdjEM0awKPmHE@redhat.com> (raw)
In-Reply-To: <20260402121356.31266-5-chrubis@suse.cz>

On Thu, Apr 02, 2026 at 02:13:43PM +0200, Cyril Hrubis wrote:
> The .needs_kconfig and .needs_drivers fields in the tst_test structure
> had overlaping functionality. Both were checking if a functionality was
> build in into the kernel or compiled as a driver. Similarily to the
> runtime checks added to tst_kconfig modules can be build but packaged
> into separate packages and may not be installed on the system even if
> corresponding config option was set to 'm'.
> 
> This commit adds a mapping table from CONFIG options to module names for
> the modules we care about. Most of the time the mapping is trivial, but
> some CONFIG options does not really match the module name, hence we need
> a mapping. We may also be able to generate the table from kernel config
> infrastructure later on, but at this point the number of options is
> small enough to be manageable by hand editing.
> 
> Once we have that mapping we can run aditional check for a module
> presence if the confing option was set to 'm' and if mapping exists in
> order to disable the config option when the module was not found.
> 
> Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
> ---
>  lib/tst_kconfig.c | 41 +++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 41 insertions(+)
> 
> diff --git a/lib/tst_kconfig.c b/lib/tst_kconfig.c
> index 52dd6d726..c5dd97a45 100644
> --- a/lib/tst_kconfig.c
> +++ b/lib/tst_kconfig.c
> @@ -144,6 +144,46 @@ static void runtime_check(struct tst_kconfig_var *var)
>  	}
>  }
>  
> +static struct module_check {
> +	const char *config;
> +	const char *module_name;
> +} module_checks[] = {
> +	{"CONFIG_KVM", "kvm"},
> +	{"CONFIG_ZRAM", "zram"},
> +	{"CONFIG_SQUASHFS", "squashfs"},
> +	{"CONFIG_BLK_DEV_LOOP", "loop"},
> +	{"CONFIG_TUN", "tun"},
> +	{"CONFIG_BLK_DEV_RAM", "brd"},
> +	{"CONFIG_HWPOISON_INJECT", "hwpoison_inject"},
> +	{"CONFIG_QFMT_V2", "quota_v2"},
> +	{"CONFIG_INPUT_UINPUT", "uinput"},
> +	{"CONFIG_DUMMY", "dummy"},
> +	{"CONFIG_CAN_VCAN", "vcan"},
> +	{"CONFIG_CAN_RAW", "can-raw"},
> +	{"CONFIG_CAN_BCM", "can-bcm"},
> +	{"CONFIG_IP_SCTP", "sctp"},
> +	{}
> +};

Maybe rename the struct to:

	static struct config_module_map {
		const char *config;
		const char *module_name;
	} config_module_maps[] = {
		...
	}

And rename 'struct runtime_check' to:

	static struct config_runtime_map {
		const char *config;
		bool (*runtime_check)(void);
	} config_runtime_maps[] = {
		...
	};

This is a tiny nit; I don't have strong opinions.

>  static inline int kconfig_parse_line(const char *line,
>                                       struct tst_kconfig_var *vars,
>                                       unsigned int vars_len)
> @@ -222,6 +262,7 @@ out:
>  			case 'm':
>  				vars[i].choice = 'm';
>  				runtime_check(&vars[i]);
> +				module_check(&vars[i]);

Then rename the two functions to:

    kconfig_runtime_check()
    kconfig_module_check()

Because in tst_kconfig.c most function contains "kconfig_" string.

-- 
Regards,
Li Wang


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

  reply	other threads:[~2026-04-03  3:10 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-02 12:13 [LTP] [PATCH 00/17] Replace needs_drivers with needs_kconfigs Cyril Hrubis
2026-04-02 12:13 ` [LTP] [PATCH 01/17] syscalls: ioctl08: Remove .needs_drivers Cyril Hrubis
2026-04-02 21:34   ` Petr Vorel
2026-04-09 12:51   ` Andrea Cervesato via ltp
2026-04-21 12:14     ` Cyril Hrubis
2026-04-02 12:13 ` [LTP] [PATCH 02/17] lib: shell: Remove needs_drivers from JSON parser Cyril Hrubis
2026-04-02 21:29   ` Petr Vorel
2026-04-02 12:13 ` [LTP] [PATCH 03/17] lib: tst_kernel: Add tst_check_module_driver() Cyril Hrubis
2026-04-02 21:26   ` Petr Vorel
2026-04-02 21:47   ` Petr Vorel
2026-04-07  9:43     ` Cyril Hrubis
2026-04-07 11:15       ` Petr Vorel
2026-04-07 11:24         ` Cyril Hrubis
2026-04-08  7:06           ` Petr Vorel
2026-04-02 12:13 ` [LTP] [PATCH 04/17] lib: tst_kconfig: Add module presence checks Cyril Hrubis
2026-04-03  3:09   ` Li Wang via ltp [this message]
2026-04-07 10:05     ` Cyril Hrubis
2026-04-07 11:40       ` Li Wang via ltp
2026-04-07 11:44         ` Cyril Hrubis
2026-04-21 11:04   ` Petr Vorel
2026-04-02 12:13 ` [LTP] [PATCH 05/17] tests: kvm: Switch from needs_drivers to needs_kconfigs Cyril Hrubis
2026-04-21 11:05   ` Petr Vorel
2026-04-02 12:13 ` [LTP] [PATCH 06/17] tests: zram03: " Cyril Hrubis
2026-04-21 11:06   ` Petr Vorel
2026-04-02 12:13 ` [LTP] [PATCH 07/17] tests: squashfs01: " Cyril Hrubis
2026-04-21 11:07   ` Petr Vorel
2026-04-02 12:13 ` [LTP] [PATCH 08/17] tests: ioctl: " Cyril Hrubis
2026-04-02 12:13 ` [LTP] [PATCH 09/17] tests: madvise11: " Cyril Hrubis
2026-04-21 11:10   ` Petr Vorel
2026-04-02 12:13 ` [LTP] [PATCH 10/17] tests: quotactl: " Cyril Hrubis
2026-04-21 11:11   ` Petr Vorel
2026-04-02 12:13 ` [LTP] [PATCH 11/17] tests: uevent: " Cyril Hrubis
2026-04-21 11:12   ` Petr Vorel
2026-04-02 12:13 ` [LTP] [PATCH 12/17] cve: tcindex01: " Cyril Hrubis
2026-04-21 11:13   ` Petr Vorel
2026-04-02 12:13 ` [LTP] [PATCH 13/17] tests: can: " Cyril Hrubis
2026-04-21 11:13   ` Petr Vorel
2026-04-02 12:13 ` [LTP] [PATCH 14/17] tests: fsetxattr: " Cyril Hrubis
2026-04-21 11:14   ` Petr Vorel
2026-04-02 12:13 ` [LTP] [PATCH 15/17] sctp: " Cyril Hrubis
2026-04-21 11:18   ` Petr Vorel
2026-04-02 12:13 ` [LTP] [PATCH 16/17] lib: tst_test: Remove now unused needs_drivers Cyril Hrubis
2026-04-03  3:01   ` Li Wang via ltp
2026-04-07 10:02     ` Cyril Hrubis
2026-04-07 11:39       ` Li Wang via ltp
2026-04-07 11:40         ` Cyril Hrubis
2026-04-21 11:47       ` Petr Vorel
2026-04-21 12:02         ` Cyril Hrubis
2026-04-02 12:13 ` [LTP] [PATCH 17/17] doc: metadata: Remove needs_drivers from docs Cyril Hrubis
2026-04-02 21:34   ` Petr Vorel
2026-04-02 21:59 ` [LTP] [PATCH 00/17] Replace needs_drivers with needs_kconfigs Petr Vorel

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=ac8vdjEM0awKPmHE@redhat.com \
    --to=ltp@lists.linux.it \
    --cc=chrubis@suse.cz \
    --cc=liwang@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.