Migration to gtest framework completed

pull/495/head
abscisys 2 years ago
parent 68e2a887c6
commit edc843c7e7
  1. 71
      src/test/Makefile
  2. 11
      src/test/test_cpp_performance.cpp
  3. 6
      src/test/test_fx.cpp
  4. 14
      src/test/test_fx_components.cpp
  5. 25
      src/test/test_fx_helper.cpp
  6. 23
      src/test/test_fx_helper.h
  7. 10
      src/test/test_fx_rack.cpp
  8. 4
      src/test/test_mixing_console.cpp

@ -1,11 +1,10 @@
OBJDIR := objects
OUTPUT_FOLDER = results
EXECUTABLE := all_test.bin
EXE := all_test.bin
CXX := g++
# CXXFLAGS := -O2
CXXFLAGS = -g -std=c++20
DEFINES = -DCPU=x86 -DDEBUG -DOUTPUT_FOLDER=$(OUTPUT_FOLDER)
DEFINES = -DCPU=x86 -DDEBUG -DOUTPUT_FOLDER="\"$(OUTPUT_FOLDER)\""
INCLUDES = -I../../CMSIS_5/CMSIS/DSP/Include/ \
-I../../CMSIS_5/CMSIS/Core/Include/ \
-I../../Synth_Dexed/src/
@ -15,46 +14,48 @@ INCLUDES = -I../../CMSIS_5/CMSIS/DSP/Include/ \
LD := g++
LIBS := -lm -lstdc++ -lgtest -lpthread
SRCS := $(filter-out waveplay.cpp, $(wildcard *.cpp))
SRCS += ../fx.cpp
SRCS += ../fx_components.cpp
SRCS += ../fx_svf.cpp
SRCS += ../fx_tube.cpp
SRCS += ../fx_chorus.cpp
SRCS += ../fx_phaser.cpp
SRCS += ../fx_orbitone.cpp
SRCS += ../fx_flanger.cpp
SRCS += ../fx_delay.cpp
SRCS += ../effect_platervbstereo.cpp
SRCS += ../fx_shimmer_reverb.cpp
SRCS += ../fx_dry.cpp
SRCS += ../fx_rack.cpp
OBJ = $(SRCS:.cpp=.o)
OBJS = $(addprefix $(OBJDIR)/,$(OBJ))
all: $(EXECUTABLE)
test: all
TST_SRCS := $(filter-out waveplay.cpp, $(wildcard *.cpp))
FX__SRCS := ../fx.cpp
FX__SRCS += ../fx_components.cpp
FX__SRCS += ../fx_svf.cpp
FX__SRCS += ../fx_tube.cpp
FX__SRCS += ../fx_chorus.cpp
FX__SRCS += ../fx_phaser.cpp
FX__SRCS += ../fx_orbitone.cpp
FX__SRCS += ../fx_flanger.cpp
FX__SRCS += ../fx_delay.cpp
FX__SRCS += ../effect_platervbstereo.cpp
FX__SRCS += ../fx_shimmer_reverb.cpp
FX__SRCS += ../fx_dry.cpp
FX__SRCS += ../fx_rack.cpp
TST_OBJS = $(TST_SRCS:%.cpp=$(OBJDIR)/%.o)
FX__OBJS = $(patsubst ../%, $(OBJDIR)/%, $(FX__SRCS:.cpp=.o))
all: $(EXE) test
test: $(EXE) $(OUTPUT_FOLDER)
rm -f $(OUTPUT_FOLDER)/*
./$(EXECUTABLE)
clean-all: clean test
./$(EXE)
$(OBJDIR):
mkdir -p $(OBJDIR)
mkdir -p $@
$(OUTPUT_FOLDER):
mkdir -p $@
$(OBJDIR)/%.o: %.cpp $(OBJDIR)
$(CXX) $(CXXFLAGS) $(DEFINES) $(INCLUDES) -c $< -o $@
test_mixing_console.cpp: ../mixing_console.h ../mixing_console.cpp
touch $@
$(OBJDIR)/%.o: ../%.cpp $(OBJDIR)
$(CXX) $(CXXFLAGS) $(DEFINES) $(INCLUDES) -c $< -o $@
$(EXECUTABLE): $(OBJS)
$(LD) $(OBJS) -o $@ $(LIBS)
# $(EXE): $(call wildcard,$(TST_OBJS)) $(call wildcard,$(FX__OBJS))
$(EXE): $(TST_OBJS) $(FX__OBJS)
$(LD) $(CXXFLAGS) $(call wildcard,$(TST_OBJS)) $(call wildcard,$(FX__OBJS)) -o $@ $(LIBS)
$(OUTPUT_FOLDER):
mkdir -p $@
test_mixing_console.cpp: ../mixing_console.h ../mixing_console.cpp
touch $@
clean:
rm -rf $(OUTPUT_FOLDER) *.o $(EXECUTABLE)
rm -rf *.o $(OBJDIR) $(EXE) $(OUTPUT_FOLDER)

@ -59,19 +59,20 @@ TEST(CppPerformance, LFOPerformance_ComplexLFO_FastLFO)
EXPECT_GE(d1, d2);
}
TEST_F(FxComponentFixture, FastLFOTuning)
TEST(CppPerformance, FastLFOTuning)
{
float32_t freq = 10.0f;
float32_t freq = 5.0f;
size_t NB = static_cast<size_t>(1.0f * SAMPLING_FREQUENCY);
FastLFO lfo1(SAMPLING_FREQUENCY, 10.0f, 440.0f);
FastLFO lfo1(SAMPLING_FREQUENCY, freq, 440.0f);
lfo1.setFrequency(freq);
ComplexLFO lfo2(SAMPLING_FREQUENCY, 10.0f, 440.0f);
ComplexLFO lfo2(SAMPLING_FREQUENCY, freq, 440.0f);
lfo2.setFrequency(freq);
std::ofstream out(this->getResultFile("FastLFO-data.csv"));
std::ofstream out(getResultFile("CppPerformance.FastLFOTuning-data.csv"));
setupOuputStreamFocCSV(out);
out << "index;FastLFO;ComplexLFO" << std::endl;
for(size_t i = 0; i < NB; ++i)
{

@ -5,7 +5,7 @@
#include "../effect_platervbstereo.h"
TEST_F(FxComponentFixture, PlateReverb)
TEST(FXElement, PlateReverbMigration)
{
const unsigned nbRepeats = 4;
@ -34,7 +34,7 @@ TEST_F(FxComponentFixture, PlateReverb)
++index;
}
}
saveWaveFile(this->getResultFile("result-PlateReverb-new.wav"), sampleOutL, sampleOutR, nbRepeats * size, static_cast<unsigned>(SAMPLING_FREQUENCY), 16);
saveWaveFile(getResultFile("result-PlateReverb-new.wav"), sampleOutL, sampleOutR, nbRepeats * size, static_cast<unsigned>(SAMPLING_FREQUENCY), 16);
unsigned indexOut = 0;
for (unsigned i = 0; i < nbRepeats; ++i)
@ -54,7 +54,7 @@ TEST_F(FxComponentFixture, PlateReverb)
}
}
saveWaveFile(this->getResultFile("result-PlateReverb-legacy.wav"), sampleOutL, sampleOutR, nbRepeats * size, static_cast<unsigned>(SAMPLING_FREQUENCY), 16);
saveWaveFile(getResultFile("result-PlateReverb-legacy.wav"), sampleOutL, sampleOutR, nbRepeats * size, static_cast<unsigned>(SAMPLING_FREQUENCY), 16);
delete[] sampleOutL;
delete[] sampleOutR;

@ -19,7 +19,7 @@
#define MAX_SVF_SAMPLES 10000000
#define MAX_NB_ERRORS 100
TEST_F(FxComponentFixture, LFO)
TEST(FXComponent, LFO)
{
const float32_t freq = 10.0f;
@ -28,7 +28,7 @@ TEST_F(FxComponentFixture, LFO)
float32_t rate = 0.0f;
float32_t rate_increment = freq / 2.0f / SAMPLING_FREQUENCY;
std::ofstream out(this->getResultFile("result-LFO.csv"));
std::ofstream out(getResultFile("FXComponent.LFO.csv"));
setupOuputStreamFocCSV(out);
out << fixed << showpoint;
@ -58,7 +58,7 @@ TEST(FXComponent, Flutter)
}
}
TEST_F(FxComponentFixture, SVF)
TEST(FXComponent, SVF)
{
float32_t inL, inR;
float32_t outL, outR;
@ -73,8 +73,8 @@ TEST_F(FxComponentFixture, SVF)
while(nbErrors < MAX_NB_ERRORS && nbSamples < MAX_SVF_SAMPLES)
{
nbSamples++;
inL = this->getRandomValue();
inR = this->getRandomValue();
inL = getRandomValue();
inR = getRandomValue();
svf.processSample(inL, inR, outL, outR);
if(std::abs(outL) > 1.0f)
@ -94,8 +94,8 @@ TEST_F(FxComponentFixture, SVF)
while(nbErrors < MAX_NB_ERRORS && nbSamples < MAX_SVF_SAMPLES)
{
nbSamples++;
inL = this->getRandomValue();
inR = this->getRandomValue();
inL = getRandomValue();
inR = getRandomValue();
svf.processSample(inL, inR, outL, outR);
if(std::abs(outL) > 1.0f)

@ -96,27 +96,16 @@ void setupOuputStreamFocCSV(std::ostream& out)
out << fixed << showpoint;
}
FxComponentFixture::FxComponentFixture() :
testing::Test(),
gen_(rd_()),
dist_(-1.0f, 1.0f)
std::string getResultFile(const std::string& filename)
{
return std::string(OUTPUT_FOLDER) + "/" + filename;
}
void FxComponentFixture::SetUp()
float32_t getRandomValue()
{
}
void FxComponentFixture::TearDown()
{
}
static random_device rd;
static mt19937 gen(rd());
static uniform_real_distribution<float32_t> dist(-1.0f, 1.0f);
string FxComponentFixture::getResultFile(const std::string& filename)
{
return std::string(STR(OUTPUT_FOLDER)) + "/" + filename;
}
float32_t FxComponentFixture::getRandomValue()
{
return this->dist_(this->gen_);
return dist(gen);
}

@ -11,7 +11,7 @@
#define SAMPLING_FREQUENCY 44100.0f
#define STR(x) #x
#define stringify( x ) # x
#define Active(scenarioKey, FxID) ((scenarioKey & (1 << FxID)) == (1 << FxID))
@ -29,25 +29,10 @@ enum FXSwitch
FX__PlateReverb
};
class FXScenarioTest : public testing::TestWithParam<int>
{
};
void setupOuputStreamFocCSV(std::ostream& out);
class FxComponentFixture : public testing::Test
{
public:
FxComponentFixture();
std::string getResultFile(const string& filename);
virtual void SetUp() override;
virtual void TearDown() override;
float32_t getRandomValue();
std::string getResultFile(const string& filename);
float32_t getRandomValue();
random_device rd_;
mt19937 gen_;
uniform_real_distribution<float32_t> dist_;
};
class FXScenarioTest : public testing::TestWithParam<int> {};

@ -77,7 +77,7 @@ TEST_P(FXScenarioTest, FXRackResetAllScenarios)
delete rack;
}
TEST_P(FXScenarioTest, FXRackProcessAllScenarios)
TEST_P(FXScenarioTest, ScenarioProcessing)
{
const unsigned nbRepeats = 1;
unsigned size;
@ -104,9 +104,9 @@ TEST_P(FXScenarioTest, FXRackProcessAllScenarios)
rack->process(samples[0], samples[1], sampleOutL + i * size, sampleOutR + i * size, size);
}
stringstream ss("FXRack-");
ss << name << ".wav";
saveWaveFile(ss.str(), sampleOutL, sampleOutR, nbRepeats * size, static_cast<unsigned>(SAMPLING_FREQUENCY), 16);
stringstream ss;
ss << "result-fx-rack" << name << ".wav";
saveWaveFile(getResultFile(ss.str()), sampleOutL, sampleOutR, nbRepeats * size, static_cast<unsigned>(SAMPLING_FREQUENCY), 16);
delete rack;
@ -117,4 +117,4 @@ TEST_P(FXScenarioTest, FXRackProcessAllScenarios)
delete[] sampleOutR;
}
INSTANTIATE_TEST_SUITE_P(FXTestInstance, FXScenarioTest, testing::Range(0, 1 << (FXSwitch::FX__ShimmerReverb + 1)));
INSTANTIATE_TEST_SUITE_P(FXRack, FXScenarioTest, testing::Range(0, 1 << (FXSwitch::FX__ShimmerReverb + 1)));

@ -203,7 +203,7 @@ TEST(MixingConsole, DryProcessing)
delete mixer;
}
TEST_F(FxComponentFixture, SimpleProcessing)
TEST(MixingConsole, SimpleProcessing)
{
const unsigned nbRepeats = 4;
unsigned size;
@ -238,7 +238,7 @@ TEST_F(FxComponentFixture, SimpleProcessing)
mixer->setInputSampleBuffer(0, samples[0], samples[1]);
mixer->process(sampleOutL + j * size, sampleOutR + j * size);
}
saveWaveFile(this->getResultFile("result-mixing-console.wav"), sampleOutL, sampleOutR, nbRepeats * size, static_cast<unsigned>(SAMPLING_FREQUENCY), 16);
saveWaveFile(getResultFile("result-mixing-console.wav"), sampleOutL, sampleOutR, nbRepeats * size, static_cast<unsigned>(SAMPLING_FREQUENCY), 16);
delete mixer;

Loading…
Cancel
Save