diff options
author | Joonas Lahtinen <joonas.lahtinen@linux.intel.com> | 2017-09-12 18:44:10 +0300 |
---|---|---|
committer | Joonas Lahtinen <joonas.lahtinen@linux.intel.com> | 2017-09-13 15:00:51 +0300 |
commit | c718ba805208e55d675defe9b2a66852e2ae038c (patch) | |
tree | a7e06c5d1621a4526b7edc8b78c840cbe63fc630 /lib/igt_kmod.c | |
parent | b6ea8b204c8a18af7098326522e8acaffb19dd7a (diff) |
lib/igt_kmod: Allow specifying libkmod config via environment variables
Allow specifying the kernel module configuration via environment
variables. This allows enumerating the subtests of the kselftest
wrappers from sysroot directory.
IGT_KMOD_CONFIG_PATHS="" \
IGT_KMOD_DIRNAME="/path/to/sysroot/lib/modules/X.Y.Z" \
tests/drm_mm --list-subtests
Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Petri Latvala <petri.latvala@intel.com>
Cc: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'lib/igt_kmod.c')
-rw-r--r-- | lib/igt_kmod.c | 44 |
1 files changed, 40 insertions, 4 deletions
diff --git a/lib/igt_kmod.c b/lib/igt_kmod.c index 58624cd1..f468a4da 100644 --- a/lib/igt_kmod.c +++ b/lib/igt_kmod.c @@ -56,14 +56,50 @@ static void squelch(void *data, int priority, static struct kmod_ctx *kmod_ctx(void) { static struct kmod_ctx *ctx; + const char **config_paths = NULL; + char *config_paths_str; + char *dirname; + + if (ctx) + goto out; + + dirname = getenv("IGT_KMOD_DIRNAME"); + if (dirname) + igt_debug("kmod dirname = %s\n", dirname); + + config_paths_str = getenv("IGT_KMOD_CONFIG_PATHS"); + if (config_paths_str) + igt_debug("kmod config paths = %s\n", config_paths_str); + + if (config_paths_str) { + unsigned count = !!strlen(config_paths_str); + unsigned i; + char* p; + + p = config_paths_str; + while ((p = strchr(p, ':'))) p++, count++; - if (!ctx) { - ctx = kmod_new(NULL, NULL); - igt_assert(ctx != NULL); - kmod_set_log_fn(ctx, squelch, NULL); + config_paths = malloc(sizeof(*config_paths) * (count + 1)); + igt_assert(config_paths != NULL); + + p = config_paths_str; + for (i = 0; i < count; ++i) { + config_paths[i] = p; + + if ((p = strchr(p, ':'))) + *p++ = '\0'; + } + config_paths[i] = NULL; } + ctx = kmod_new(dirname, config_paths); + igt_assert(ctx != NULL); + + free(config_paths); + + kmod_set_log_fn(ctx, squelch, NULL); +out: return ctx; } |