diff options
author | David Robillard <d@drobilla.net> | 2016-07-11 20:26:39 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2016-07-11 20:26:39 -0400 |
commit | 2f745fae447200b666c9f5810796d13a20fdf559 (patch) | |
tree | 37f5dde7f63fe36c70cf92a44f4b5835ea95aeac /test | |
parent | 05f9e858a5dd4b3a1ba5047aa703e55da70dcfdf (diff) | |
download | lilv-2f745fae447200b666c9f5810796d13a20fdf559.tar.gz lilv-2f745fae447200b666c9f5810796d13a20fdf559.tar.bz2 lilv-2f745fae447200b666c9f5810796d13a20fdf559.zip |
Fully reset plugin struct when plugin is reloaded
This fixes a bug where, for example, after re-loading a plugin from a
different bundle, the LilvPlugin would still report the old bundle.
Also never replace a newer version with an older version when a bundle
is loaded. Ignores the entire bundle if an older plugin than one loaded
is found. This is tricky because the unit of loading/unloading is a
bundle, and the unit of versioning is a plugin, but since having data
from an old bundle still loaded seems like a bad idea, this seems like
the most correct behaviour.
Diffstat (limited to 'test')
-rw-r--r-- | test/lilv_test.c | 41 |
1 files changed, 37 insertions, 4 deletions
diff --git a/test/lilv_test.c b/test/lilv_test.c index 4215d97..69f58c7 100644 --- a/test/lilv_test.c +++ b/test/lilv_test.c @@ -2039,6 +2039,8 @@ test_replace_version(void) LilvNode* plug_uri = lilv_new_uri(world, "http://example.org/versioned"); LilvNode* lv2_minorVersion = lilv_new_uri(world, LV2_CORE__minorVersion); LilvNode* lv2_microVersion = lilv_new_uri(world, LV2_CORE__microVersion); + LilvNode* minor = NULL; + LilvNode* micro = NULL; char* old_bundle_path = malloc(strlen(LILV_TEST_DIR) + 32); strcpy(old_bundle_path, LILV_TEST_DIR); @@ -2053,8 +2055,12 @@ test_replace_version(void) const LilvPlugins* plugins = lilv_world_get_all_plugins(world); const LilvPlugin* old_plug = lilv_plugins_get_by_uri(plugins, plug_uri); TEST_ASSERT(old_plug); - TEST_ASSERT(!strcmp(lilv_node_as_string(lilv_world_get(world, plug_uri, lv2_minorVersion, 0)), "1")); - TEST_ASSERT(!strcmp(lilv_node_as_string(lilv_world_get(world, plug_uri, lv2_microVersion, 0)), "0")); + minor = lilv_world_get(world, plug_uri, lv2_minorVersion, 0); + micro = lilv_world_get(world, plug_uri, lv2_microVersion, 0); + TEST_ASSERT(!strcmp(lilv_node_as_string(minor), "1")); + TEST_ASSERT(!strcmp(lilv_node_as_string(micro), "0")); + lilv_node_free(micro); + lilv_node_free(minor); char* new_bundle_path = malloc(strlen(LILV_TEST_DIR) + 32); strcpy(new_bundle_path, LILV_TEST_DIR); @@ -2069,9 +2075,36 @@ test_replace_version(void) plugins = lilv_world_get_all_plugins(world); const LilvPlugin* new_plug = lilv_plugins_get_by_uri(plugins, plug_uri); TEST_ASSERT(new_plug); - TEST_ASSERT(!strcmp(lilv_node_as_string(lilv_world_get(world, plug_uri, lv2_minorVersion, 0)), "2")); - TEST_ASSERT(!strcmp(lilv_node_as_string(lilv_world_get(world, plug_uri, lv2_microVersion, 0)), "1")); + TEST_ASSERT(lilv_node_equals(lilv_plugin_get_bundle_uri(new_plug), new_bundle)); + minor = lilv_world_get(world, plug_uri, lv2_minorVersion, 0); + micro = lilv_world_get(world, plug_uri, lv2_microVersion, 0); + TEST_ASSERT(!strcmp(lilv_node_as_string(minor), "2")); + TEST_ASSERT(!strcmp(lilv_node_as_string(micro), "1")); + lilv_node_free(micro); + lilv_node_free(minor); + + // Try to load the old version again + lilv_world_load_bundle(world, old_bundle); + lilv_world_load_resource(world, plug_uri); + // Check that version in the world model has not changed + plugins = lilv_world_get_all_plugins(world); + new_plug = lilv_plugins_get_by_uri(plugins, plug_uri); + TEST_ASSERT(new_plug); + minor = lilv_world_get(world, plug_uri, lv2_minorVersion, 0); + micro = lilv_world_get(world, plug_uri, lv2_microVersion, 0); + TEST_ASSERT(!strcmp(lilv_node_as_string(minor), "2")); + TEST_ASSERT(!strcmp(lilv_node_as_string(micro), "1")); + lilv_node_free(micro); + lilv_node_free(minor); + + lilv_node_free(new_bundle); + lilv_node_free(old_bundle); + free(new_bundle_path); + free(old_bundle_path); + lilv_node_free(plug_uri); + lilv_node_free(lv2_minorVersion); + lilv_node_free(lv2_microVersion); return 1; } |