summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-12-01 10:23:51 +0100
committerDavid Robillard <d@drobilla.net>2020-12-01 10:23:51 +0100
commit24e392f843e69e3cbe98e743870cc2502bb9ca19 (patch)
tree665fb42a3be1b1f07797cdc50795a40ae48d8102 /test
parent721b677f1d8131436465998f8d696e24053ab624 (diff)
downloadlilv-24e392f843e69e3cbe98e743870cc2502bb9ca19.tar.gz
lilv-24e392f843e69e3cbe98e743870cc2502bb9ca19.tar.bz2
lilv-24e392f843e69e3cbe98e743870cc2502bb9ca19.zip
Factor out loading test plugin
Diffstat (limited to 'test')
-rw-r--r--test/test_state.c45
1 files changed, 29 insertions, 16 deletions
diff --git a/test/test_state.c b/test/test_state.c
index 2ebf6be..ae382ef 100644
--- a/test/test_state.c
+++ b/test/test_state.c
@@ -42,6 +42,8 @@
#include <stdlib.h>
#include <string.h>
+#define TEST_PLUGIN_URI "http://example.org/lilv-test-plugin"
+
typedef struct
{
LilvTestEnv* env;
@@ -137,29 +139,41 @@ lilv_free_path(LV2_State_Free_Path_Handle handle, char* path)
lilv_free(path);
}
-int
-main(void)
+static const LilvPlugin*
+load_test_plugin(const TestContext* const ctx, const LilvTestEnv* const env)
{
- TestContext* const ctx = test_context_new();
- LilvTestEnv* const env = ctx->env;
- LilvWorld* const world = env->world;
-
- LilvTestUriMap uri_map;
- lilv_test_uri_map_init(&uri_map);
+ LilvWorld* world = env->world;
+ uint8_t* abs_bundle = (uint8_t*)lilv_path_absolute(LILV_TEST_BUNDLE);
+ SerdNode bundle = serd_node_new_file_uri(abs_bundle, 0, 0, true);
+ LilvNode* bundle_uri = lilv_new_uri(world, (const char*)bundle.buf);
+ LilvNode* plugin_uri = lilv_new_uri(world, TEST_PLUGIN_URI);
- uint8_t* abs_bundle = (uint8_t*)lilv_path_absolute(LILV_TEST_BUNDLE);
- SerdNode bundle = serd_node_new_file_uri(abs_bundle, 0, 0, true);
- LilvNode* bundle_uri = lilv_new_uri(world, (const char*)bundle.buf);
- LilvNode* plugin_uri =
- lilv_new_uri(world, "http://example.org/lilv-test-plugin");
lilv_world_load_bundle(world, bundle_uri);
- free(abs_bundle);
- serd_node_free(&bundle);
const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
const LilvPlugin* plugin = lilv_plugins_get_by_uri(plugins, plugin_uri);
+
+ lilv_node_free(plugin_uri);
+ lilv_node_free(bundle_uri);
+ serd_node_free(&bundle);
+ free(abs_bundle);
+
+ return plugin;
+}
+
+int
+main(void)
+{
+ TestContext* const ctx = test_context_new();
+ LilvTestEnv* const env = ctx->env;
+ LilvWorld* const world = env->world;
+ LilvNode* plugin_uri = lilv_new_uri(world, TEST_PLUGIN_URI);
+ const LilvPlugin* plugin = load_test_plugin(ctx, env);
assert(plugin);
+ LilvTestUriMap uri_map;
+ lilv_test_uri_map_init(&uri_map);
+
LV2_URID_Map map = {&uri_map, map_uri};
LV2_Feature map_feature = {LV2_URID_MAP_URI, &map};
LV2_URID_Unmap unmap = {&uri_map, unmap_uri};
@@ -573,7 +587,6 @@ main(void)
lilv_test_uri_map_clear(&uri_map);
lilv_node_free(plugin_uri);
- lilv_node_free(bundle_uri);
free(link_dir);
free(copy_dir);
free(temp_dir);