summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/instance.c3
-rw-r--r--src/node.c11
-rw-r--r--src/pluginclass.c11
-rw-r--r--src/query.c3
-rw-r--r--src/state.c8
-rw-r--r--src/util.c26
-rw-r--r--test/failed_lib_descriptor.lv2/failed_lib_descriptor.c30
-rw-r--r--test/failed_lib_descriptor.lv2/failed_lib_descriptor.ttl.in38
-rw-r--r--test/failed_lib_descriptor.lv2/manifest.ttl.in7
-rw-r--r--test/failed_lib_descriptor.lv2/test_failed_lib_descriptor.c44
-rw-r--r--test/lib_descriptor.lv2/lib_descriptor.c112
-rw-r--r--test/lib_descriptor.lv2/lib_descriptor.ttl.in41
-rw-r--r--test/lib_descriptor.lv2/manifest.ttl.in7
-rw-r--r--test/lib_descriptor.lv2/test_lib_descriptor.c52
-rw-r--r--test/lilv_test.c59
-rw-r--r--test/missing_descriptor.lv2/manifest.ttl.in7
-rw-r--r--test/missing_descriptor.lv2/missing_descriptor.c20
-rw-r--r--test/missing_descriptor.lv2/missing_descriptor.ttl.in38
-rw-r--r--test/missing_descriptor.lv2/test_missing_descriptor.c44
-rw-r--r--test/missing_name.lv2/manifest.ttl.in7
-rw-r--r--test/missing_name.lv2/missing_name.c93
-rw-r--r--test/missing_name.lv2/missing_name.ttl.in37
-rw-r--r--test/missing_name.lv2/test_missing_name.c44
-rw-r--r--test/missing_plugin.lv2/manifest.ttl.in7
-rw-r--r--test/missing_plugin.lv2/missing_plugin.c28
-rw-r--r--test/missing_plugin.lv2/missing_plugin.ttl.in38
-rw-r--r--test/missing_plugin.lv2/test_missing_plugin.c44
-rw-r--r--test/missing_port_name.lv2/manifest.ttl.in7
-rw-r--r--test/missing_port_name.lv2/missing_port_name.c93
-rw-r--r--test/missing_port_name.lv2/missing_port_name.ttl.in30
-rw-r--r--test/missing_port_name.lv2/test_missing_port_name.c46
-rw-r--r--test/test.lv2/manifest.ttl.in (renamed from test/manifest.ttl.in)4
-rw-r--r--test/test.lv2/test.c (renamed from test/test_plugin.c)2
-rw-r--r--test/test.lv2/test.ttl.in (renamed from test/test_plugin.ttl.in)2
-rw-r--r--wscript72
35 files changed, 1054 insertions, 61 deletions
diff --git a/src/instance.c b/src/instance.c
index 66f5d13..5092dcd 100644
--- a/src/instance.c
+++ b/src/instance.c
@@ -1,5 +1,5 @@
/*
- Copyright 2007-2014 David Robillard <http://drobilla.net>
+ Copyright 2007-2015 David Robillard <http://drobilla.net>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
@@ -14,7 +14,6 @@
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/src/node.c b/src/node.c
index d745adb..575d3f0 100644
--- a/src/node.c
+++ b/src/node.c
@@ -1,5 +1,5 @@
/*
- Copyright 2007-2014 David Robillard <http://drobilla.net>
+ Copyright 2007-2015 David Robillard <http://drobilla.net>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
@@ -14,7 +14,7 @@
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include <assert.h>
+#include <math.h>
#include <stdlib.h>
#include <string.h>
@@ -140,8 +140,6 @@ lilv_node_new_from_node(LilvWorld* world, const SordNode* node)
world, type, (const char*)sord_node_get_string_counted(node, &len));
lilv_node_set_numerics_from_string(result, len);
break;
- default:
- assert(false);
}
return result;
@@ -327,6 +325,7 @@ lilv_node_is_literal(const LilvNode* value)
case LILV_VALUE_STRING:
case LILV_VALUE_INT:
case LILV_VALUE_FLOAT:
+ case LILV_VALUE_BLOB:
return true;
default:
return false;
@@ -366,12 +365,12 @@ lilv_node_is_float(const LilvNode* value)
LILV_API float
lilv_node_as_float(const LilvNode* value)
{
- assert(lilv_node_is_float(value) || lilv_node_is_int(value));
if (lilv_node_is_float(value)) {
return value->val.float_val;
- } else { // lilv_node_is_int(value)
+ } else if (lilv_node_is_int(value)) {
return (float)value->val.int_val;
}
+ return NAN;
}
LILV_API bool
diff --git a/src/pluginclass.c b/src/pluginclass.c
index f6f6cc6..0afb39a 100644
--- a/src/pluginclass.c
+++ b/src/pluginclass.c
@@ -1,5 +1,5 @@
/*
- Copyright 2007-2014 David Robillard <http://drobilla.net>
+ Copyright 2007-2015 David Robillard <http://drobilla.net>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
@@ -14,7 +14,6 @@
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include <assert.h>
#include <stdlib.h>
#include <string.h>
@@ -26,9 +25,6 @@ lilv_plugin_class_new(LilvWorld* world,
const SordNode* uri,
const char* label)
{
- if (parent_node && sord_node_get_type(parent_node) != SORD_URI) {
- return NULL; // Not an LV2 plugin superclass (FIXME: discover properly)
- }
LilvPluginClass* pc = (LilvPluginClass*)malloc(sizeof(LilvPluginClass));
pc->world = world;
pc->uri = lilv_node_new_from_node(world, uri);
@@ -42,7 +38,10 @@ lilv_plugin_class_new(LilvWorld* world,
void
lilv_plugin_class_free(LilvPluginClass* plugin_class)
{
- assert(plugin_class->uri);
+ if (!plugin_class) {
+ return;
+ }
+
lilv_node_free(plugin_class->uri);
lilv_node_free(plugin_class->parent_uri);
lilv_node_free(plugin_class->label);
diff --git a/src/query.c b/src/query.c
index 0d06533..fe2988f 100644
--- a/src/query.c
+++ b/src/query.c
@@ -1,5 +1,5 @@
/*
- Copyright 2007-2014 David Robillard <http://drobilla.net>
+ Copyright 2007-2015 David Robillard <http://drobilla.net>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
@@ -14,7 +14,6 @@
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include <assert.h>
#include <limits.h>
#include <stdlib.h>
#include <string.h>
diff --git a/src/state.c b/src/state.c
index a29581a..ccc1b22 100644
--- a/src/state.c
+++ b/src/state.c
@@ -1,5 +1,5 @@
/*
- Copyright 2007-2014 David Robillard <http://drobilla.net>
+ Copyright 2007-2015 David Robillard <http://drobilla.net>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
@@ -231,7 +231,11 @@ abstract_path(LV2_State_Map_Path_Handle handle,
if (!copy || !lilv_file_equals(real_path, copy)) {
// No recent enough copy, make a new one
copy = lilv_find_free_path(cpath, lilv_path_exists, NULL);
- lilv_copy_file(real_path, copy);
+ const int st = lilv_copy_file(real_path, copy);
+ if (st) {
+ LILV_ERRORF("Error copying state file %s (%s)\n",
+ copy, strerror(st));
+ }
}
free(real_path);
free(cpath);
diff --git a/src/util.c b/src/util.c
index c072514..7def7bd 100644
--- a/src/util.c
+++ b/src/util.c
@@ -1,5 +1,5 @@
/*
- Copyright 2007-2014 David Robillard <http://drobilla.net>
+ Copyright 2007-2015 David Robillard <http://drobilla.net>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
@@ -21,7 +21,6 @@
# define _DARWIN_C_SOURCE 1 /* for flock */
#endif
-#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <stdarg.h>
@@ -90,7 +89,6 @@ lilv_strjoin(const char* first, ...)
char* new_result = (char*)realloc(result, len + this_len + 1);
if (!new_result) {
free(result);
- LILV_ERROR("realloc() failed\n");
return NULL;
}
@@ -293,36 +291,33 @@ lilv_copy_file(const char* src, const char* dst)
{
FILE* in = fopen(src, "r");
if (!in) {
- LILV_ERRORF("error opening %s (%s)\n", src, strerror(errno));
- return 1;
+ return errno;
}
FILE* out = fopen(dst, "w");
if (!out) {
- LILV_ERRORF("error opening %s (%s)\n", dst, strerror(errno));
- fclose(in);
- return 2;
+ return errno;
}
char* page = (char*)malloc(PAGE_SIZE);
size_t n_read = 0;
+ int st = 0;
while ((n_read = fread(page, 1, PAGE_SIZE, in)) > 0) {
if (fwrite(page, 1, n_read, out) != n_read) {
- LILV_ERRORF("write to %s failed (%s)\n", dst, strerror(errno));
+ st = errno;
break;
}
}
- const int ret = ferror(in) || ferror(out);
- if (ferror(in)) {
- LILV_ERRORF("read from %s failed (%s)\n", src, strerror(errno));
+ if (!st && (ferror(in) || ferror(out))) {
+ st = EBADFD;
}
free(page);
fclose(in);
fclose(out);
- return ret;
+ return st;
}
bool
@@ -381,6 +376,7 @@ lilv_size_mtime(const char* path, off_t* size, time_t* time)
struct stat buf;
if (stat(path, &buf)) {
LILV_ERRORF("stat(%s) (%s)\n", path, strerror(errno));
+ return;
}
if (size) {
@@ -575,10 +571,8 @@ lilv_mkdir_p(const char* dir_path)
if (path[i] == LILV_DIR_SEP[0] || path[i] == '\0') {
path[i] = '\0';
if (mkdir(path, 0755) && errno != EEXIST) {
- LILV_ERRORF("Failed to create %s (%s)\n",
- path, strerror(errno));
free(path);
- return 1;
+ return errno;
}
path[i] = LILV_DIR_SEP[0];
}
diff --git a/test/failed_lib_descriptor.lv2/failed_lib_descriptor.c b/test/failed_lib_descriptor.lv2/failed_lib_descriptor.c
new file mode 100644
index 0000000..6a1fd90
--- /dev/null
+++ b/test/failed_lib_descriptor.lv2/failed_lib_descriptor.c
@@ -0,0 +1,30 @@
+/*
+ Lilv Test Plugin - Failed lib descriptor
+ Copyright 2011-2015 David Robillard <d@drobilla.net>
+
+ Permission to use, copy, modify, and/or distribute this software for any
+ purpose with or without fee is hereby granted, provided that the above
+ copyright notice and this permission notice appear in all copies.
+
+ THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+*/
+
+#include <stdlib.h>
+
+#include "lv2/lv2plug.in/ns/lv2core/lv2.h"
+
+#define PLUGIN_URI "http://example.org/failed-lib-descriptor"
+
+LV2_SYMBOL_EXPORT
+const LV2_Lib_Descriptor*
+lv2_lib_descriptor(const char* bundle_path,
+ const LV2_Feature*const* features)
+{
+ return NULL;
+}
diff --git a/test/failed_lib_descriptor.lv2/failed_lib_descriptor.ttl.in b/test/failed_lib_descriptor.lv2/failed_lib_descriptor.ttl.in
new file mode 100644
index 0000000..f41545f
--- /dev/null
+++ b/test/failed_lib_descriptor.lv2/failed_lib_descriptor.ttl.in
@@ -0,0 +1,38 @@
+# Lilv Test Plugin - Failed lib descriptor
+# Copyright 2011-2015 David Robillard <d@drobilla.net>
+#
+# Permission to use, copy, modify, and/or distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+@prefix doap: <http://usefulinc.com/ns/doap#> .
+@prefix foaf: <http://xmlns.com/foaf/0.1/> .
+@prefix lv2: <http://lv2plug.in/ns/lv2core#> .
+@prefix ui: <http://lv2plug.in/ns/extensions/ui#> .
+
+<http://example.org/failed-lib-descriptor>
+ a lv2:Plugin ;
+ doap:name "Missing descriptor test" ;
+ doap:license <http://opensource.org/licenses/isc> ;
+ lv2:optionalFeature lv2:hardRTCapable ;
+ lv2:port [
+ a lv2:InputPort ,
+ lv2:ControlPort ;
+ lv2:index 0 ;
+ lv2:symbol "input" ;
+ lv2:name "Input"
+ ] , [
+ a lv2:OutputPort ,
+ lv2:ControlPort ;
+ lv2:index 1 ;
+ lv2:symbol "output" ;
+ lv2:name "Output"
+ ] .
diff --git a/test/failed_lib_descriptor.lv2/manifest.ttl.in b/test/failed_lib_descriptor.lv2/manifest.ttl.in
new file mode 100644
index 0000000..4724f0f
--- /dev/null
+++ b/test/failed_lib_descriptor.lv2/manifest.ttl.in
@@ -0,0 +1,7 @@
+@prefix lv2: <http://lv2plug.in/ns/lv2core#> .
+@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
+
+<http://example.org/failed-lib-descriptor>
+ a lv2:Plugin ;
+ lv2:binary <failed_lib_descriptor@SHLIB_EXT@> ;
+ rdfs:seeAlso <failed_lib_descriptor.ttl> .
diff --git a/test/failed_lib_descriptor.lv2/test_failed_lib_descriptor.c b/test/failed_lib_descriptor.lv2/test_failed_lib_descriptor.c
new file mode 100644
index 0000000..2bdc999
--- /dev/null
+++ b/test/failed_lib_descriptor.lv2/test_failed_lib_descriptor.c
@@ -0,0 +1,44 @@
+#include "lilv/lilv.h"
+#include "../src/lilv_internal.h"
+
+#define PLUGIN_URI "http://example.org/failed-lib-descriptor"
+
+#define TEST_ASSERT(check) do {\
+ if (!(check)) {\
+ fprintf(stderr, "%s:%d: failed test: %s\n", __FILE__, __LINE__, #check);\
+ return 1;\
+ }\
+} while (0)
+
+int
+main(int argc, char** argv)
+{
+ if (argc != 2) {
+ fprintf(stderr, "USAGE: %s BUNDLE\n", argv[0]);
+ return 1;
+ }
+
+ const char* bundle_path = argv[1];
+ LilvWorld* world = lilv_world_new();
+
+ // Load test plugin bundle
+ uint8_t* abs_bundle = (uint8_t*)lilv_path_absolute(bundle_path);
+ SerdNode bundle = serd_node_new_file_uri(abs_bundle, 0, 0, true);
+ LilvNode* bundle_uri = lilv_new_uri(world, (const char*)bundle.buf);
+ lilv_world_load_bundle(world, bundle_uri);
+ free(abs_bundle);
+ serd_node_free(&bundle);
+
+ LilvNode* plugin_uri = lilv_new_uri(world, PLUGIN_URI);
+ const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
+ const LilvPlugin* plugin = lilv_plugins_get_by_uri(plugins, plugin_uri);
+ TEST_ASSERT(plugin);
+
+ LilvInstance* instance = lilv_plugin_instantiate(plugin, 48000.0, NULL);
+ TEST_ASSERT(!instance);
+
+ lilv_world_free(world);
+
+ return 0;
+}
+
diff --git a/test/lib_descriptor.lv2/lib_descriptor.c b/test/lib_descriptor.lv2/lib_descriptor.c
new file mode 100644
index 0000000..48dc775
--- /dev/null
+++ b/test/lib_descriptor.lv2/lib_descriptor.c
@@ -0,0 +1,112 @@
+/*
+ Lilv Test Plugin - Missing descriptor
+ Copyright 2011-2015 David Robillard <d@drobilla.net>
+
+ Permission to use, copy, modify, and/or distribute this software for any
+ purpose with or without fee is hereby granted, provided that the above
+ copyright notice and this permission notice appear in all copies.
+
+ THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+*/
+
+#include <stdlib.h>
+
+#include "lv2/lv2plug.in/ns/lv2core/lv2.h"
+
+#define PLUGIN_URI "http://example.org/lib-descriptor"
+
+enum {
+ TEST_INPUT = 0,
+ TEST_OUTPUT = 1
+};
+
+typedef struct {
+ float* input;
+ float* output;
+} Test;
+
+static void
+cleanup(LV2_Handle instance)
+{
+ free((Test*)instance);
+}
+
+static void
+connect_port(LV2_Handle instance, uint32_t port, void* data)
+{
+ Test* test = (Test*)instance;
+ switch (port) {
+ case TEST_INPUT:
+ test->input = (float*)data;
+ break;
+ case TEST_OUTPUT:
+ test->output = (float*)data;
+ break;
+ default:
+ break;
+ }
+}
+
+static LV2_Handle
+instantiate(const LV2_Descriptor* descriptor,
+ double rate,
+ const char* path,
+ const LV2_Feature* const* features)
+{
+ Test* test = (Test*)calloc(1, sizeof(Test));
+ if (!test) {
+ return NULL;
+ }
+
+ return (LV2_Handle)test;
+}
+
+static void
+run(LV2_Handle instance, uint32_t sample_count)
+{
+ Test* test = (Test*)instance;
+
+ *test->output = *test->input;
+}
+
+static const LV2_Descriptor descriptor = {
+ PLUGIN_URI,
+ instantiate,
+ connect_port,
+ NULL, // activate,
+ run,
+ NULL, // deactivate,
+ cleanup,
+ NULL // extension_data
+};
+
+static const LV2_Descriptor*
+get_plugin(LV2_Lib_Handle handle, uint32_t index)
+{
+ switch (index) {
+ case 0:
+ return &descriptor;
+ default:
+ return NULL;
+ }
+}
+
+static const LV2_Lib_Descriptor lib = {
+ NULL,
+ sizeof(LV2_Lib_Descriptor),
+ NULL,
+ get_plugin };
+
+LV2_SYMBOL_EXPORT
+const LV2_Lib_Descriptor*
+lv2_lib_descriptor(const char* bundle_path,
+ const LV2_Feature*const* features)
+{
+ return &lib;
+}
diff --git a/test/lib_descriptor.lv2/lib_descriptor.ttl.in b/test/lib_descriptor.lv2/lib_descriptor.ttl.in
new file mode 100644
index 0000000..19c8c4a
--- /dev/null
+++ b/test/lib_descriptor.lv2/lib_descriptor.ttl.in
@@ -0,0 +1,41 @@
+# Lilv Test Plugin - Missing descriptor
+# Copyright 2011-2015 David Robillard <d@drobilla.net>
+#
+# Permission to use, copy, modify, and/or distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+@prefix doap: <http://usefulinc.com/ns/doap#> .
+@prefix foaf: <http://xmlns.com/foaf/0.1/> .
+@prefix lv2: <http://lv2plug.in/ns/lv2core#> .
+@prefix ui: <http://lv2plug.in/ns/extensions/ui#> .
+@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
+
+<http://example.org/lib-descriptor>
+ a lv2:Plugin ;
+ doap:name "Missing descriptor test" ;
+ doap:license <http://opensource.org/licenses/isc> ;
+ lv2:optionalFeature lv2:hardRTCapable ;
+ <http://example.org/blob> "aGVsbG8sIHdvcmxk"^^xsd:base64Binary ;
+ <http://example.org/junk> "opaque"^^<http://example.org/binary> ;
+ lv2:port [
+ a lv2:InputPort ,
+ lv2:ControlPort ;
+ lv2:index 0 ;
+ lv2:symbol "input" ;
+ lv2:name "Input"
+ ] , [
+ a lv2:OutputPort ,
+ lv2:ControlPort ;
+ lv2:index 1 ;
+ lv2:symbol "output" ;
+ lv2:name "Output"
+ ] .
diff --git a/test/lib_descriptor.lv2/manifest.ttl.in b/test/lib_descriptor.lv2/manifest.ttl.in
new file mode 100644
index 0000000..5f4eced
--- /dev/null
+++ b/test/lib_descriptor.lv2/manifest.ttl.in
@@ -0,0 +1,7 @@
+@prefix lv2: <http://lv2plug.in/ns/lv2core#> .
+@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
+
+<http://example.org/lib-descriptor>
+ a lv2:Plugin ;
+ lv2:binary <lib_descriptor@SHLIB_EXT@> ;
+ rdfs:seeAlso <lib_descriptor.ttl> .
diff --git a/test/lib_descriptor.lv2/test_lib_descriptor.c b/test/lib_descriptor.lv2/test_lib_descriptor.c
new file mode 100644
index 0000000..3409ef2
--- /dev/null
+++ b/test/lib_descriptor.lv2/test_lib_descriptor.c
@@ -0,0 +1,52 @@
+#include "lilv/lilv.h"
+#include "../src/lilv_internal.h"
+
+#define PLUGIN_URI "http://example.org/lib-descriptor"
+
+#define TEST_ASSERT(check) do {\
+ if (!(check)) {\
+ fprintf(stderr, "%s:%d: failed test: %s\n", __FILE__, __LINE__, #check);\
+ return 1;\
+ }\
+} while (0)
+
+int
+main(int argc, char** argv)
+{
+ if (argc != 2) {
+ fprintf(stderr, "USAGE: %s BUNDLE\n", argv[0]);
+ return 1;
+ }
+
+ const char* bundle_path = argv[1];
+ LilvWorld* world = lilv_world_new();
+
+ // Load test plugin bundle
+ uint8_t* abs_bundle = (uint8_t*)lilv_path_absolute(bundle_path);
+ SerdNode bundle = serd_node_new_file_uri(abs_bundle, 0, 0, true);
+ LilvNode* bundle_uri = lilv_new_uri(world, (const char*)bundle.buf);
+ lilv_world_load_bundle(world, bundle_uri);
+ free(abs_bundle);
+ serd_node_free(&bundle);
+
+ LilvNode* plugin_uri = lilv_new_uri(world, PLUGIN_URI);
+ const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
+ const LilvPlugin* plugin = lilv_plugins_get_by_uri(plugins, plugin_uri);
+ TEST_ASSERT(plugin);
+
+ LilvInstance* instance = lilv_plugin_instantiate(plugin, 48000.0, NULL);
+ TEST_ASSERT(instance);
+
+ LilvNode* eg_blob = lilv_new_uri(world, "http://example.org/blob");
+ LilvNode* blob = lilv_world_get(world, plugin_uri, eg_blob, NULL);
+ TEST_ASSERT(lilv_node_is_literal(blob));
+
+ LilvNode* eg_junk = lilv_new_uri(world, "http://example.org/junk");
+ LilvNode* junk = lilv_world_get(world, plugin_uri, eg_junk, NULL);
+ TEST_ASSERT(lilv_node_is_literal(junk));
+
+ lilv_world_free(world);
+
+ return 0;
+}
+
diff --git a/test/lilv_test.c b/test/lilv_test.c
index e89239c..3e2a23a 100644
--- a/test/lilv_test.c
+++ b/test/lilv_test.c
@@ -1,5 +1,5 @@
/*
- Copyright 2007-2014 David Robillard <http://drobilla.net>
+ Copyright 2007-2015 David Robillard <http://drobilla.net>
Copyright 2008 Krzysztof Foltman
Permission to use, copy, modify, and/or distribute this software for any
@@ -241,6 +241,7 @@ test_value(void)
TEST_ASSERT(lilv_node_is_int(ival));
TEST_ASSERT(lilv_node_is_float(fval));
+ TEST_ASSERT(!lilv_node_is_literal(NULL));
TEST_ASSERT(!lilv_node_is_literal(uval));
TEST_ASSERT(lilv_node_is_literal(sval));
TEST_ASSERT(lilv_node_is_literal(ival));
@@ -605,6 +606,9 @@ test_plugin(void)
TEST_ASSERT(lilv_nodes_contains(data_uris, data_uri_val));
lilv_node_free(data_uri_val);
+ LilvNode* unknown_uri_val = lilv_new_uri(world, "http://example.org/unknown");
+ TEST_ASSERT(!lilv_nodes_contains(data_uris, unknown_uri_val));
+
free(manifest_uri);
free(data_uri);
@@ -645,6 +649,7 @@ test_plugin(void)
TEST_ASSERT(latency_port);
TEST_ASSERT(lilv_port_get_index(plug, latency_port) == 2);
+ TEST_ASSERT(lilv_node_is_blank(lilv_port_get_node(plug, latency_port)));
LilvNode* rt_feature = lilv_new_uri(world,
"http://lv2plug.in/ns/lv2core#hardRTCapable");
@@ -1060,6 +1065,12 @@ test_port(void)
TEST_ASSERT(p3 == NULL);
lilv_node_free(nopsym);
+ // Try getting an invalid property
+ LilvNode* num = lilv_new_int(world, 1);
+ LilvNodes* nothing = lilv_port_get_value(plug, p, num);
+ TEST_ASSERT(!nothing);
+ lilv_node_free(num);
+
LilvNode* audio_class = lilv_new_uri(world,
"http://lv2plug.in/ns/lv2core#AudioPort");
LilvNode* control_class = lilv_new_uri(world,
@@ -1116,6 +1127,12 @@ test_port(void)
TEST_ASSERT(!strcmp(lilv_node_as_string(name), "store"));
lilv_node_free(name);
+ // Invalid language
+ setenv("LANG", "1!", 1);
+ name = lilv_port_get_name(plug, p);
+ TEST_ASSERT(!strcmp(lilv_node_as_string(name), "store"));
+ lilv_node_free(name);
+
setenv("LANG", "en_CA.utf-8", 1);
// Language tagged value with no untranslated values
@@ -1347,11 +1364,15 @@ test_ui(void)
LilvNode* ui_class_uri = lilv_new_uri(world,
"http://lv2plug.in/ns/extensions/ui#GtkUI");
+ LilvNode* unknown_ui_class_uri = lilv_new_uri(world,
+ "http://example.org/mysteryUI");
+
TEST_ASSERT(lilv_node_equals(lilv_nodes_get_first(classes), ui_class_uri));
TEST_ASSERT(lilv_ui_is_a(ui0, ui_class_uri));
const LilvNode* ui_type = NULL;
TEST_ASSERT(lilv_ui_is_supported(ui0, ui_supported, ui_class_uri, &ui_type));
+ TEST_ASSERT(!lilv_ui_is_supported(ui0, ui_supported, unknown_ui_class_uri, &ui_type));
TEST_ASSERT(lilv_node_equals(ui_type, ui_class_uri));
const LilvNode* plug_bundle_uri = lilv_plugin_get_bundle_uri(plug);
@@ -1647,6 +1668,15 @@ test_state(void)
lilv_instance_connect_port(instance, 1, &out);
lilv_instance_run(instance, 1);
+ // Test instantiating twice
+ LilvInstance* instance2 = lilv_plugin_instantiate(plugin, 48000.0, ffeatures);
+ if (!instance2) {
+ fatal_error("Failed to create multiple instances of <%s>\n",
+ lilv_node_as_uri(state_plugin_uri));
+ return 0;
+ }
+ lilv_instance_free(instance2);
+
// Get instance state state
LilvState* fstate = lilv_state_new_from_instance(
plugin, instance, &map,
@@ -1869,6 +1899,32 @@ test_string(void)
/*****************************************************************************/
+static int
+test_world(void)
+{
+ if (!init_world()) {
+ return 0;
+ }
+
+ LilvNode* num = lilv_new_int(world, 4);
+ LilvNode* uri = lilv_new_uri(world, "http://example.org/object");
+
+ LilvNodes* matches = lilv_world_find_nodes(world, num, NULL, NULL);
+ TEST_ASSERT(!matches);
+
+ matches = lilv_world_find_nodes(world, NULL, num, NULL);
+ TEST_ASSERT(!matches);
+
+ matches = lilv_world_find_nodes(world, NULL, uri, NULL);
+ TEST_ASSERT(!matches);
+
+ lilv_world_unload_bundle(world, NULL);
+
+ return 1;
+}
+
+/*****************************************************************************/
+
/* add tests here */
static struct TestCase tests[] = {
TEST_CASE(value),
@@ -1889,6 +1945,7 @@ static struct TestCase tests[] = {
TEST_CASE(bad_port_index),
TEST_CASE(bad_port_index),
TEST_CASE(string),
+ TEST_CASE(world),
TEST_CASE(state),
{ NULL, NULL }
};
diff --git a/test/missing_descriptor.lv2/manifest.ttl.in b/test/missing_descriptor.lv2/manifest.ttl.in
new file mode 100644
index 0000000..789d1ec
--- /dev/null
+++ b/test/missing_descriptor.lv2/manifest.ttl.in
@@ -0,0 +1,7 @@
+@prefix lv2: <http://lv2plug.in/ns/lv2core#> .
+@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
+
+<http://example.org/missing-descriptor>
+ a lv2:Plugin ;
+ lv2:binary <missing_descriptor@SHLIB_EXT@> ;
+ rdfs:seeAlso <missing_descriptor.ttl> .
diff --git a/test/missing_descriptor.lv2/missing_descriptor.c b/test/missing_descriptor.lv2/missing_descriptor.c
new file mode 100644
index 0000000..0aa2050
--- /dev/null
+++ b/test/missing_descriptor.lv2/missing_descriptor.c
@@ -0,0 +1,20 @@
+/*
+ Lilv Test Plugin - Missing descriptor
+ Copyright 2011-2015 David Robillard <d@drobilla.net>
+
+ Permission to use, copy, modify, and/or distribute this software for any
+ purpose with or without fee is hereby granted, provided that the above
+ copyright notice and this permission notice appear in all copies.
+
+ THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+*/
+
+#include "lv2/lv2plug.in/ns/lv2core/lv2.h"
+
+LV2_SYMBOL_EXPORT const char* msg = "this is not the thing you're looking for";
diff --git a/test/missing_descriptor.lv2/missing_descriptor.ttl.in b/test/missing_descriptor.lv2/missing_descriptor.ttl.in
new file mode 100644
index 0000000..9e2aad8
--- /dev/null
+++ b/test/missing_descriptor.lv2/missing_descriptor.ttl.in
@@ -0,0 +1,38 @@
+# Lilv Test Plugin - Missing descriptor
+# Copyright 2011-2015 David Robillard <d@drobilla.net>
+#
+# Permission to use, copy, modify, and/or distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+@prefix doap: <http://usefulinc.com/ns/doap#> .
+@prefix foaf: <http://xmlns.com/foaf/0.1/> .
+@prefix lv2: <http://lv2plug.in/ns/lv2core#> .
+@prefix ui: <http://lv2plug.in/ns/extensions/ui#> .
+
+<http://example.org/missing-descriptor>
+ a lv2:Plugin ;
+ doap:name "Missing descriptor test" ;
+ doap:license <http://opensource.org/licenses/isc> ;
+ lv2:optionalFeature lv2:hardRTCapable ;
+ lv2:port [
+ a lv2:InputPort ,
+ lv2:ControlPort ;
+ lv2:index 0 ;
+ lv2:symbol "input" ;
+ lv2:name "Input"
+ ] , [
+ a lv2:OutputPort ,
+ lv2:ControlPort ;
+ lv2:index 1 ;
+ lv2:symbol "output" ;
+ lv2:name "Output"
+ ] .
diff --git a/test/missing_descriptor.lv2/test_missing_descriptor.c b/test/missing_descriptor.lv2/test_missing_descriptor.c
new file mode 100644
index 0000000..e0af49e
--- /dev/null
+++ b/test/missing_descriptor.lv2/test_missing_descriptor.c
@@ -0,0 +1,44 @@
+#include "lilv/lilv.h"
+#include "../src/lilv_internal.h"
+
+#define PLUGIN_URI "http://example.org/missing-descriptor"
+
+#define TEST_ASSERT(check) do {\
+ if (!(check)) {\
+ fprintf(stderr, "%s:%d: failed test: %s\n", __FILE__, __LINE__, #check);\
+ return 1;\
+ }\
+} while (0)
+
+int
+main(int argc, char** argv)
+{
+ if (argc != 2) {
+ fprintf(stderr, "USAGE: %s BUNDLE\n", argv[0]);
+ return 1;
+ }
+
+ const char* bundle_path = argv[1];
+ LilvWorld* world = lilv_world_new();
+
+ // Load test plugin bundle
+ uint8_t* abs_bundle = (uint8_t*)lilv_path_absolute(bundle_path);
+ SerdNode bundle = serd_node_new_file_uri(abs_bundle, 0, 0, true);
+ LilvNode* bundle_uri = lilv_new_uri(world, (const char*)bundle.buf);
+ lilv_world_load_bundle(world, bundle_uri);
+ free(abs_bundle);
+ serd_node_free(&bundle);
+
+ LilvNode* plugin_uri = lilv_new_uri(world, PLUGIN_URI);
+ const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
+ const LilvPlugin* plugin = lilv_plugins_get_by_uri(plugins, plugin_uri);
+ TEST_ASSERT(plugin);
+
+ LilvInstance* instance = lilv_plugin_instantiate(plugin, 48000.0, NULL);
+ TEST_ASSERT(!instance);
+
+ lilv_world_free(world);
+
+ return 0;
+}
+
diff --git a/test/missing_name.lv2/manifest.ttl.in b/test/missing_name.lv2/manifest.ttl.in
new file mode 100644
index 0000000..62f4813
--- /dev/null
+++ b/test/missing_name.lv2/manifest.ttl.in
@@ -0,0 +1,7 @@
+@prefix lv2: <http://lv2plug.in/ns/lv2core#> .
+@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
+
+<http://example.org/missing-name>
+ a lv2:Plugin ;
+ lv2:binary <missing_name@SHLIB_EXT@> ;
+ rdfs:seeAlso <missing_name.ttl> .
diff --git a/test/missing_name.lv2/missing_name.c b/test/missing_name.lv2/missing_name.c
new file mode 100644
index 0000000..8a198b9
--- /dev/null
+++ b/test/missing_name.lv2/missing_name.c
@@ -0,0 +1,93 @@
+/*
+ Lilv Test Plugin - Missing descriptor
+ Copyright 2011-2015 David Robillard <d@drobilla.net>
+
+ Permission to use, copy, modify, and/or distribute this software for any
+ purpose with or without fee is hereby granted, provided that the above
+ copyright notice and this permission notice appear in all copies.
+
+ THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+*/
+
+#include <stdlib.h>
+
+#include "lv2/lv2plug.in/ns/lv2core/lv2.h"
+
+#define PLUGIN_URI "http://example.org/missing-name"
+
+enum {
+ TEST_INPUT = 0,
+ TEST_OUTPUT = 1
+};
+
+typedef struct {
+ float* input;
+ float* output;
+} Test;
+
+static void
+cleanup(LV2_Handle instance)
+{
+ free((Test*)instance);
+}
+
+static void
+connect_port(LV2_Handle instance, uint32_t port, void* data)
+{
+ Test* test = (Test*)instance;
+ switch (port) {
+ case TEST_INPUT:
+ test->input = (float*)data;
+ break;
+ case TEST_OUTPUT:
+ test->output = (float*)data;
+ break;
+ default:
+ break;
+ }
+}
+
+static LV2_Handle
+instantiate(const LV2_Descriptor* descriptor,
+ double rate,
+ const char* path,
+ const LV2_Feature* const* features)
+{
+ Test* test = (Test*)calloc(1, sizeof(Test));
+ if (!test) {
+ return NULL;
+ }
+
+ return (LV2_Handle)test;
+}
+
+static void
+run(LV2_Handle instance, uint32_t sample_count)
+{
+ Test* test = (Test*)instance;
+
+ *test->output = *test->input;
+}
+
+static const LV2_Descriptor descriptor = {
+ PLUGIN_URI,
+ instantiate,
+ connect_port,
+ NULL, // activate,
+ run,
+ NULL, // deactivate,
+ cleanup,
+ NULL // extension_data
+};
+
+LV2_SYMBOL_EXPORT
+const LV2_Descriptor* lv2_descriptor(uint32_t index)
+{
+ return (index == 0) ? &descriptor : NULL;
+}
diff --git a/test/missing_name.lv2/missing_name.ttl.in b/test/missing_name.lv2/missing_name.ttl.in
new file mode 100644
index 0000000..68ce23e
--- /dev/null
+++ b/test/missing_name.lv2/missing_name.ttl.in
@@ -0,0 +1,37 @@
+# Lilv Test Plugin - Missing plugin name
+# Copyright 2011-2015 David Robillard <d@drobilla.net>
+#
+# Permission to use, copy, modify, and/or distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+@prefix doap: <http://usefulinc.com/ns/doap#> .
+@prefix foaf: <http://xmlns.com/foaf/0.1/> .
+@prefix lv2: <http://lv2plug.in/ns/lv2core#> .
+@prefix ui: <http://lv2plug.in/ns/extensions/ui#> .
+
+<http://example.org/missing-name>
+ a lv2:Plugin ;
+ doap:license <http://opensource.org/licenses/isc> ;
+ lv2:optionalFeature lv2:hardRTCapable ;
+ lv2:port [
+ a lv2:InputPort ,
+ lv2:ControlPort ;
+ lv2:index 0 ;
+ lv2:symbol "input" ;
+ lv2:name "Input"
+ ] , [
+ a lv2:OutputPort ,
+ lv2:ControlPort ;
+ lv2:index 1 ;
+ lv2:symbol "output" ;
+ lv2:name "Output"
+ ] .
diff --git a/test/missing_name.lv2/test_missing_name.c b/test/missing_name.lv2/test_missing_name.c
new file mode 100644
index 0000000..9237ae2
--- /dev/null
+++ b/test/missing_name.lv2/test_missing_name.c
@@ -0,0 +1,44 @@
+#include "lilv/lilv.h"
+#include "../src/lilv_internal.h"
+
+#define PLUGIN_URI "http://example.org/missing-name"
+
+#define TEST_ASSERT(check) do {\
+ if (!(check)) {\
+ fprintf(stderr, "%s:%d: failed test: %s\n", __FILE__, __LINE__, #check);\
+ return 1;\
+ }\
+} while (0)
+
+int
+main(int argc, char** argv)
+{
+ if (argc != 2) {
+ fprintf(stderr, "USAGE: %s BUNDLE\n", argv[0]);
+ return 1;
+ }
+
+ const char* bundle_path = argv[1];
+ LilvWorld* world = lilv_world_new();
+
+ // Load test plugin bundle
+ uint8_t* abs_bundle = (uint8_t*)lilv_path_absolute(bundle_path);
+ SerdNode bundle = serd_node_new_file_uri(abs_bundle, 0, 0, true);
+ LilvNode* bundle_uri = lilv_new_uri(world, (const char*)bundle.buf);
+ lilv_world_load_bundle(world, bundle_uri);
+ free(abs_bundle);
+ serd_node_free(&bundle);
+
+ LilvNode* plugin_uri = lilv_new_uri(world, PLUGIN_URI);
+ const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
+ const LilvPlugin* plugin = lilv_plugins_get_by_uri(plugins, plugin_uri);
+ TEST_ASSERT(plugin);
+
+ LilvInstance* instance = lilv_plugin_instantiate(plugin, 48000.0, NULL);
+ TEST_ASSERT(instance);
+
+ lilv_world_free(world);
+
+ return 0;
+}
+
diff --git a/test/missing_plugin.lv2/manifest.ttl.in b/test/missing_plugin.lv2/manifest.ttl.in
new file mode 100644
index 0000000..d969cec
--- /dev/null
+++ b/test/missing_plugin.lv2/manifest.ttl.in
@@ -0,0 +1,7 @@
+@prefix lv2: <http://lv2plug.in/ns/lv2core#> .
+@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
+
+<http://example.org/missing-plugin>
+ a lv2:Plugin ;
+ lv2:binary <missing_plugin@SHLIB_EXT@> ;
+ rdfs:seeAlso <missing_plugin.ttl> .
diff --git a/test/missing_plugin.lv2/missing_plugin.c b/test/missing_plugin.lv2/missing_plugin.c
new file mode 100644
index 0000000..577d42a
--- /dev/null
+++ b/test/missing_plugin.lv2/missing_plugin.c
@@ -0,0 +1,28 @@
+/*
+ Lilv Test Plugin - Missing plugin
+ Copyright 2011-2015 David Robillard <d@drobilla.net>
+
+ Permission to use, copy, modify, and/or distribute this software for any
+ purpose with or without fee is hereby granted, provided that the above
+ copyright notice and this permission notice appear in all copies.
+
+ THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+*/
+
+#include <stdlib.h>
+
+#include "lv2/lv2plug.in/ns/lv2core/lv2.h"
+
+#define PLUGIN_URI "http://example.org/missing-plugin"
+
+LV2_SYMBOL_EXPORT
+const LV2_Descriptor* lv2_descriptor(uint32_t index)
+{
+ return NULL;
+}
diff --git a/test/missing_plugin.lv2/missing_plugin.ttl.in b/test/missing_plugin.lv2/missing_plugin.ttl.in
new file mode 100644
index 0000000..ed8a7f3
--- /dev/null
+++ b/test/missing_plugin.lv2/missing_plugin.ttl.in
@@ -0,0 +1,38 @@
+# Lilv Test Plugin - Missing plugin
+# Copyright 2011-2015 David Robillard <d@drobilla.net>
+#
+# Permission to use, copy, modify, and/or distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+@prefix doap: <http://usefulinc.com/ns/doap#> .
+@prefix foaf: <http://xmlns.com/foaf/0.1/> .
+@prefix lv2: <http://lv2plug.in/ns/lv2core#> .
+@prefix ui: <http://lv2plug.in/ns/extensions/ui#> .
+
+<http://example.org/missing-plugin>
+ a lv2:Plugin ;
+ doap:name "Missing descriptor test" ;
+ doap:license <http://opensource.org/licenses/isc> ;
+ lv2:optionalFeature lv2:hardRTCapable ;
+ lv2:port [
+ a lv2:InputPort ,
+ lv2:ControlPort ;
+ lv2:index 0 ;
+ lv2:symbol "input" ;
+ lv2:name "Input"
+ ] , [
+ a lv2:OutputPort ,
+ lv2:ControlPort ;
+ lv2:index 1 ;
+ lv2:symbol "output" ;
+ lv2:name "Output"
+ ] .
diff --git a/test/missing_plugin.lv2/test_missing_plugin.c b/test/missing_plugin.lv2/test_missing_plugin.c
new file mode 100644
index 0000000..01f00cd
--- /dev/null
+++ b/test/missing_plugin.lv2/test_missing_plugin.c
@@ -0,0 +1,44 @@
+#include "lilv/lilv.h"
+#include "../src/lilv_internal.h"
+
+#define PLUGIN_URI "http://example.org/missing-plugin"
+
+#define TEST_ASSERT(check) do {\
+ if (!(check)) {\
+ fprintf(stderr, "%s:%d: failed test: %s\n", __FILE__, __LINE__, #check);\
+ return 1;\
+ }\
+} while (0)
+
+int
+main(int argc, char** argv)
+{
+ if (argc != 2) {
+ fprintf(stderr, "USAGE: %s BUNDLE\n", argv[0]);
+ return 1;
+ }
+
+ const char* bundle_path = argv[1];
+ LilvWorld* world = lilv_world_new();
+
+ // Load test plugin bundle
+ uint8_t* abs_bundle = (uint8_t*)lilv_path_absolute(bundle_path);
+ SerdNode bundle = serd_node_new_file_uri(abs_bundle, 0, 0, true);
+ LilvNode* bundle_uri = lilv_new_uri(world, (const char*)bundle.buf);
+ lilv_world_load_bundle(world, bundle_uri);
+ free(abs_bundle);
+ serd_node_free(&bundle);
+
+ LilvNode* plugin_uri = lilv_new_uri(world, PLUGIN_URI);
+ const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
+ const LilvPlugin* plugin = lilv_plugins_get_by_uri(plugins, plugin_uri);
+ TEST_ASSERT(plugin);
+
+ LilvInstance* instance = lilv_plugin_instantiate(plugin, 48000.0, NULL);
+ TEST_ASSERT(!instance);
+
+ lilv_world_free(world);
+
+ return 0;
+}
+
diff --git a/test/missing_port_name.lv2/manifest.ttl.in b/test/missing_port_name.lv2/manifest.ttl.in
new file mode 100644
index 0000000..d6a4e39
--- /dev/null
+++ b/test/missing_port_name.lv2/manifest.ttl.in
@@ -0,0 +1,7 @@
+@prefix lv2: <http://lv2plug.in/ns/lv2core#> .
+@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
+
+<http://example.org/missing-port-name>
+ a lv2:Plugin ;
+ lv2:binary <missing_port_name@SHLIB_EXT@> ;
+ rdfs:seeAlso <missing_port_name.ttl> .
diff --git a/test/missing_port_name.lv2/missing_port_name.c b/test/missing_port_name.lv2/missing_port_name.c
new file mode 100644
index 0000000..4ed44ed
--- /dev/null
+++ b/test/missing_port_name.lv2/missing_port_name.c
@@ -0,0 +1,93 @@
+/*
+ Lilv Test Plugin - Missing port name
+ Copyright 2011-2015 David Robillard <d@drobilla.net>
+
+ Permission to use, copy, modify, and/or distribute this software for any
+ purpose with or without fee is hereby granted, provided that the above
+ copyright notice and this permission notice appear in all copies.
+
+ THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+*/
+
+#include <stdlib.h>
+
+#include "lv2/lv2plug.in/ns/lv2core/lv2.h"
+
+#define PLUGIN_URI "http://example.org/missing-port-name"
+
+enum {
+ TEST_INPUT = 0,
+ TEST_OUTPUT = 1
+};
+
+typedef struct {
+ float* input;
+ float* output;
+} Test;
+
+static void
+cleanup(LV2_Handle instance)
+{
+ free((Test*)instance);
+}
+
+static void
+connect_port(LV2_Handle instance, uint32_t port, void* data)
+{
+ Test* test = (Test*)instance;
+ switch (port) {
+ case TEST_INPUT:
+ test->input = (float*)data;
+ break;
+ case TEST_OUTPUT:
+ test->output = (float*)data;
+ break;
+ default:
+ break;
+ }
+}
+
+static LV2_Handle
+instantiate(const LV2_Descriptor* descriptor,
+ double rate,
+ const char* path,
+ const LV2_Feature* const* features)
+{
+ Test* test = (Test*)calloc(1, sizeof(Test));
+ if (!test) {
+ return NULL;
+ }
+
+ return (LV2_Handle)test;
+}
+
+static void
+run(LV2_Handle instance, uint32_t sample_count)
+{
+ Test* test = (Test*)instance;
+
+ *test->output = *test->input;
+}
+
+static const LV2_Descriptor descriptor = {
+ PLUGIN_URI,
+ instantiate,
+ connect_port,
+ NULL, // activate,
+ run,
+ NULL, // deactivate,
+ cleanup,
+ NULL // extension_data
+};
+
+LV2_SYMBOL_EXPORT
+const LV2_Descriptor* lv2_descriptor(uint32_t index)
+{
+ return (index == 0) ? &descriptor : NULL;
+}
diff --git a/test/missing_port_name.lv2/missing_port_name.ttl.in b/test/missing_port_name.lv2/missing_port_name.ttl.in
new file mode 100644
index 0000000..5a58a80
--- /dev/null
+++ b/test/missing_port_name.lv2/missing_port_name.ttl.in
@@ -0,0 +1,30 @@
+# Lilv Test Plugin - Missing port name
+# Copyright 2011-2015 David Robillard <d@drobilla.net>
+#
+# Permission to use, copy, modify, and/or distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+@prefix doap: <http://usefulinc.com/ns/doap#> .
+@prefix foaf: <http://xmlns.com/foaf/0.1/> .
+@prefix lv2: <http://lv2plug.in/ns/lv2core#> .
+@prefix ui: <http://lv2plug.in/ns/extensions/ui#> .
+
+<http://example.org/missing-port-name>
+ a lv2:Plugin ;
+ doap:license <http://opensource.org/licenses/isc> ;
+ lv2:optionalFeature lv2:hardRTCapable ;
+ lv2:port [
+ a lv2:InputPort ,
+ lv2:ControlPort ;
+ lv2:index 0 ;
+ lv2:symbol "input" ;
+ ] . \ No newline at end of file
diff --git a/test/missing_port_name.lv2/test_missing_port_name.c b/test/missing_port_name.lv2/test_missing_port_name.c
new file mode 100644
index 0000000..0f96918
--- /dev/null
+++ b/test/missing_port_name.lv2/test_missing_port_name.c
@@ -0,0 +1,46 @@
+#include "lilv/lilv.h"
+#include "../src/lilv_internal.h"
+
+#define PLUGIN_URI "http://example.org/missing-port-name"
+
+#define TEST_ASSERT(check) do {\
+ if (!(check)) {\
+ fprintf(stderr, "%s:%d: failed test: %s\n", __FILE__, __LINE__, #check);\
+ return 1;\
+ }\
+} while (0)
+
+int
+main(int argc, char** argv)
+{
+ if (argc != 2) {
+ fprintf(stderr, "USAGE: %s BUNDLE\n", argv[0]);
+ return 1;
+ }
+
+ const char* bundle_path = argv[1];
+ LilvWorld* world = lilv_world_new();
+
+ // Load test plugin bundle
+ uint8_t* abs_bundle = (uint8_t*)lilv_path_absolute(bundle_path);
+ SerdNode bundle = serd_node_new_file_uri(abs_bundle, 0, 0, true);
+ LilvNode* bundle_uri = lilv_new_uri(world, (const char*)bundle.buf);
+ lilv_world_load_bundle(world, bundle_uri);
+ free(abs_bundle);
+ serd_node_free(&bundle);
+
+ LilvNode* plugin_uri = lilv_new_uri(world, PLUGIN_URI);
+ const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
+ const LilvPlugin* plugin = lilv_plugins_get_by_uri(plugins, plugin_uri);
+ TEST_ASSERT(plugin);
+
+ const LilvPort* port = lilv_plugin_get_port_by_index(plugin, 0);
+ TEST_ASSERT(port);
+ LilvNode* name = lilv_port_get_name(plugin, port);
+ TEST_ASSERT(!name);
+
+ lilv_world_free(world);
+
+ return 0;
+}
+
diff --git a/test/manifest.ttl.in b/test/test.lv2/manifest.ttl.in
index 48b009b..bc3952c 100644
--- a/test/manifest.ttl.in
+++ b/test/test.lv2/manifest.ttl.in
@@ -3,5 +3,5 @@
<http://example.org/lilv-test-plugin>
a lv2:Plugin ;
- lv2:binary <test_plugin@SHLIB_EXT@> ;
- rdfs:seeAlso <test_plugin.ttl> .
+ lv2:binary <test@SHLIB_EXT@> ;
+ rdfs:seeAlso <test.ttl> .
diff --git a/test/test_plugin.c b/test/test.lv2/test.c
index edcc5ab..cd9a18c 100644
--- a/test/test_plugin.c
+++ b/test/test.lv2/test.c
@@ -1,6 +1,6 @@
/*
Lilv Test Plugin
- Copyright 2011-2012 David Robillard <d@drobilla.net>
+ Copyright 2011-2015 David Robillard <d@drobilla.net>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
diff --git a/test/test_plugin.ttl.in b/test/test.lv2/test.ttl.in
index 704f815..6fb6aed 100644
--- a/test/test_plugin.ttl.in
+++ b/test/test.lv2/test.ttl.in
@@ -1,5 +1,5 @@
# Lilv Test Plugin
-# Copyright 2011 David Robillard <d@drobilla.net>
+# Copyright 2011-2015 David Robillard <d@drobilla.net>
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
diff --git a/wscript b/wscript
index 1dcd69c..12a0a09 100644
--- a/wscript
+++ b/wscript
@@ -21,6 +21,13 @@ VERSION = LILV_VERSION # Package version for waf dist
top = '.' # Source directory
out = 'build' # Build directory
+test_plugins = ['missing_descriptor',
+ 'missing_plugin',
+ 'missing_name',
+ 'missing_port_name',
+ 'lib_descriptor',
+ 'failed_lib_descriptor']
+
def options(opt):
opt.load('compiler_c')
opt.load('compiler_cxx')
@@ -34,6 +41,8 @@ def options(opt):
help='Build support for dynamic manifests')
opt.add_option('--test', action='store_true', dest='build_tests',
help='Build unit tests')
+ opt.add_option('--no-coverage', action='store_true', dest='no_coverage',
+ help='Do not use gcov for code coverage')
opt.add_option('--no-bash-completion', action='store_true',
dest='no_bash_completion',
help='Do not install bash completion script in CONFIGDIR')
@@ -88,11 +97,8 @@ def configure(conf):
if conf.env.DEST_OS == 'darwin':
defines += ['_DARWIN_C_SOURCE']
- # Check for gcov library (for test coverage)
- if conf.env.BUILD_TESTS:
- conf.check_cc(lib='gcov',
- define_name='HAVE_GCOV',
- mandatory=False)
+ if conf.env.BUILD_TESTS and not Options.options.no_coverage:
+ conf.check_cc(lib='gcov', define_name='HAVE_GCOV', mandatory=False)
conf.check_cc(function_name='flock',
header_name='sys/file.h',
@@ -267,23 +273,39 @@ def build(bld):
penv.cshlib_PATTERN = shlib_pattern
shlib_ext = shlib_pattern[shlib_pattern.rfind('.'):]
- obj = bld(features = 'c cshlib',
- env = penv,
- source = 'test/test_plugin.c',
- name = 'test_plugin',
- target = 'test/test_plugin.lv2/test_plugin',
- install_path = None,
- defines = defines,
- cflags = test_cflags,
- lib = test_libs,
- uselib = 'LV2')
+ for p in ['test'] + test_plugins:
+ obj = bld(features = 'c cshlib',
+ env = penv,
+ source = 'test/%s.lv2/%s.c' % (p, p),
+ name = p,
+ target = 'test/%s.lv2/%s' % (p, p),
+ install_path = None,
+ defines = defines,
+ cflags = test_cflags,
+ lib = test_libs,
+ uselib = 'LV2')
+
+ for p in test_plugins:
+ obj = bld(features = 'c cprogram',
+ source = 'test/%s.lv2/test_%s.c' % (p, p),
+ target = 'test/test_%s' % p,
+ includes = ['.', './src'],
+ use = 'liblilv_profiled',
+ install_path = None,
+ defines = defines,
+ cflags = test_cflags,
+ lib = test_libs,
+ uselib = 'LV2')
+ autowaf.use_lib(bld, obj, 'SERD SORD SRATOM LV2')
# Test plugin data files
- for i in [ 'manifest.ttl.in', 'test_plugin.ttl.in' ]:
- bld(features = 'subst',
- source = 'test/' + i,
- target = 'test/test_plugin.lv2/' + i.replace('.in', ''),
- install_path = None,
+ for p in ['test'] + test_plugins:
+ for i in [ 'manifest.ttl.in', p + '.ttl.in' ]:
+ bundle = 'test/%s.lv2/' % p
+ bld(features = 'subst',
+ source = bundle + i,
+ target = bundle + i.replace('.in', ''),
+ install_path = None,
SHLIB_EXT = shlib_ext)
# Static profiled library (for unit test code coverage)
@@ -300,7 +322,7 @@ def build(bld):
# Unit test program
blddir = autowaf.build_dir(APPNAME, 'test')
- bpath = os.path.abspath(os.path.join(blddir, 'test_plugin.lv2'))
+ bpath = os.path.abspath(os.path.join(blddir, 'test.lv2'))
bpath = bpath.replace('\\', '/')
obj = bld(features = 'c cprogram',
source = 'test/lilv_test.c',
@@ -410,7 +432,13 @@ def test(ctx):
os.environ['LD_LIBRARY_PATH'] = os.getcwd()
autowaf.run_tests(ctx, 'Python ' + APPNAME, ['python -m unittest discover bindings/'])
os.environ['PATH'] = 'test' + os.pathsep + os.getenv('PATH')
- autowaf.run_tests(ctx, APPNAME, ['lilv_test'], dirs=['./src','./test'])
+ autowaf.run_test(ctx, APPNAME, 'lilv_test', dirs=['./src','./test'], name='lilv_test', header=True)
+
+ for p in test_plugins:
+ autowaf.run_test(ctx, APPNAME,
+ 'test_' + p + ' ' + ('test/%s.lv2/' % p),
+ 0, dirs=['./src','./test','./test/%s.lv2' % p], name=p, header=True)
+
autowaf.post_test(ctx, APPNAME)
try:
shutil.rmtree('state')