summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2015-10-29 04:29:33 +0000
committerDavid Robillard <d@drobilla.net>2015-10-29 04:29:33 +0000
commitdb1f21708808e2ad01292f08deb8da1788db6ee8 (patch)
tree81d907cfaa03a3e4c539d1e4108f33ccbdb562b3 /test
parentefc94d38733ac94c04f3c2d01d2eb058b5e3d4d5 (diff)
downloadlilv-db1f21708808e2ad01292f08deb8da1788db6ee8.tar.gz
lilv-db1f21708808e2ad01292f08deb8da1788db6ee8.tar.bz2
lilv-db1f21708808e2ad01292f08deb8da1788db6ee8.zip
Support reloading bundles
git-svn-id: http://svn.drobilla.net/lad/trunk/lilv@5797 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'test')
-rw-r--r--test/lilv_test.c71
1 files changed, 69 insertions, 2 deletions
diff --git a/test/lilv_test.c b/test/lilv_test.c
index f179d33..7b6d14a 100644
--- a/test/lilv_test.c
+++ b/test/lilv_test.c
@@ -159,9 +159,9 @@ cleanup(void)
#define TEST_ASSERT(check) do {\
test_count++;\
if (!(check)) {\
- assert(false);\
error_count++;\
- fprintf(stderr, "lilv_test.c:%d: error: %s\n", __LINE__, #check);\
+ fprintf(stderr, "lilv_test.c:%d: error: test `%s' failed\n", __LINE__, #check);\
+ assert(check);\
}\
} while (0)
@@ -1940,6 +1940,72 @@ test_world(void)
/*****************************************************************************/
+static int
+test_reload_bundle(void)
+{
+ // Create a simple plugin bundle
+ create_bundle(MANIFEST_PREFIXES
+ ":plug a lv2:Plugin ; lv2:binary <foo" SHLIB_EXT "> ; rdfs:seeAlso <plugin.ttl> .\n",
+ BUNDLE_PREFIXES
+ ":plug a lv2:Plugin ; "
+ PLUGIN_NAME("First name") " .");
+
+ if (!init_world()) {
+ return 0;
+ }
+
+ init_uris();
+ lilv_world_load_specifications(world);
+
+ // Load bundle
+ LilvNode* bundle_uri = lilv_new_uri(world, bundle_dir_uri);
+ lilv_world_load_bundle(world, bundle_uri);
+
+ // Check that plugin is present
+ const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
+ const LilvPlugin* plug = lilv_plugins_get_by_uri(plugins, plugin_uri_value);
+ TEST_ASSERT(plug);
+
+ // Check that plugin name is correct
+ LilvNode* name = lilv_plugin_get_name(plug);
+ TEST_ASSERT(!strcmp(lilv_node_as_string(name), "First name"));
+ lilv_node_free(name);
+
+ // Unload bundle from world and delete it
+ lilv_world_unload_bundle(world, bundle_uri);
+ delete_bundle();
+
+ // Create a new version of the same bundle, but with a different name
+ create_bundle(MANIFEST_PREFIXES
+ ":plug a lv2:Plugin ; lv2:binary <foo" SHLIB_EXT "> ; rdfs:seeAlso <plugin.ttl> .\n",
+ BUNDLE_PREFIXES
+ ":plug a lv2:Plugin ; "
+ PLUGIN_NAME("Second name") " .");
+
+ // Load new bundle
+ lilv_world_load_bundle(world, bundle_uri);
+
+ // TODO: Mechanism to actually remove plugin from world list
+
+ // Check that plugin is present again
+ const LilvPlugin* plug2 = lilv_plugins_get_by_uri(plugins, plugin_uri_value);
+ TEST_ASSERT(plug2);
+
+ // Check that plugin now has new name
+ LilvNode* name2 = lilv_plugin_get_name(plug2);
+ TEST_ASSERT(name2);
+ TEST_ASSERT(!strcmp(lilv_node_as_string(name2), "Second name"));
+ lilv_node_free(name2);
+
+ lilv_node_free(bundle_uri);
+ lilv_world_free(world);
+ world = NULL;
+
+ return 1;
+}
+
+/*****************************************************************************/
+
/* add tests here */
static struct TestCase tests[] = {
TEST_CASE(util),
@@ -1963,6 +2029,7 @@ static struct TestCase tests[] = {
TEST_CASE(string),
TEST_CASE(world),
TEST_CASE(state),
+ TEST_CASE(reload_bundle),
{ NULL, NULL }
};