summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-07-15 10:46:04 +0200
committerDavid Robillard <d@drobilla.net>2020-07-16 11:24:59 +0200
commitd7ab0b3eab59f6068d697399da50734e57c5ca83 (patch)
tree81f8593a540d271eb9b9615515bd37e085716165
parentdd15498078a58c2fe9f71e1ceef1eb326c82d9e6 (diff)
downloadlilv-d7ab0b3eab59f6068d697399da50734e57c5ca83.tar.gz
lilv-d7ab0b3eab59f6068d697399da50734e57c5ca83.tar.bz2
lilv-d7ab0b3eab59f6068d697399da50734e57c5ca83.zip
Automatically write prefixes to test files
Makes the code less repetitive and verbose. They were all the same at this point anyway, since unused prefixes don't hurt anything.
-rw-r--r--test/lilv_test.c53
-rw-r--r--test/lilv_test_utils.c17
2 files changed, 28 insertions, 42 deletions
diff --git a/test/lilv_test.c b/test/lilv_test.c
index 66f7ce0..92e98be 100644
--- a/test/lilv_test.c
+++ b/test/lilv_test.c
@@ -78,9 +78,8 @@ test_value(LilvTestEnv* env)
{
LilvWorld* const world = env->world;
- if (start_bundle(env, MANIFEST_PREFIXES
+ if (start_bundle(env,
":plug a lv2:Plugin ; lv2:binary <foo" SHLIB_EXT "> ; rdfs:seeAlso <plugin.ttl> .\n",
- PLUGIN_PREFIXES
":plug a lv2:Plugin ; a lv2:CompressorPlugin ; "
"doap:name \"Test plugin\" ;"
"lv2:port [ "
@@ -273,9 +272,8 @@ test_discovery(LilvTestEnv* env)
{
LilvWorld* const world = env->world;
- if (start_bundle(env, MANIFEST_PREFIXES
+ if (start_bundle(env,
":plug a lv2:Plugin ; lv2:binary <foo" SHLIB_EXT "> ; rdfs:seeAlso <plugin.ttl> .\n",
- PLUGIN_PREFIXES
":plug a lv2:Plugin ;"
"doap:name \"Test plugin\" ;"
"lv2:port [ a lv2:ControlPort ; a lv2:InputPort ;"
@@ -314,9 +312,8 @@ test_verify(LilvTestEnv* env)
{
LilvWorld* const world = env->world;
- if (start_bundle(env, MANIFEST_PREFIXES
+ if (start_bundle(env,
":plug a lv2:Plugin ; lv2:binary <foo" SHLIB_EXT "> ; rdfs:seeAlso <plugin.ttl> .\n",
- PLUGIN_PREFIXES
":plug a lv2:Plugin ; "
"doap:name \"Test plugin\" ;"
"lv2:port [ a lv2:ControlPort ; a lv2:InputPort ;"
@@ -340,9 +337,8 @@ test_no_verify(LilvTestEnv* env)
{
LilvWorld* const world = env->world;
- if (start_bundle(env, MANIFEST_PREFIXES
+ if (start_bundle(env,
":plug a lv2:Plugin ; lv2:binary <foo" SHLIB_EXT "> ; rdfs:seeAlso <plugin.ttl> .\n",
- PLUGIN_PREFIXES
":plug a lv2:Plugin . ")) {
return 1;
}
@@ -363,9 +359,8 @@ test_classes(LilvTestEnv* env)
{
LilvWorld* const world = env->world;
- if (start_bundle(env, MANIFEST_PREFIXES
+ if (start_bundle(env,
":plug a lv2:Plugin ; lv2:binary <foo" SHLIB_EXT "> ; rdfs:seeAlso <plugin.ttl> .\n",
- PLUGIN_PREFIXES
":plug a lv2:Plugin ; a lv2:CompressorPlugin ; "
"doap:name \"Test plugin\" ;"
"lv2:port [ "
@@ -410,9 +405,8 @@ test_plugin(LilvTestEnv* env)
{
LilvWorld* const world = env->world;
- if (start_bundle(env, MANIFEST_PREFIXES
+ if (start_bundle(env,
":plug a lv2:Plugin ; lv2:binary <foo" SHLIB_EXT "> ; rdfs:seeAlso <plugin.ttl> .\n",
- PLUGIN_PREFIXES
":plug a lv2:Plugin ; a lv2:CompressorPlugin ; "
"doap:name \"Test plugin\" ;"
"lv2:optionalFeature lv2:hardRTCapable ; "
@@ -649,9 +643,8 @@ test_project(LilvTestEnv* env)
{
LilvWorld* const world = env->world;
- if (start_bundle(env, MANIFEST_PREFIXES
+ if (start_bundle(env,
":plug a lv2:Plugin ; lv2:binary <foo" SHLIB_EXT "> ; rdfs:seeAlso <plugin.ttl> .\n",
- PLUGIN_PREFIXES
":plug a lv2:Plugin ; a lv2:CompressorPlugin ; "
"doap:name \"Test plugin with project\" ;"
"lv2:project [ "
@@ -704,9 +697,8 @@ test_no_author(LilvTestEnv* env)
{
LilvWorld* const world = env->world;
- if (start_bundle(env, MANIFEST_PREFIXES
+ if (start_bundle(env,
":plug a lv2:Plugin ; lv2:binary <foo" SHLIB_EXT "> ; rdfs:seeAlso <plugin.ttl> .\n",
- PLUGIN_PREFIXES
":plug a lv2:Plugin ; a lv2:CompressorPlugin ; "
"doap:name \"Test plugin with project\" ;"
"lv2:port [ "
@@ -752,9 +744,8 @@ test_project_no_author(LilvTestEnv* env)
{
LilvWorld* const world = env->world;
- if (start_bundle(env, MANIFEST_PREFIXES
+ if (start_bundle(env,
":plug a lv2:Plugin ; lv2:binary <foo" SHLIB_EXT "> ; rdfs:seeAlso <plugin.ttl> .\n",
- PLUGIN_PREFIXES
":plug a lv2:Plugin ; a lv2:CompressorPlugin ; "
"doap:name \"Test plugin with project\" ;"
"lv2:project [ "
@@ -802,9 +793,8 @@ test_preset(LilvTestEnv* env)
{
LilvWorld* const world = env->world;
- if (start_bundle(env, MANIFEST_PREFIXES
+ if (start_bundle(env,
":plug a lv2:Plugin ; lv2:binary <foo" SHLIB_EXT "> ; rdfs:seeAlso <plugin.ttl> .\n",
- PLUGIN_PREFIXES
":plug a lv2:Plugin ; a lv2:CompressorPlugin ; "
"doap:name \"Test plugin with project\" ;"
"lv2:project [ "
@@ -853,10 +843,9 @@ test_prototype(LilvTestEnv* env)
{
LilvWorld* const world = env->world;
- if (start_bundle(env, MANIFEST_PREFIXES
+ if (start_bundle(env,
":prot a lv2:PluginBase ; rdfs:seeAlso <plugin.ttl> .\n"
":plug a lv2:Plugin ; lv2:binary <inst" SHLIB_EXT "> ; lv2:prototype :prot .\n",
- PLUGIN_PREFIXES
":prot a lv2:Plugin ; a lv2:CompressorPlugin ; "
"lv2:project [ "
" doap:name \"Fake project\" ;"
@@ -903,9 +892,8 @@ test_port(LilvTestEnv* env)
{
LilvWorld* const world = env->world;
- if (start_bundle(env, MANIFEST_PREFIXES
+ if (start_bundle(env,
":plug a lv2:Plugin ; lv2:binary <foo" SHLIB_EXT "> ; rdfs:seeAlso <plugin.ttl> .\n",
- PLUGIN_PREFIXES
"@prefix lv2ev: <http://lv2plug.in/ns/ext/event#> . \n"
":plug a lv2:Plugin ; "
"doap:name \"Test plugin\" ;"
@@ -1190,9 +1178,8 @@ test_ui(LilvTestEnv* env)
{
LilvWorld* const world = env->world;
- if (start_bundle(env, MANIFEST_PREFIXES
+ if (start_bundle(env,
":plug a lv2:Plugin ; lv2:binary <foo" SHLIB_EXT "> ; rdfs:seeAlso <plugin.ttl> .\n",
- PLUGIN_PREFIXES
"@prefix lv2ui: <http://lv2plug.in/ns/extensions/ui#> .\n"
":plug a lv2:Plugin ; a lv2:CompressorPlugin ; "
"doap:name \"Test plugin\" ;"
@@ -1768,9 +1755,8 @@ test_bad_port_symbol(LilvTestEnv* env)
{
LilvWorld* const world = env->world;
- if (start_bundle(env, MANIFEST_PREFIXES
+ if (start_bundle(env,
":plug a lv2:Plugin ; lv2:binary <foo" SHLIB_EXT "> ; rdfs:seeAlso <plugin.ttl> .\n",
- PLUGIN_PREFIXES
":plug a lv2:Plugin ; "
"doap:name \"Test plugin\" ;"
"doap:homepage <http://example.org/someplug> ; "
@@ -1799,9 +1785,8 @@ test_bad_port_index(LilvTestEnv* env)
{
LilvWorld* const world = env->world;
- if (start_bundle(env, MANIFEST_PREFIXES
+ if (start_bundle(env,
":plug a lv2:Plugin ; lv2:binary <foo" SHLIB_EXT "> ; rdfs:seeAlso <plugin.ttl> .\n",
- PLUGIN_PREFIXES
":plug a lv2:Plugin ; "
"doap:name \"Test plugin\" ;"
"doap:homepage <http://example.org/someplug> ; "
@@ -1899,9 +1884,8 @@ test_reload_bundle(LilvTestEnv* env)
LilvWorld* const world = env->world;
// Create a simple plugin bundle
- create_bundle(env, MANIFEST_PREFIXES
+ create_bundle(env,
":plug a lv2:Plugin ; lv2:binary <foo" SHLIB_EXT "> ; rdfs:seeAlso <plugin.ttl> .\n",
- PLUGIN_PREFIXES
":plug a lv2:Plugin ; "
"doap:name \"First name\" .");
@@ -1926,9 +1910,8 @@ test_reload_bundle(LilvTestEnv* env)
delete_bundle(env);
// Create a new version of the same bundle, but with a different name
- create_bundle(env, MANIFEST_PREFIXES
+ create_bundle(env,
":plug a lv2:Plugin ; lv2:binary <foo" SHLIB_EXT "> ; rdfs:seeAlso <plugin.ttl> .\n",
- PLUGIN_PREFIXES
":plug a lv2:Plugin ; "
"doap:name \"Second name\" .");
@@ -2041,9 +2024,7 @@ test_get_symbol(LilvTestEnv* env)
LilvWorld* const world = env->world;
if (start_bundle(env,
- MANIFEST_PREFIXES
":plug a lv2:Plugin ; lv2:symbol \"plugsym\" ; lv2:binary <foo" SHLIB_EXT "> ; rdfs:seeAlso <plugin.ttl> .\n",
- PLUGIN_PREFIXES
":plug a lv2:Plugin ; "
"doap:name \"Test plugin\" ;"
"lv2:symbol \"plugsym\" .")) {
diff --git a/test/lilv_test_utils.c b/test/lilv_test_utils.c
index 6137c27..5d692ea 100644
--- a/test/lilv_test_utils.c
+++ b/test/lilv_test_utils.c
@@ -118,17 +118,22 @@ create_bundle(LilvTestEnv* env, const char* manifest, const char* plugin)
return 3;
}
- const size_t manifest_len = strlen(manifest);
- const size_t plugin_len = strlen(plugin);
- size_t n_written = 0;
-
+ const size_t manifest_head_len = strlen(MANIFEST_PREFIXES);
+ const size_t manifest_len = strlen(manifest);
+ const size_t plugin_head_len = strlen(PLUGIN_PREFIXES);
+ const size_t plugin_len = strlen(plugin);
+ const size_t n_total =
+ manifest_len + plugin_len + manifest_head_len + plugin_head_len;
+
+ size_t n_written = 0;
+ n_written += fwrite(MANIFEST_PREFIXES, 1, manifest_head_len, manifest_file);
n_written += fwrite(manifest, 1, manifest_len, manifest_file);
+ n_written += fwrite(PLUGIN_PREFIXES, 1, plugin_head_len, plugin_file);
n_written += fwrite(plugin, 1, plugin_len, plugin_file);
fclose(manifest_file);
fclose(plugin_file);
-
- return n_written == manifest_len + plugin_len ? 0 : 4;
+ return n_written == n_total ? 0 : 4;
}
int