[LTP] [PATCH 04/17] lib: tst_kconfig: Add module presence checks
Cyril Hrubis
chrubis@suse.cz
Thu Apr 2 14:13:43 CEST 2026
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"},
+ {}
+};
+
+static void module_check(struct tst_kconfig_var *var)
+{
+ size_t i;
+
+ for (i = 0; module_checks[i].config; i++) {
+ if (strcmp(module_checks[i].config, var->id))
+ continue;
+
+ tst_res(TDEBUG, "Running module check for '%s'", var->id);
+
+ if (tst_check_module_driver(module_checks[i].module_name)) {
+ tst_res(TINFO, "%s=%c present but module '%s' not installed",
+ var->id, var->choice, module_checks[i].module_name);
+ var->choice = 'n';
+ return;
+ }
+ }
+}
+
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]);
return 1;
}
}
--
2.52.0
More information about the ltp
mailing list