make VintageDreams sf2 an explicit requirement for unit tests

This commit is contained in:
derselbst 2018-04-11 11:03:12 +02:00
parent 713a4b680d
commit cb35fac1c6
6 changed files with 17 additions and 23 deletions

View File

@ -55,7 +55,7 @@ option ( enable-fpe-check "enable Floating Point Exception checks and debug mess
option ( enable-portaudio "compile PortAudio support" off )
option ( enable-profiling "profile the dsp code" off )
option ( enable-trap-on-fpe "enable SIGFPE trap on Floating Point Exceptions" off )
option ( enable-tests "build unit tests (implicitly disables BUILD_SHARED_LIBS and overrides DEFAULT_SOUNDFONT)" off )
option ( enable-tests "build unit tests (implicitly disables BUILD_SHARED_LIBS)" off )
# Options enabled by default
option ( enable-aufile "compile support for sound file output" on )
@ -503,7 +503,7 @@ endif ( enable-readline )
if(enable-tests)
# manipulate some variables to setup a proper test env
set(DEFAULT_SOUNDFONT "${CMAKE_SOURCE_DIR}/sf2/VintageDreamsWaves-v2.sf2")
set(TEST_SOUNDFONT "${CMAKE_SOURCE_DIR}/sf2/VintageDreamsWaves-v2.sf2")
# force to build a static lib, in order to bypass the visibility control, allowing us
# to test fluidsynths private/internal functions

View File

@ -190,6 +190,9 @@
/* Define to 1 if you have the ANSI C header files. */
#cmakedefine STDC_HEADERS @STDC_HEADERS@
/* Soundfont to load for unit testing */
#cmakedefine TEST_SOUNDFONT "@TEST_SOUNDFONT@"
/* Define to enable SIGFPE assertions */
#cmakedefine TRAP_ON_FPE @TRAP_ON_FPE@

View File

@ -16,4 +16,6 @@ To add a unit test just duplicate an existing one, give it a unique name and upd
* adding a call to `ADD_FLUID_TEST()` and
* a dependency to the custom `check` target.
Make sure you call cmake with `-Denable-tests=1` to build and execute the tests via `make check`.
Make sure you call cmake with `-Denable-tests=1` to build and execute the tests via `make check`. Unit
tests should use the `VintageDreamsWaves-v2.sf2` as test soundfont. Use the `TEST_SOUNDFONT` macro to
access it.

View File

@ -14,8 +14,9 @@ int main(void)
/* setup */
fluid_settings_t *settings = new_fluid_settings();
fluid_synth_t *synth = new_fluid_synth(settings);
/* Load the VintageDreams soundfont */
id = fluid_synth_sfload(synth, DEFAULT_SOUNDFONT, 1);
id = fluid_synth_sfload(synth, TEST_SOUNDFONT, 1);
sfont = fluid_synth_get_sfont_by_id(synth, id);
/* code under test */

View File

@ -1,6 +1,7 @@
#include "test.h"
#include "fluidsynth.h" // use local fluidsynth header
#include "utils/fluidsynth_priv.h"
// this test aims to make sure that sample data used by multiple synths is not freed
@ -9,7 +10,6 @@ int main(void)
{
enum { FRAMES = 1024 };
float buf[FRAMES * 2];
char *s;
fluid_settings_t *settings = new_fluid_settings();
fluid_synth_t *synth1 = new_fluid_synth(settings),
@ -19,17 +19,11 @@ int main(void)
TEST_ASSERT(synth1 != NULL);
TEST_ASSERT(synth2 != NULL);
TEST_SUCCESS(fluid_settings_dupstr(settings, "synth.default-soundfont", &s))
TEST_ASSERT(s[0] != '\0');
printf("Attempt to open %s\n", s);
// load a sfont to synth1
TEST_SUCCESS(fluid_synth_sfload(synth1, s, 1));
TEST_SUCCESS(fluid_synth_sfload(synth1, TEST_SOUNDFONT, 1));
// load the same font to synth2 and start a note
TEST_SUCCESS(fluid_synth_sfload(synth2, s, 1));
TEST_SUCCESS(fluid_synth_sfload(synth2, TEST_SOUNDFONT, 1));
TEST_SUCCESS(fluid_synth_noteon(synth2, 0, 60, 127));
// render some audio

View File

@ -9,7 +9,6 @@
// once unloaded by its parent synth
int main(void)
{
char *s;
int id;
fluid_sfont_t *sfont;
@ -22,20 +21,14 @@ int main(void)
// no sfont loaded
TEST_ASSERT(fluid_synth_sfcount(synth) == 0);
TEST_SUCCESS(fluid_settings_dupstr(settings, "synth.default-soundfont", &s))
TEST_ASSERT(s[0] != '\0');
FLUID_LOG(FLUID_INFO, "Attempt to open %s", s);
// load a sfont to synth
TEST_SUCCESS(id = fluid_synth_sfload(synth, s, 1));
TEST_SUCCESS(id = fluid_synth_sfload(synth, TEST_SOUNDFONT, 1));
// one sfont loaded
TEST_ASSERT(fluid_synth_sfcount(synth) == 1);
TEST_ASSERT((sfont = fluid_synth_get_sfont_by_id(synth, id)) != NULL);
// this is still the same filename as we've put in
TEST_ASSERT(FLUID_STRCMP(s, fluid_sfont_get_name(sfont)) == 0);
TEST_ASSERT(FLUID_STRCMP(TEST_SOUNDFONT, fluid_sfont_get_name(sfont)) == 0);
TEST_ASSERT(fluid_sfont_get_id(sfont) == id);
// still the same id?
@ -45,7 +38,7 @@ int main(void)
TEST_ASSERT((sfont = fluid_synth_get_sfont_by_id(synth, id)) != NULL);
// still the same filename?
TEST_ASSERT(FLUID_STRCMP(s, fluid_sfont_get_name(sfont)) == 0);
TEST_ASSERT(FLUID_STRCMP(TEST_SOUNDFONT, fluid_sfont_get_name(sfont)) == 0);
// correct id stored?
TEST_ASSERT(fluid_sfont_get_id(sfont) == id);
@ -59,6 +52,7 @@ int main(void)
// one sfont loaded
TEST_ASSERT(fluid_synth_sfcount(synth) == 1);
// destroy the sfont
TEST_SUCCESS(fluid_synth_sfunload(synth, id, 0));
// no sfont loaded