@@ -29,6 +29,7 @@ | |||||
*.vst3 | *.vst3 | ||||
# Binary dir | # Binary dir | ||||
bin/ansi-pedantic-test_* | |||||
bin/carla | bin/carla | ||||
bin/carla.lv2/carla-bridge-* | bin/carla.lv2/carla-bridge-* | ||||
bin/carla-database | bin/carla-database | ||||
@@ -371,6 +371,7 @@ clean: | |||||
$(MAKE) clean -C source/modules | $(MAKE) clean -C source/modules | ||||
$(MAKE) clean -C source/native-plugins | $(MAKE) clean -C source/native-plugins | ||||
$(MAKE) clean -C source/plugin | $(MAKE) clean -C source/plugin | ||||
$(MAKE) clean -C source/tests | |||||
$(MAKE) clean -C source/theme | $(MAKE) clean -C source/theme | ||||
rm -f *~ source/*~ | rm -f *~ source/*~ | ||||
@@ -387,6 +388,9 @@ debug: | |||||
doxygen: | doxygen: | ||||
$(MAKE) doxygen -C source/backend | $(MAKE) doxygen -C source/backend | ||||
tests: | |||||
$(MAKE) -C source/tests | |||||
stoat: | stoat: | ||||
stoat --recursive ./build/ --suppression ./data/stoat-supression.txt --whitelist ./data/stoat-whitelist.txt --graph-view ./data/stoat-callgraph.png | stoat --recursive ./build/ --suppression ./data/stoat-supression.txt --whitelist ./data/stoat-whitelist.txt --graph-view ./data/stoat-callgraph.png | ||||
@@ -0,0 +1,129 @@ | |||||
#!/usr/bin/make -f | |||||
# Makefile for tests # | |||||
# ------------------ # | |||||
# Created by falkTX | |||||
# | |||||
CWD=.. | |||||
include $(CWD)/Makefile.mk | |||||
# --------------------------------------------------------------------------------------------------------------------- | |||||
BINDIR := $(CWD)/../bin | |||||
ifeq ($(DEBUG),true) | |||||
OBJDIR := $(CWD)/../build/tests/Debug | |||||
MODULEDIR := $(CWD)/../build/modules/Debug | |||||
else | |||||
OBJDIR := $(CWD)/../build/tests/Release | |||||
MODULEDIR := $(CWD)/../build/modules/Release | |||||
endif | |||||
# --------------------------------------------------------------------------------------------------------------------- | |||||
BUILD_C_FLAGS += -I.. | |||||
BUILD_CXX_FLAGS += -I.. -I$(CWD)/modules | |||||
# --------------------------------------------------------------------------------------------------------------------- | |||||
PEDANTIC_FLAGS = -pedantic -pedantic-errors | |||||
PEDANTIC_FLAGS += -Wall -Wextra -Werror -pipe -DBUILDING_CARLA -DREAL_BUILD | |||||
PEDANTIC_FLAGS += -I. -I../backend -I../includes -I../modules -I../utils | |||||
PEDANTIC_FLAGS += -Wabi=98 -Wcast-qual -Wclobbered -Wconversion -Wdisabled-optimization | |||||
PEDANTIC_FLAGS += -Wcast-align -Wcast-qual -Wclobbered -Wconversion -Wdisabled-optimization | |||||
PEDANTIC_FLAGS += -Wdouble-promotion -Wfloat-equal -Wlogical-op -Wpointer-arith -Wsign-conversion | |||||
PEDANTIC_FLAGS += -Wformat=2 -Woverlength-strings | |||||
PEDANTIC_FLAGS += -Wformat-truncation=2 -Wformat-overflow=2 | |||||
PEDANTIC_FLAGS += -Wstringop-overflow=4 -Wstringop-truncation | |||||
PEDANTIC_FLAGS += -Wmissing-declarations -Wredundant-decls | |||||
PEDANTIC_FLAGS += -Wshadow -Wundef -Wuninitialized -Wunused | |||||
PEDANTIC_FLAGS += -Wstrict-aliasing -fstrict-aliasing | |||||
PEDANTIC_FLAGS += -Wstrict-overflow -fstrict-overflow | |||||
PEDANTIC_FLAGS += -Wduplicated-branches -Wduplicated-cond -Wnull-dereference | |||||
PEDANTIC_CFLAGS = $(PEDANTIC_FLAGS) | |||||
PEDANTIC_CFLAGS += -Wc++-compat | |||||
PEDANTIC_CFLAGS += -Winit-self -Wjump-misses-init -Wnested-externs -Wwrite-strings | |||||
PEDANTIC_CFLAGS += -Wmissing-prototypes -Wstrict-prototypes | |||||
PEDANTIC_CXXFLAGS = $(PEDANTIC_FLAGS) | |||||
PEDANTIC_CXXFLAGS += -Wc++0x-compat -Wc++11-compat | |||||
PEDANTIC_CXXFLAGS += -Wnon-virtual-dtor -Woverloaded-virtual | |||||
PEDANTIC_CXXFLAGS += -Wold-style-cast -Wuseless-cast | |||||
PEDANTIC_CXXFLAGS += -Wzero-as-null-pointer-constant | |||||
PEDANTIC_CXXFLAGS += -Weffc++ | |||||
PEDANTIC_LDFLAGS = -Wl,-rpath,$(BINDIR) -L$(BINDIR) | |||||
# --------------------------------------------------------------------------------------------------------------------- | |||||
# Set targets | |||||
TARGETS = \ | |||||
ansi-pedantic-test_c_ansi_run \ | |||||
ansi-pedantic-test_c89_run \ | |||||
ansi-pedantic-test_c99_run \ | |||||
ansi-pedantic-test_c11_run \ | |||||
ansi-pedantic-test_cxx_ansi_run \ | |||||
ansi-pedantic-test_cxx98_run \ | |||||
ansi-pedantic-test_cxx03_run \ | |||||
ansi-pedantic-test_cxx11_run | |||||
# --------------------------------------------------------------------------------------------------------------------- | |||||
all: $(TARGETS) | |||||
# --------------------------------------------------------------------------------------------------------------------- | |||||
%_run: $(BINDIR)/% | |||||
$(BINDIR)/$* | |||||
# --------------------------------------------------------------------------------------------------------------------- | |||||
$(BINDIR)/ansi-pedantic-test_c_ansi: ansi-pedantic-test.c ../backend/Carla*.h ../includes/*.h | |||||
$(CC) $< $(PEDANTIC_CFLAGS) $(PEDANTIC_LDFLAGS) -lcarla_standalone2 -lcarla_utils -ansi -o $@ | |||||
$(BINDIR)/ansi-pedantic-test_c89: ansi-pedantic-test.c ../backend/Carla*.h ../includes/*.h | |||||
$(CC) $< $(PEDANTIC_CFLAGS) $(PEDANTIC_LDFLAGS) -lcarla_standalone2 -lcarla_utils -std=c89 -o $@ | |||||
$(BINDIR)/ansi-pedantic-test_c99: ansi-pedantic-test.c ../backend/Carla*.h ../includes/*.h | |||||
$(CC) $< $(PEDANTIC_CFLAGS) $(PEDANTIC_LDFLAGS) -lcarla_standalone2 -lcarla_utils -std=c99 -o $@ | |||||
$(BINDIR)/ansi-pedantic-test_c11: ansi-pedantic-test.c ../backend/Carla*.h ../includes/*.h | |||||
$(CC) $< $(PEDANTIC_CFLAGS) $(PEDANTIC_LDFLAGS) -lcarla_standalone2 -lcarla_utils -std=c11 -o $@ | |||||
# --------------------------------------------------------------------------------------------------------------------- | |||||
$(BINDIR)/ansi-pedantic-test_cxx_ansi: ansi-pedantic-test.cpp ../backend/Carla*.h ../backend/Carla*.hpp ../includes/*.h | |||||
$(CXX) $< $(PEDANTIC_CXXFLAGS) $(PEDANTIC_LDFLAGS) -lcarla_standalone2 -lcarla_utils -ansi -Wno-effc++ -o $@ | |||||
$(BINDIR)/ansi-pedantic-test_cxx98: ansi-pedantic-test.cpp ../backend/Carla*.h ../backend/Carla*.hpp ../includes/*.h | |||||
$(CXX) $< $(PEDANTIC_CXXFLAGS) $(PEDANTIC_LDFLAGS) -lcarla_standalone2 -lcarla_utils -std=c++98 -Wno-effc++ -o $@ | |||||
$(BINDIR)/ansi-pedantic-test_cxx03: ansi-pedantic-test.cpp ../backend/Carla*.h ../backend/Carla*.hpp ../includes/*.h | |||||
$(CXX) $< $(PEDANTIC_CXXFLAGS) $(PEDANTIC_LDFLAGS) -lcarla_standalone2 -lcarla_utils -std=c++03 -Wno-effc++ -o $@ | |||||
$(BINDIR)/ansi-pedantic-test_cxx11: ansi-pedantic-test.cpp ../backend/Carla*.h ../backend/Carla*.hpp ../includes/*.h | |||||
$(CXX) $< $(PEDANTIC_CXXFLAGS) $(PEDANTIC_LDFLAGS) -lcarla_standalone2 -lcarla_utils -std=c++11 -o $@ | |||||
# --------------------------------------------------------------------------------------------------------------------- | |||||
clean: | |||||
rm -f $(BINDIR)/ansi-pedantic-test_* | |||||
debug: | |||||
$(MAKE) DEBUG=true | |||||
# --------------------------------------------------------------------------------------------------------------------- | |||||
$(OBJDIR)/%.c.o: %.c | |||||
-@mkdir -p $(OBJDIR) | |||||
@echo "Compiling $<" | |||||
@$(CC) $< $(BUILD_C_FLAGS) -c -o $@ | |||||
$(OBJDIR)/%.cpp.o: %.cpp | |||||
-@mkdir -p $(OBJDIR) | |||||
@echo "Compiling $<" | |||||
@$(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@ | |||||
# --------------------------------------------------------------------------------------------------------------------- |
@@ -0,0 +1,184 @@ | |||||
/* | |||||
* ANSI pedantic test for the Carla Backend & Host API | |||||
* Copyright (C) 2013-2019 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 "CarlaBackend.h" | |||||
#include "CarlaHost.h" | |||||
#include "CarlaUtils.h" | |||||
#include "CarlaMIDI.h" | |||||
#include "CarlaNative.h" | |||||
#include "CarlaNativePlugin.h" | |||||
#ifdef __cplusplus | |||||
# include "CarlaEngine.hpp" | |||||
# include "CarlaPlugin.hpp" | |||||
# include <cassert> | |||||
# include <cstdio> | |||||
# ifdef CARLA_PROPER_CPP11_SUPPORT | |||||
# undef NULL | |||||
# define NULL nullptr | |||||
# endif | |||||
#else | |||||
# include <assert.h> | |||||
# include <stdio.h> | |||||
#endif | |||||
#define BOOLEAN_AS_STRING(cond) ((cond) ? "true" : "false") | |||||
int main(int argc, char* argv[]) | |||||
{ | |||||
#ifdef __cplusplus | |||||
CARLA_BACKEND_USE_NAMESPACE | |||||
#endif | |||||
ParameterData a; | |||||
ParameterRanges b; | |||||
MidiProgramData c; | |||||
CustomData d; | |||||
EngineDriverDeviceInfo e; | |||||
CarlaPluginInfo f; | |||||
/*CarlaCachedPluginInfo g;*/ | |||||
CarlaPortCountInfo h; | |||||
CarlaParameterInfo i; | |||||
CarlaScalePointInfo j; | |||||
CarlaTransportInfo k; | |||||
const char* licenseText; | |||||
const char* const* fileExtensions; | |||||
uint l, count; | |||||
licenseText = carla_get_complete_license_text(); | |||||
printf("LICENSE:\n%s\n", licenseText); | |||||
fileExtensions = carla_get_supported_file_extensions(); | |||||
printf("FILE EXTENSIONS:\n "); | |||||
for (l=0; fileExtensions[l] != NULL; ++l) | |||||
printf(" %s", fileExtensions[l]); | |||||
printf("\n"); | |||||
count = carla_get_engine_driver_count(); | |||||
printf("DRIVER COUNT: %i\n", count); | |||||
for (l=0; l < count; ++l) | |||||
{ | |||||
const char* driverName; | |||||
const char* const* driverDeviceNames; | |||||
const EngineDriverDeviceInfo* driverDeviceInfo; | |||||
uint m, m2, count2; | |||||
driverName = carla_get_engine_driver_name(l); | |||||
driverDeviceNames = carla_get_engine_driver_device_names(l); | |||||
printf("DRIVER %i/%i: \"%s\" : DEVICES:\n", l+1, count, driverName); | |||||
count2 = 0; | |||||
while (driverDeviceNames[count2] != NULL) | |||||
++count2; | |||||
for (m = 0; m < count2; ++m) | |||||
{ | |||||
driverDeviceInfo = carla_get_engine_driver_device_info(l, driverDeviceNames[m]); | |||||
printf("DRIVER DEVICE %i/%i: \"%s\"\n", m+1, count2, driverDeviceNames[m]); | |||||
printf(" Has control panel: %s\n", BOOLEAN_AS_STRING(driverDeviceInfo->hints & ENGINE_DRIVER_DEVICE_HAS_CONTROL_PANEL)); | |||||
printf(" Can triple buffer: %s\n", BOOLEAN_AS_STRING(driverDeviceInfo->hints & ENGINE_DRIVER_DEVICE_CAN_TRIPLE_BUFFER)); | |||||
printf(" Variable buffer size: %s\n", BOOLEAN_AS_STRING(driverDeviceInfo->hints & ENGINE_DRIVER_DEVICE_VARIABLE_BUFFER_SIZE)); | |||||
printf(" Variable sample rate: %s\n", BOOLEAN_AS_STRING(driverDeviceInfo->hints & ENGINE_DRIVER_DEVICE_VARIABLE_SAMPLE_RATE)); | |||||
if (driverDeviceInfo->bufferSizes != NULL && driverDeviceInfo->bufferSizes[0] != 0) | |||||
{ | |||||
printf(" Buffer sizes:"); | |||||
m2 = 0; | |||||
while (driverDeviceInfo->bufferSizes[m2] != 0) | |||||
printf(" %i", driverDeviceInfo->bufferSizes[m2++]); | |||||
printf("\n"); | |||||
} | |||||
else | |||||
{ | |||||
printf(" Buffer sizes: (null)\n"); | |||||
} | |||||
if (driverDeviceInfo->sampleRates != NULL && driverDeviceInfo->sampleRates[0] > 0.1) | |||||
{ | |||||
printf(" Sample rates:"); | |||||
m2 = 0; | |||||
while (driverDeviceInfo->sampleRates[m2] > 0.1) | |||||
printf(" %.1f", driverDeviceInfo->sampleRates[m2++]); | |||||
printf("\n"); | |||||
} | |||||
else | |||||
{ | |||||
printf(" Sample rates: (null)\n"); | |||||
} | |||||
} | |||||
} | |||||
carla_set_engine_option(ENGINE_OPTION_PROCESS_MODE, ENGINE_PROCESS_MODE_PATCHBAY, NULL); | |||||
carla_set_engine_option(ENGINE_OPTION_TRANSPORT_MODE, ENGINE_TRANSPORT_MODE_INTERNAL, NULL); | |||||
if (carla_engine_init("Dummy", "ansi-test")) | |||||
{ | |||||
#ifdef __cplusplus | |||||
CarlaEngine* const engine(carla_get_engine()); | |||||
assert(engine != nullptr); | |||||
engine->getLastError(); | |||||
#endif | |||||
if (carla_add_plugin(BINARY_NATIVE, PLUGIN_INTERNAL, NULL, NULL, "audiofile", 0, NULL, 0x0)) | |||||
{ | |||||
#ifdef __cplusplus | |||||
CarlaPlugin* const plugin(engine->getPlugin(0)); | |||||
assert(plugin != nullptr); | |||||
plugin->getId(); | |||||
#endif | |||||
/* carla_set_custom_data(0, CUSTOM_DATA_TYPE_STRING, "file", "/home/falktx/Music/test.wav"); */ | |||||
carla_transport_play(); | |||||
} | |||||
else | |||||
{ | |||||
printf("%s\n", carla_get_last_error()); | |||||
} | |||||
#ifdef __cplusplus | |||||
engine->setAboutToClose(); | |||||
#endif | |||||
carla_engine_close(); | |||||
} | |||||
#ifdef __cplusplus | |||||
EngineControlEvent e1; | |||||
EngineMidiEvent e2; | |||||
EngineEvent e3; | |||||
e3.fillFromMidiData(0, nullptr, 0); | |||||
EngineOptions e4; | |||||
EngineTimeInfoBBT e5; | |||||
EngineTimeInfo e6; | |||||
#endif | |||||
/* unused C */ | |||||
(void)argc; | |||||
(void)argv; | |||||
(void)a; (void)b; (void)c; (void)d; (void)e; | |||||
(void)f; /*(void)g;*/ (void)h; (void)i; (void)j; (void)k; | |||||
#ifdef __cplusplus | |||||
(void)e1; (void)e2; (void)e4; (void)e5; (void)e6; | |||||
#endif | |||||
return 0; | |||||
} |
@@ -0,0 +1 @@ | |||||
ansi-pedantic-test.c |