test: allow creating a context with a custom plugindir

For runtime creation of plugins for testing

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1192>
This commit is contained in:
Peter Hutterer 2025-06-11 15:26:48 +10:00
parent d557a649fd
commit 0c65b1069b
2 changed files with 19 additions and 2 deletions

View file

@ -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)
{

View file

@ -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);