Browse Source

Add a test for carla-host-plugin usage

tags/v2.3.0-RC1
falkTX 4 years ago
parent
commit
b81d3d955f
4 changed files with 138 additions and 5 deletions
  1. +13
    -4
      source/tests/Makefile
  2. +1
    -1
      source/tests/ansi-pedantic-test.c
  3. +110
    -0
      source/tests/carla-host-plugin.c
  4. +14
    -0
      source/tests/valgrind.supp

+ 13
- 4
source/tests/Makefile View File

@@ -74,7 +74,8 @@ TARGETS = \
ansi-pedantic-test_cxx_ansi_run \
ansi-pedantic-test_cxx98_run \
ansi-pedantic-test_cxx03_run \
ansi-pedantic-test_cxx11_run
ansi-pedantic-test_cxx11_run \
carla-host-plugin_run

# ---------------------------------------------------------------------------------------------------------------------

@@ -82,8 +83,11 @@ all: $(TARGETS)

# ---------------------------------------------------------------------------------------------------------------------

%_run: $(BINDIR)/%
$(BINDIR)/$*
ansi-%_run: $(BINDIR)/ansi-%
$(BINDIR)/ansi-$*

carla-%_run: $(BINDIR)/carla-%
valgrind --leak-check=full --show-leak-kinds=all --suppressions=valgrind.supp $(BINDIR)/carla-$*

# ---------------------------------------------------------------------------------------------------------------------

@@ -115,8 +119,13 @@ $(BINDIR)/ansi-pedantic-test_cxx11: ansi-pedantic-test.cpp ../backend/Carla*.h .

# ---------------------------------------------------------------------------------------------------------------------

$(BINDIR)/carla-host-plugin: carla-host-plugin.c
$(CC) $< $(PEDANTIC_CFLAGS) $(PEDANTIC_LDFLAGS) -Wno-declaration-after-statement -Wno-pedantic -lcarla_host-plugin -ansi -o $@

# ---------------------------------------------------------------------------------------------------------------------

clean:
rm -f $(BINDIR)/ansi-pedantic-test_*
rm -f $(BINDIR)/ansi-pedantic-test_* $(BINDIR)/carla-host-plugin

debug:
$(MAKE) DEBUG=true


+ 1
- 1
source/tests/ansi-pedantic-test.c View File

@@ -1,6 +1,6 @@
/*
* ANSI pedantic test for the Carla Backend & Host API
* Copyright (C) 2013-2019 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2013-2020 Filipe Coelho <falktx@falktx.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as


+ 110
- 0
source/tests/carla-host-plugin.c View File

@@ -0,0 +1,110 @@
/*
* Carla Host Plugin test
* Copyright (C) 2020 Filipe Coelho <falktx@falktx.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* For a full copy of the GNU General Public License see the doc/GPL.txt file.
*/

#include "CarlaNativePlugin.h"

#include <assert.h>

static uint32_t get_buffer_size(NativeHostHandle h)
{
return 128;

/* unused */
(void)h;
}

static double get_sample_rate(NativeHostHandle h)
{
return 44100.0;

/* unused */
(void)h;
}

static bool is_offline(NativeHostHandle h)
{
return false;

/* unused */
(void)h;
}

static intptr_t dispatcher(NativeHostHandle h, NativeHostDispatcherOpcode c, int32_t i, intptr_t v, void* p, float o)
{
return 0;

/* unused */
(void)h;
(void)c;
(void)i;
(void)v;
(void)p;
(void)o;
}

static const NativeHostDescriptor host_descriptor = {
.resourceDir = "",
.uiName = "",
.get_buffer_size = get_buffer_size,
.get_sample_rate = get_sample_rate,
.is_offline = is_offline,
.dispatcher = dispatcher
};

int main(void)
{
const char* const standalone_filename = carla_standalone_get_library_filename();
assert(standalone_filename != NULL && standalone_filename[0] != '\0');

const char* const utils_filename = carla_utils_get_library_filename();
assert(utils_filename != NULL && utils_filename[0] != '\0');

const char* const standalone_folder = carla_standalone_get_library_folder();
assert(standalone_folder != NULL && standalone_folder[0] != '\0');

const char* const utils_folder = carla_utils_get_library_folder();
assert(utils_folder != NULL && utils_folder[0] != '\0');
/*
carla_juce_init();*/

const NativePluginDescriptor* const rack = carla_get_native_rack_plugin();
assert(rack != NULL);

const NativePluginDescriptor* const patchbay = carla_get_native_patchbay_plugin();
assert(patchbay != NULL);

const NativePluginHandle rack_handle = rack->instantiate(&host_descriptor);
assert(rack_handle != NULL);

const NativePluginHandle patchbay_handle = patchbay->instantiate(&host_descriptor);
assert(patchbay_handle != NULL);

const CarlaHostHandle rack_host_handle = carla_create_native_plugin_host_handle(rack, rack_handle);
assert(rack_host_handle);

const CarlaHostHandle patchbay_host_handle = carla_create_native_plugin_host_handle(patchbay, patchbay_handle);
assert(patchbay_host_handle);

rack->cleanup(patchbay_handle);
rack->cleanup(rack_handle);

carla_host_handle_free(patchbay_host_handle);
carla_host_handle_free(rack_host_handle);
/*
carla_juce_cleanup();*/
return 0;
}

+ 14
- 0
source/tests/valgrind.supp View File

@@ -0,0 +1,14 @@
{
libdl init part 1
Memcheck:Leak
fun:calloc
...
fun:_dl_init
}
{
libdl init part 2
Memcheck:Leak
fun:malloc
...
fun:_dl_init
}

Loading…
Cancel
Save