-Updated test code location to src/tests, gcov was counting the test code lines as "untested"

This commit is contained in:
Harry van Haaren 2013-09-15 22:59:35 +01:00
parent 205aba43b4
commit ed803634e2
6 changed files with 99 additions and 41 deletions

View file

@ -11,16 +11,17 @@ INCLUDES += `pkg-config --cflags jack sndfile cairomm-1.0 ntk ntk_images`
ifeq (@(LUPPP_BUILD_TESTS),y)
CFLAGS += -fprofile-arcs -ftest-coverage -DBUILD_TESTS -DBUILD_COVERAGE_TEST -DDEBUG_KILL_ON_ERR
OUTPUT += | %B.gcno
: foreach tests/*.cxx |> ^c^ g++ $(CFLAGS) -c %f $(INCLUDES) -o %o |> $(OUTPUT)
endif
# COMPILE
#: foreach *.cxx observer/*.cxx state/*.cxx cjson/*.c dsp/*.cxx controller/*.cxx avtk/*.cxx |> ^c^ g++ $(CFLAGS) -c %f $(INCLUDES) -o %o |> $(OUTPUT)
: foreach *.cxx |> ^c^ g++ $(CFLAGS) -c %f $(INCLUDES) -o %o |> $(OUTPUT)
: foreach avtk/*.cxx |> ^c^ g++ $(CFLAGS) -c %f $(INCLUDES) -o %o |> $(OUTPUT)
: foreach controller/*.cxx |> ^c^ g++ $(CFLAGS) -c %f $(INCLUDES) -o %o |> $(OUTPUT)
: foreach dsp/*.cxx |> ^c^ g++ $(CFLAGS) -c %f $(INCLUDES) -o %o |> $(OUTPUT)
: foreach cjson/*.c |> ^c^ g++ $(CFLAGS) -c %f $(INCLUDES) -o %o |> $(OUTPUT)
: foreach state/*.cxx |> ^c^ g++ $(CFLAGS) -c %f $(INCLUDES) -o %o |> $(OUTPUT)
: foreach observer/*.cxx |> ^c^ g++ $(CFLAGS) -c %f $(INCLUDES) -o %o |> $(OUTPUT)
: foreach *.cxx |> ^c^ g++ $(CFLAGS) -c %f $(INCLUDES) -o %o |> $(OUTPUT)

View file

@ -4,11 +4,6 @@
#include "jack.hxx"
#include "audiobuffer.hxx"
#ifdef BUILD_TESTS
#define CATCH_CONFIG_RUNNER
#include "catch.hxx"
#endif
extern Jack* jack;
const char* GridLogic::StateString[8] = {
@ -200,35 +195,3 @@ void GridLogic::beat()
}
#ifdef BUILD_TESTS
int GridLogic::runTests()
{
char* const tmp = "-s";
return Catch::Session().run( 1, &tmp );
}
TEST_CASE( "Gridlogic press events", "[gridlogic]" )
{
for(int t = 0; t < NTRACKS; t++)
{
LooperClip* lc = jack->getLooper( t )->getClip( 0 );
GridLogic::State s1 = lc->getState();
lc->queuePlay();
REQUIRE( lc->getQueuePlay() == true );
lc->bar();
REQUIRE( lc->getQueuePlay() == false );
}
int t = 0;
int s = 0;
LooperClip* lc = jack->getLooper( t )->getClip( s );
lc->init();
jack->getGridLogic()->pressed( t, s );
REQUIRE( lc->playing() == false );
}
#endif

View file

@ -297,6 +297,7 @@ void LooperClip::queuePlay(bool qP)
{
_queuePlay = true;
_queueStop = false;
_queueRecord = false;
}
void LooperClip::queueStop()

View file

@ -0,0 +1,77 @@
#include "../gridlogic.hxx"
#include "../jack.hxx"
#include "../looperclip.hxx"
extern Jack* jack;
#ifdef BUILD_TESTS
#define CATCH_CONFIG_RUNNER
#include "catch.hxx"
#endif
#ifdef BUILD_TESTS
int GridLogic::runTests()
{
char* const tmp = "-s";
return Catch::Session().run( 1, &tmp );
}
TEST_CASE( "Gridlogic press events", "[gridlogic]" )
{
int t = 0;
int s = 0;
LooperClip* lc = jack->getLooper( t )->getClip( s );
for(int t = 0; t < NTRACKS; t++)
{
lc->init();
GridLogic::State s1 = lc->getState();
REQUIRE( lc->getState() == GridLogic::STATE_EMPTY );
jack->getGridLogic()->launchScene( s );
REQUIRE( lc->getQueuePlay() == false );
jack->getGridLogic()->bar();
REQUIRE( lc->getQueuePlay() == true );
REQUIRE( jack->getGridLogic()->getLaunchedScene() == s );
}
/// SCENE LAUNCH
lc->init();
jack->getGridLogic()->launchScene( s );
REQUIRE( jack->getGridLogic()->getLaunchedScene() == s );
/// PAD STATE CHECKS
// empty -> recording
lc->init();
REQUIRE( lc->getState() == GridLogic::STATE_EMPTY );
jack->getGridLogic()->pressed( t, s );
jack->getGridLogic()->released( t, s );
REQUIRE( lc->getState() == GridLogic::STATE_RECORD_QUEUED );
jack->getGridLogic()->bar();
REQUIRE( lc->getState() == GridLogic::STATE_RECORDING );
// recording -> playing
jack->getGridLogic()->pressed( t, s );
jack->getGridLogic()->released( t, s );
REQUIRE( lc->getState() == GridLogic::STATE_PLAY_QUEUED );
jack->getGridLogic()->bar();
REQUIRE( lc->getState() == GridLogic::STATE_PLAYING );
// playing -> stopped
jack->getGridLogic()->pressed( t, s );
jack->getGridLogic()->released( t, s );
REQUIRE( lc->getState() == GridLogic::STATE_STOP_QUEUED );
jack->getGridLogic()->bar();
REQUIRE( lc->getState() == GridLogic::STATE_STOPPED );
// stopped -> playing
jack->getGridLogic()->pressed( t, s );
jack->getGridLogic()->released( t, s );
REQUIRE( lc->getState() == GridLogic::STATE_PLAY_QUEUED );
jack->getGridLogic()->bar();
REQUIRE( lc->getState() == GridLogic::STATE_PLAYING );
}
#endif

18
test.sh
View file

@ -18,11 +18,26 @@ set -e
rm -rf buildTest/src/
tup upd buildTest/
if [ $? -eq 0 ]; then
notify-send -t 5 "Luppp: Compiled successfully..."
echo OK
else
notify-send -t 0 --urgency=critical "Luppp: Compilation FAILURE!"
echo FAIL
fi
cd buildTest/
./luppp
if [ $? -eq 0 ]; then
notify-send -t 5 "Luppp: Tests passed successfully..."
echo OK
else
notify-send -t 5 -u critical "Luppp: Test FAILURE!"
echo FAIL
fi
cd src
gcov -r -b *
@ -30,4 +45,5 @@ cp -r ../../src/* ./
lcov --directory . --capture --output-file lcov.info
genhtml lcov.info
firefox index.html
notify-send -t 5 "Luppp: Test data available..."
firefox src/index.html