From 0c65b1069bacf10530b70efb0761161c7c095510 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Wed, 11 Jun 2025 15:26:48 +1000 Subject: [PATCH] test: allow creating a context with a custom plugindir For runtime creation of plugins for testing Part-of: --- test/litest.c | 15 +++++++++++++-- test/litest.h | 6 ++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/test/litest.c b/test/litest.c index fc92cdc3..608c7ca5 100644 --- a/test/litest.c +++ b/test/litest.c @@ -2129,7 +2129,7 @@ litest_create(enum litest_device_type which, } struct libinput * -litest_create_context(void) +litest_create_context_with_plugindir(const char *plugindir) { struct libinput *libinput; struct litest_context *ctx; @@ -2144,11 +2144,22 @@ litest_create_context(void) if (verbose) libinput_log_set_priority(libinput, LIBINPUT_LOG_PRIORITY_DEBUG); - libinput_plugin_system_load_plugins(libinput, LIBINPUT_PLUGIN_FLAG_NONE); + if (plugindir) + libinput_plugin_system_append_path(libinput, plugindir); return libinput; } +struct libinput * +litest_create_context(void) +{ + struct libinput *li = litest_create_context_with_plugindir(NULL); + + libinput_plugin_system_load_plugins(li, LIBINPUT_PLUGIN_FLAG_NONE); + + return li; +} + void litest_destroy_context(struct libinput *li) { diff --git a/test/litest.h b/test/litest.h index f70226d6..68512f65 100644 --- a/test/litest.h +++ b/test/litest.h @@ -656,6 +656,12 @@ litest_axis_set_value(struct axis_replacement *axes, int code, double value) struct libinput * litest_create_context(void); + +/* Adds the given plugin dir to the context but does *not* initialize + * the plugins */ +struct libinput * +litest_create_context_with_plugindir(const char *plugindir); + void litest_destroy_context(struct libinput *li); DEFINE_TRIVIAL_CLEANUP_FUNC(struct libinput *, litest_destroy_context);