[LTP] [PATCH 03/17] lib: tst_kernel: Add tst_check_module_driver()

Cyril Hrubis chrubis@suse.cz
Thu Apr 2 14:13:42 CEST 2026


This function allows us to check for presence of drivers build as
modules.

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
 include/tst_kernel.h | 10 ++++++++++
 lib/tst_kernel.c     | 12 +++++++-----
 2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/include/tst_kernel.h b/include/tst_kernel.h
index 63ecb19a4..d5a4a9625 100644
--- a/include/tst_kernel.h
+++ b/include/tst_kernel.h
@@ -45,6 +45,16 @@ bool tst_abi_bits(int abi);
  */
 int tst_check_builtin_driver(const char *driver);
 
+/**
+ * tst_check_module_driver() - Check if the kernel module is present.
+ *
+ * @driver: the name of the driver.
+ *
+ * Return: 0 if module driver is present or -1 when driver is missing or config file not
+ * available. On Android *always* 0 (always expect the module is present).
+ */
+int tst_check_module_driver(const char *driver);
+
 /**
  * tst_check_driver() - Check support for the kernel module.
  *
diff --git a/lib/tst_kernel.c b/lib/tst_kernel.c
index 8bb7e080a..8f7503c02 100644
--- a/lib/tst_kernel.c
+++ b/lib/tst_kernel.c
@@ -200,16 +200,18 @@ static int tst_search_driver(const char *driver, const char *file)
 
 int tst_check_builtin_driver(const char *driver)
 {
-	if (!tst_search_driver(driver, "modules.builtin"))
-		return 0;
+	return tst_search_driver(driver, "modules.builtin");
+}
 
-	return -1;
+int tst_check_module_driver(const char *driver)
+{
+	return tst_search_driver(driver, "modules.dep");
 }
 
 int tst_check_driver(const char *driver)
 {
-	if (!tst_search_driver(driver, "modules.dep") ||
-		!tst_check_builtin_driver(driver))
+	if (!tst_check_module_driver(driver) ||
+	    !tst_check_builtin_driver(driver))
 		return 0;
 
 	return -1;
-- 
2.52.0



More information about the ltp mailing list