[PATCH i-g-t v2] lib/igt_kmod: Allow to load kunit from alias
Lucas De Marchi
lucas.demarchi at intel.com
Mon Mar 4 20:48:38 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.
v2: Fallback to kmod_module_new_from_name() since the kmod ctx is also
used on builder machines to determine the test lists.
Signed-off-by: Lucas De Marchi <lucas.demarchi at intel.com>
---
lib/igt_kmod.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/lib/igt_kmod.c b/lib/igt_kmod.c
index cc242838f..0fe289950 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,10 +1454,20 @@ 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;
+ /*
+ * Lookup may not resolve to a module when used to just list subtests,
+ * where module is not available. Fallback to _new_from_name().
+ */
+ if (!l)
+ return kmod_module_new_from_name(kmod_ctx(), module_name, &tst->kmod);
+
+ 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