diff options
Diffstat (limited to 'test/missing_port.lv2')
-rw-r--r-- | test/missing_port.lv2/meson.build | 36 | ||||
-rw-r--r-- | test/missing_port.lv2/missing_port.c | 93 | ||||
-rw-r--r-- | test/missing_port.lv2/test_missing_port.c | 62 |
3 files changed, 105 insertions, 86 deletions
diff --git a/test/missing_port.lv2/meson.build b/test/missing_port.lv2/meson.build new file mode 100644 index 0000000..f6138d8 --- /dev/null +++ b/test/missing_port.lv2/meson.build @@ -0,0 +1,36 @@ +# Copyright 2021-2022 David Robillard <d@drobilla.net> +# SPDX-License-Identifier: 0BSD OR ISC + +module = shared_module( + 'missing_port', + files('missing_port.c'), + c_args: c_suppressions, + dependencies: lv2_dep, + gnu_symbol_visibility: 'hidden', + name_prefix: '', +) + +extension = '.' + module.full_path().split('.')[-1] +config = configuration_data({'SHLIB_EXT': extension}) +ttl_files = ['manifest.ttl', 'missing_port.ttl'] + +foreach f : ttl_files + configure_file( + input: files(f + '.in'), + output: f, + configuration: config, + ) +endforeach + +test( + 'missing_port', + executable( + 'test_missing_port', + files('test_missing_port.c'), + c_args: c_suppressions + test_args, + dependencies: [lv2_dep, lilv_static_dep], + ), + args: [meson.current_build_dir() / ''], + suite: 'plugin', +) + diff --git a/test/missing_port.lv2/missing_port.c b/test/missing_port.lv2/missing_port.c index 558eeb0..ce98c30 100644 --- a/test/missing_port.lv2/missing_port.c +++ b/test/missing_port.lv2/missing_port.c @@ -1,19 +1,5 @@ -/* - Lilv Test Plugin - Missing port - Copyright 2011-2019 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. -*/ +// Copyright 2011-2019 David Robillard <d@drobilla.net> +// SPDX-License-Identifier: ISC #include "lv2/core/lv2.h" @@ -22,36 +8,33 @@ #define PLUGIN_URI "http://example.org/missing-port" -enum { - TEST_INPUT = 0, - TEST_OUTPUT = 1 -}; +enum { TEST_INPUT = 0, TEST_OUTPUT = 1 }; typedef struct { - float* input; - float* output; + float* input; + float* output; } Test; static void cleanup(LV2_Handle instance) { - free((Test*)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; - } + 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 @@ -60,35 +43,43 @@ instantiate(const LV2_Descriptor* descriptor, const char* path, const LV2_Feature* const* features) { - Test* test = (Test*)calloc(1, sizeof(Test)); - if (!test) { - return NULL; - } + (void)descriptor; + (void)rate; + (void)path; + (void)features; - return (LV2_Handle)test; + 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; + (void)sample_count; + + Test* test = (Test*)instance; - *test->output = *test->input; + *test->output = *test->input; } static const LV2_Descriptor descriptor = { - PLUGIN_URI, - instantiate, - connect_port, - NULL, // activate, - run, - NULL, // deactivate, - cleanup, - NULL // extension_data + 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) +const LV2_Descriptor* +lv2_descriptor(uint32_t index) { - return (index == 0) ? &descriptor : NULL; + return (index == 0) ? &descriptor : NULL; } diff --git a/test/missing_port.lv2/test_missing_port.c b/test/missing_port.lv2/test_missing_port.c index 36b583e..463fd63 100644 --- a/test/missing_port.lv2/test_missing_port.c +++ b/test/missing_port.lv2/test_missing_port.c @@ -1,48 +1,40 @@ -#undef NDEBUG +// Copyright 2015-2020 David Robillard <d@drobilla.net> +// SPDX-License-Identifier: ISC -#include "../src/filesystem.h" +#undef NDEBUG -#include "serd/serd.h" #include "lilv/lilv.h" #include <assert.h> -#include <stdbool.h> -#include <stdint.h> #include <stdio.h> -#include <stdlib.h> #define PLUGIN_URI "http://example.org/missing-port" 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); - lilv_node_free(bundle_uri); - - 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); - - // Check that all ports are ignored - assert(lilv_plugin_get_num_ports(plugin) == 0); - - lilv_node_free(plugin_uri); - lilv_world_free(world); - - return 0; -} + 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 + LilvNode* bundle_uri = lilv_new_file_uri(world, NULL, bundle_path); + lilv_world_load_bundle(world, bundle_uri); + lilv_node_free(bundle_uri); + 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); + + // Check that all ports are ignored + assert(lilv_plugin_get_num_ports(plugin) == 0); + + lilv_node_free(plugin_uri); + lilv_world_free(world); + + return 0; +} |