Add mechanics for Unit Tests, unit tests for AudioBuffer, and fix some minor AudioBuffer issues
parent
40035dee3c
commit
e7b45bc11a
|
@ -8,6 +8,8 @@ stages:
|
||||||
# - template: Code-Quality.gitlab-ci.yml
|
# - template: Code-Quality.gitlab-ci.yml
|
||||||
|
|
||||||
static-analysis:
|
static-analysis:
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
stage: test
|
stage: test
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
script:
|
script:
|
||||||
|
@ -16,8 +18,23 @@ static-analysis:
|
||||||
paths:
|
paths:
|
||||||
- lizard.txt
|
- lizard.txt
|
||||||
expire_in: 2 days
|
expire_in: 2 days
|
||||||
|
dependencies: []
|
||||||
|
|
||||||
build:
|
build-test:
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
stage: build
|
||||||
|
script:
|
||||||
|
- meson buildDir -DunitTests=true -Db_coverage=true
|
||||||
|
- ninja -C buildDir
|
||||||
|
artifacts:
|
||||||
|
untracked: true
|
||||||
|
expire_in: 1 days
|
||||||
|
dependencies: []
|
||||||
|
|
||||||
|
build-publish:
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
stage: build
|
stage: build
|
||||||
script:
|
script:
|
||||||
- meson --prefix /usr buildDir
|
- meson --prefix /usr buildDir
|
||||||
|
@ -27,15 +44,27 @@ build:
|
||||||
expire_in: 1 days
|
expire_in: 1 days
|
||||||
|
|
||||||
test:
|
test:
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
stage: test
|
stage: test
|
||||||
dependencies:
|
dependencies:
|
||||||
- build
|
- build-test
|
||||||
script: ninja -C buildDir test
|
script:
|
||||||
|
- ninja -C buildDir test
|
||||||
|
- gcovr -b -e buildDir/luppp@exe/catch.hpp -e buildDir/luppp@exe/test_ <&1 | tee buildDir/coverage.txt
|
||||||
|
artifacts:
|
||||||
|
paths:
|
||||||
|
- buildDir/coverage.txt
|
||||||
|
reports:
|
||||||
|
junit: buildDir/junit.xml
|
||||||
|
coverage: '/^TOTAL.*\s+(\d+\%)$/'
|
||||||
|
|
||||||
deploy-AppImage:
|
package-AppImage:
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
stage: package
|
stage: package
|
||||||
dependencies:
|
dependencies:
|
||||||
- build
|
- build-publish
|
||||||
script:
|
script:
|
||||||
- DESTDIR=./appdir ninja -C buildDir install ; find ./buildDir/appdir
|
- DESTDIR=./appdir ninja -C buildDir install ; find ./buildDir/appdir
|
||||||
- unset QTDIR; unset QT_PLUGIN_PATH ; unset LD_LIBRARY_PATH
|
- unset QTDIR; unset QT_PLUGIN_PATH ; unset LD_LIBRARY_PATH
|
||||||
|
|
|
@ -38,10 +38,14 @@ foreach dep : dep_names
|
||||||
endforeach
|
endforeach
|
||||||
|
|
||||||
# compile the main project
|
# compile the main project
|
||||||
executable('luppp', luppp_src + [version_hxx],
|
exe = executable('luppp', luppp_src + [version_hxx],
|
||||||
install: true,
|
install: true,
|
||||||
dependencies: deps)
|
dependencies: deps)
|
||||||
|
|
||||||
|
if get_option('unitTests')
|
||||||
|
test('Unit Tests', exe, args : ['-r junit', '-o junit.xml'])
|
||||||
|
endif
|
||||||
|
|
||||||
install_data('resources/metadata/luppp.desktop', install_dir: 'share/applications')
|
install_data('resources/metadata/luppp.desktop', install_dir: 'share/applications')
|
||||||
install_data('resources/metadata/luppp.appdata.xml', install_dir: 'share/appdata')
|
install_data('resources/metadata/luppp.appdata.xml', install_dir: 'share/appdata')
|
||||||
install_data('resources/icons/luppp.png', install_dir: 'share/pixmaps')
|
install_data('resources/icons/luppp.png', install_dir: 'share/pixmaps')
|
||||||
|
|
|
@ -1 +1,2 @@
|
||||||
option('tests', type : 'boolean', value : true, description : 'Build tests')
|
option('tests', type : 'boolean', value : false, description : 'Build tests')
|
||||||
|
option('unitTests', type : 'boolean', value : false, description : 'Build unit tests')
|
||||||
|
|
|
@ -83,12 +83,21 @@ void AudioBuffer::setBeats(int b)
|
||||||
numBeats = b;
|
numBeats = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioBuffer::setAudioFrames(long af)
|
bool
|
||||||
|
AudioBuffer::setAudioFrames(long af)
|
||||||
{
|
{
|
||||||
audioFrames = af;
|
if(af <= getSize()) {
|
||||||
|
audioFrames = af;
|
||||||
#ifdef DEBUG_BUFFER
|
#ifdef DEBUG_BUFFER
|
||||||
cout << "AudioBuffer " << ID << " has " << audioFrames << " audioFrames" << " and " << getSize() << " Buffersize\n" << endl;
|
cout << "AudioBuffer " << ID << " has " << audioFrames
|
||||||
|
<< " audioFrames"
|
||||||
|
<< " and " << getSize() << " Buffersize\n"
|
||||||
|
<< endl;
|
||||||
#endif
|
#endif
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
long AudioBuffer::getAudioFrames()
|
long AudioBuffer::getAudioFrames()
|
||||||
|
@ -118,8 +127,3 @@ void AudioBuffer::nonRtSetSample(std::vector<float>& sampleL, std::vector<float>
|
||||||
bufferL.swap(sampleL);
|
bufferL.swap(sampleL);
|
||||||
bufferR.swap(sampleR);
|
bufferR.swap(sampleR);
|
||||||
}
|
}
|
||||||
void AudioBuffer::nonRtResize(unsigned long size)
|
|
||||||
{
|
|
||||||
bufferL.resize(size);
|
|
||||||
bufferR.resize(size);
|
|
||||||
}
|
|
|
@ -48,7 +48,7 @@ public:
|
||||||
|
|
||||||
void setBeats(int b);
|
void setBeats(int b);
|
||||||
|
|
||||||
void setAudioFrames(long af);
|
bool setAudioFrames(long af);
|
||||||
|
|
||||||
long getAudioFrames();
|
long getAudioFrames();
|
||||||
|
|
||||||
|
@ -59,8 +59,6 @@ public:
|
||||||
|
|
||||||
void nonRtSetSample(std::vector<float>& sampleL, std::vector<float>& sampleR);
|
void nonRtSetSample(std::vector<float>& sampleL, std::vector<float>& sampleR);
|
||||||
|
|
||||||
void nonRtResize(unsigned long size);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static int privateID;
|
static int privateID;
|
||||||
int ID;
|
int ID;
|
||||||
|
|
|
@ -3,39 +3,48 @@ version_hxx = vcs_tag(
|
||||||
output : 'version.hxx',
|
output : 'version.hxx',
|
||||||
fallback: 'Version info could not be read.')
|
fallback: 'Version info could not be read.')
|
||||||
|
|
||||||
luppp_src = files(
|
if not get_option('unitTests')
|
||||||
'audiobuffer.cxx',
|
message('Create build config for publishing')
|
||||||
'controllerupdater.cxx',
|
luppp_src = files(
|
||||||
'debug.cxx',
|
'audiobuffer.cxx',
|
||||||
'diskreader.cxx',
|
'controllerupdater.cxx',
|
||||||
'diskwriter.cxx',
|
'debug.cxx',
|
||||||
'event.cxx',
|
'diskreader.cxx',
|
||||||
'eventhandlerdsp.cxx',
|
'diskwriter.cxx',
|
||||||
'eventhandlergui.cxx',
|
'event.cxx',
|
||||||
'gaudioeditor.cxx',
|
'eventhandlerdsp.cxx',
|
||||||
'gmastertrack.cxx',
|
'eventhandlergui.cxx',
|
||||||
'goptions.cxx',
|
'gaudioeditor.cxx',
|
||||||
'gridlogic.cxx',
|
'gmastertrack.cxx',
|
||||||
'gtrack.cxx',
|
'goptions.cxx',
|
||||||
'gui.cxx',
|
'gridlogic.cxx',
|
||||||
'jack.cxx',
|
'gtrack.cxx',
|
||||||
'jacksendreturn.cxx',
|
'gui.cxx',
|
||||||
'logic.cxx',
|
'jack.cxx',
|
||||||
'looperclip.cxx',
|
'jacksendreturn.cxx',
|
||||||
'looper.cxx',
|
'logic.cxx',
|
||||||
'main.cxx',
|
'looperclip.cxx',
|
||||||
'metronome.cxx',
|
'looper.cxx',
|
||||||
'timemanager.cxx',
|
'main.cxx',
|
||||||
'trackoutput.cxx'
|
'metronome.cxx',
|
||||||
)
|
'timemanager.cxx',
|
||||||
|
'trackoutput.cxx'
|
||||||
|
)
|
||||||
|
|
||||||
subdir('cjson')
|
subdir('cjson')
|
||||||
subdir('dsp')
|
subdir('dsp')
|
||||||
subdir('controller')
|
subdir('controller')
|
||||||
subdir('observer')
|
subdir('observer')
|
||||||
subdir('state')
|
subdir('state')
|
||||||
subdir('avtk')
|
subdir('avtk')
|
||||||
|
|
||||||
if(get_option('tests') == true)
|
if get_option('tests')
|
||||||
subdir('tests')
|
message('Built with Diskwriter Tests')
|
||||||
|
subdir('tests')
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
if get_option('unitTests')
|
||||||
|
message('Create build config for unit tests')
|
||||||
|
subdir('unitTests')
|
||||||
endif
|
endif
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,5 @@
|
||||||
|
luppp_src = files(
|
||||||
|
'test_audiobuffer.cxx',
|
||||||
|
'test_entrypoint.cxx',
|
||||||
|
'test_debug.cxx',
|
||||||
|
'../audiobuffer.cxx')
|
|
@ -0,0 +1,79 @@
|
||||||
|
#include "catch.hpp"
|
||||||
|
#include "test_debug.hxx"
|
||||||
|
#include "../audiobuffer.hxx"
|
||||||
|
|
||||||
|
extern OUTPUT output;
|
||||||
|
|
||||||
|
int AudioBuffer::privateID = 0;
|
||||||
|
|
||||||
|
TEST_CASE("AudioBuffer Tests")
|
||||||
|
{
|
||||||
|
AudioBuffer *ab_sizeless = new AudioBuffer();
|
||||||
|
AudioBuffer *ab_size = new AudioBuffer(1000);
|
||||||
|
|
||||||
|
SECTION("Test correct initial state")
|
||||||
|
{
|
||||||
|
REQUIRE(ab_size->getBeats() == 0);
|
||||||
|
REQUIRE(ab_size->getAudioFrames() == 0);
|
||||||
|
REQUIRE(ab_size->getSize() == 1000);
|
||||||
|
|
||||||
|
REQUIRE(ab_sizeless->getBeats() == 0);
|
||||||
|
REQUIRE(ab_sizeless->getAudioFrames() == 0);
|
||||||
|
REQUIRE(ab_sizeless->getSize() == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("Test ID changes")
|
||||||
|
{
|
||||||
|
ab_size->setID(500);
|
||||||
|
REQUIRE(ab_size->getID() == 500);
|
||||||
|
ab_sizeless->setID(501);
|
||||||
|
REQUIRE(ab_sizeless->getID() == 501);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("Test name changes")
|
||||||
|
{
|
||||||
|
ab_size->setName("abcdef");
|
||||||
|
REQUIRE(ab_size->getName() == "abcdef");
|
||||||
|
ab_size->setName("Lorem ipsum dolor sit amet");
|
||||||
|
REQUIRE(ab_size->getName() == "Lorem ipsum dolor si");
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("Test beat num changes") {
|
||||||
|
ab_size->setBeats(5);
|
||||||
|
REQUIRE(ab_size->getBeats() == 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("Test audio frames change") {
|
||||||
|
ab_size->setAudioFrames(900);
|
||||||
|
REQUIRE(ab_size->getAudioFrames() == 900);
|
||||||
|
|
||||||
|
// Set AudioFrames higher than size
|
||||||
|
REQUIRE(ab_size->setAudioFrames(1500) == false);
|
||||||
|
REQUIRE(ab_size->getAudioFrames() == 900);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("Test Set Audio Buffer with different Length") {
|
||||||
|
std::vector<float> tempL;
|
||||||
|
for(int i = 0; i < 500; i++) {
|
||||||
|
tempL.push_back(rand());
|
||||||
|
}
|
||||||
|
std::vector<float> tempR;
|
||||||
|
for(int i = 0; i < 900; i++) {
|
||||||
|
tempR.push_back(rand());
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<float> argL = tempL;
|
||||||
|
std::vector<float> argR = tempR;
|
||||||
|
ab_size->nonRtSetSample(argL, argR);
|
||||||
|
|
||||||
|
REQUIRE(ab_size->getSize() == 500);
|
||||||
|
REQUIRE(strcmp(output.format,
|
||||||
|
"left and right channels of audio buffer have different size: %i vs %i") == 0);
|
||||||
|
REQUIRE(output.warnLevel == 1);
|
||||||
|
|
||||||
|
REQUIRE(ab_size->getDataL() == tempL);
|
||||||
|
REQUIRE(ab_size->getDataR() == tempR);
|
||||||
|
|
||||||
|
output.reset();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
#include "test_debug.hxx"
|
||||||
|
|
||||||
|
OUTPUT output;
|
||||||
|
|
||||||
|
void
|
||||||
|
luppp_debug(int warnLevel, const char *name, const char *file, const char *func,
|
||||||
|
int line, const char *format, ...)
|
||||||
|
{
|
||||||
|
output.warnLevel = warnLevel;
|
||||||
|
output.name = name;
|
||||||
|
output.file = file;
|
||||||
|
output.func = func;
|
||||||
|
output.line = line;
|
||||||
|
output.format = format;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
OUTPUT::reset()
|
||||||
|
{
|
||||||
|
warnLevel = 0;
|
||||||
|
name = "";
|
||||||
|
file = "";
|
||||||
|
func = "";
|
||||||
|
line = 0;
|
||||||
|
format = "";
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
struct OUTPUT {
|
||||||
|
int warnLevel;
|
||||||
|
const char *name;
|
||||||
|
const char *file;
|
||||||
|
const char *func;
|
||||||
|
int line;
|
||||||
|
const char *format;
|
||||||
|
|
||||||
|
void
|
||||||
|
reset();
|
||||||
|
};
|
|
@ -0,0 +1,2 @@
|
||||||
|
#define CATCH_CONFIG_MAIN
|
||||||
|
#include "catch.hpp"
|
Loading…
Reference in New Issue