~vcs-imports/lilv/master

« back to all changes in this revision

Viewing changes to test/lilv_test.c

  • Committer: David Robillard
  • Date: 2015-10-29 04:29:33 UTC
  • Revision ID: git-v1:db1f21708808e2ad01292f08deb8da1788db6ee8
Support reloading bundles

git-svn-id: http://svn.drobilla.net/lad/trunk/lilv@5797 a436a847-0d15-0410-975c-d299462d15a1

Show diffs side-by-side

added added

removed removed

Lines of Context:
159
159
#define TEST_ASSERT(check) do {\
160
160
        test_count++;\
161
161
        if (!(check)) {\
162
 
                assert(false);\
163
162
                error_count++;\
164
 
                fprintf(stderr, "lilv_test.c:%d: error: %s\n", __LINE__, #check);\
 
163
                fprintf(stderr, "lilv_test.c:%d: error: test `%s' failed\n", __LINE__, #check);\
 
164
                assert(check);\
165
165
        }\
166
166
} while (0)
167
167
 
1940
1940
 
1941
1941
/*****************************************************************************/
1942
1942
 
 
1943
static int
 
1944
test_reload_bundle(void)
 
1945
{
 
1946
        // Create a simple plugin bundle
 
1947
        create_bundle(MANIFEST_PREFIXES
 
1948
                      ":plug a lv2:Plugin ; lv2:binary <foo" SHLIB_EXT "> ; rdfs:seeAlso <plugin.ttl> .\n",
 
1949
                      BUNDLE_PREFIXES
 
1950
                      ":plug a lv2:Plugin ; "
 
1951
                      PLUGIN_NAME("First name") " .");
 
1952
 
 
1953
        if (!init_world()) {
 
1954
                return 0;
 
1955
        }
 
1956
 
 
1957
        init_uris();
 
1958
        lilv_world_load_specifications(world);
 
1959
 
 
1960
        // Load bundle
 
1961
        LilvNode* bundle_uri = lilv_new_uri(world, bundle_dir_uri);
 
1962
        lilv_world_load_bundle(world, bundle_uri);
 
1963
 
 
1964
        // Check that plugin is present
 
1965
        const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
 
1966
        const LilvPlugin*  plug    = lilv_plugins_get_by_uri(plugins, plugin_uri_value);
 
1967
        TEST_ASSERT(plug);
 
1968
 
 
1969
        // Check that plugin name is correct
 
1970
        LilvNode* name = lilv_plugin_get_name(plug);
 
1971
        TEST_ASSERT(!strcmp(lilv_node_as_string(name), "First name"));
 
1972
        lilv_node_free(name);
 
1973
 
 
1974
        // Unload bundle from world and delete it
 
1975
        lilv_world_unload_bundle(world, bundle_uri);
 
1976
        delete_bundle();
 
1977
 
 
1978
        // Create a new version of the same bundle, but with a different name
 
1979
        create_bundle(MANIFEST_PREFIXES
 
1980
                      ":plug a lv2:Plugin ; lv2:binary <foo" SHLIB_EXT "> ; rdfs:seeAlso <plugin.ttl> .\n",
 
1981
                      BUNDLE_PREFIXES
 
1982
                      ":plug a lv2:Plugin ; "
 
1983
                      PLUGIN_NAME("Second name") " .");
 
1984
 
 
1985
        // Load new bundle
 
1986
        lilv_world_load_bundle(world, bundle_uri);
 
1987
 
 
1988
        // TODO: Mechanism to actually remove plugin from world list
 
1989
 
 
1990
        // Check that plugin is present again
 
1991
        const LilvPlugin* plug2 = lilv_plugins_get_by_uri(plugins, plugin_uri_value);
 
1992
        TEST_ASSERT(plug2);
 
1993
 
 
1994
        // Check that plugin now has new name
 
1995
        LilvNode* name2 = lilv_plugin_get_name(plug2);
 
1996
        TEST_ASSERT(name2);
 
1997
        TEST_ASSERT(!strcmp(lilv_node_as_string(name2), "Second name"));
 
1998
        lilv_node_free(name2);
 
1999
 
 
2000
        lilv_node_free(bundle_uri);
 
2001
        lilv_world_free(world);
 
2002
        world = NULL;
 
2003
 
 
2004
        return 1;
 
2005
}
 
2006
 
 
2007
/*****************************************************************************/
 
2008
 
1943
2009
/* add tests here */
1944
2010
static struct TestCase tests[] = {
1945
2011
        TEST_CASE(util),
1963
2029
        TEST_CASE(string),
1964
2030
        TEST_CASE(world),
1965
2031
        TEST_CASE(state),
 
2032
        TEST_CASE(reload_bundle),
1966
2033
        { NULL, NULL }
1967
2034
};
1968
2035