[LTP] [PATCH 04/17] lib: tst_kconfig: Add module presence checks
Li Wang
liwang@redhat.com
Fri Apr 3 05:09:42 CEST 2026
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
More information about the ltp
mailing list