[PATCH i-g-t] lib/igt_kmod: Allow to load kunit from alias

Lucas De Marchi lucas.demarchi at intel.com
Thu Feb 22 19:30:44 UTC 2024


Instead of only allowing to load the from the module name, also allow it
from alias by using kmod_module_new_from_lookup(). With that a user can
have their on aliases and the kernel can also export a compat alias for
future module renames.

Signed-off-by: Lucas De Marchi <lucas.demarchi at intel.com>
---
 lib/igt_kmod.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/lib/igt_kmod.c b/lib/igt_kmod.c
index cc242838f..43c52eaab 100644
--- a/lib/igt_kmod.c
+++ b/lib/igt_kmod.c
@@ -1443,6 +1443,7 @@ void igt_kunit(const char *module_name, const char *suite, const char *opts)
 int igt_ktest_init(struct igt_ktest *tst,
 		   const char *module_name)
 {
+	struct kmod_list *l = NULL;
 	int err;
 
 	memset(tst, 0, sizeof(*tst));
@@ -1453,9 +1454,14 @@ int igt_ktest_init(struct igt_ktest *tst,
 
 	tst->kmsg = -1;
 
-	err = kmod_module_new_from_name(kmod_ctx(), module_name, &tst->kmod);
-	if (err)
+	err = kmod_module_new_from_lookup(kmod_ctx(), module_name, &l);
+	if (err < 0)
 		return err;
+	if (!l)
+		return -ENOENT;
+
+	tst->kmod = kmod_module_get_module(l);
+	kmod_module_unref_list(l);
 
 	return 0;
 }
-- 
2.43.0



More information about the igt-dev mailing list