mirror of
https://github.com/vale981/openAV-Luppp
synced 2025-03-05 09:01:39 -05:00
-Updated test code, CMake, QUnit
This commit is contained in:
parent
2dc9ed8c74
commit
5b38d9b3c5
10 changed files with 70 additions and 34 deletions
|
@ -13,7 +13,7 @@ add_definitions( -DBUILD_TESTS )
|
|||
add_definitions( -DBUILD_COVERAGE_TEST )
|
||||
|
||||
|
||||
set(CMAKE_VERBOSE_MAKEFILE on)
|
||||
#set(CMAKE_VERBOSE_MAKEFILE on)
|
||||
|
||||
#set(CMAKE_FILES_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||
#set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||
|
|
|
@ -12,10 +12,10 @@
|
|||
#define DEBUG_TRACKS 1
|
||||
|
||||
// Clip selection / queueing
|
||||
#define DEBUG_CLIP 1
|
||||
//#define DEBUG_CLIP 1
|
||||
|
||||
// Buffer loading / resizing
|
||||
#define DEBUG_BUFFER 1
|
||||
//#define DEBUG_BUFFER 1
|
||||
|
||||
// Logic : Warning NON RT!
|
||||
#define DEBUG_LOGIC 1
|
||||
|
|
|
@ -9,27 +9,39 @@ void luppp_debug( int warnLevel, const char* name, const char* file, const char*
|
|||
{
|
||||
if ( warnLevel == DEBUG_LEVEL_KILL )
|
||||
{
|
||||
printf( "[\033[1;31m%s\033[0m] %s : %s : %i ", NAME, file, func, line );
|
||||
#ifdef DEBUG_KILL_ON_ERR
|
||||
assert(false);
|
||||
#endif
|
||||
printf( "[\033[1;31m%s\033[0m] %s:%i: ", NAME, func, line );
|
||||
}
|
||||
else if ( warnLevel == DEBUG_LEVEL_WARN )
|
||||
{
|
||||
printf( "[\033[1;33m%s\033[0m] %s : %s : %i ", NAME, file, func, line );
|
||||
printf( "[\033[1;33m%s\033[0m] %s:%i: ", NAME, func, line );
|
||||
}
|
||||
else if ( warnLevel == DEBUG_LEVEL_TEST )
|
||||
{
|
||||
#ifdef BUILD_TESTS
|
||||
printf( "[\033[1;33m%s\033[0m] %s:%i: ", NAME, func, line );
|
||||
#endif
|
||||
}
|
||||
else // NOTE
|
||||
{
|
||||
printf( "[\033[1;32m%s\033[0m] %s : %s : %i ", NAME, file, func, line );
|
||||
printf( "[\033[1;32m%s\033[0m] %s:%i: ", NAME, func, line );
|
||||
}
|
||||
printf( "\033[0m" );
|
||||
|
||||
if ( format )
|
||||
{
|
||||
va_list args;
|
||||
va_start( args, format );
|
||||
printf( format, args );
|
||||
vfprintf( stdout, format, args );
|
||||
va_end( args );
|
||||
}
|
||||
printf( "\033[0m\n" );
|
||||
printf( "\n" );
|
||||
|
||||
#ifdef DEBUG_KILL_ON_ERR
|
||||
if ( warnLevel == DEBUG_LEVEL_KILL )
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -5,18 +5,29 @@
|
|||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
/* Example usage
|
||||
LUPPP_NOTE( "%s", "MessageHere" );
|
||||
LUPPP_WARN( "%s", "MessageHere" );
|
||||
LUPPP_KILL( "%s", "MessageHere" );
|
||||
*/
|
||||
|
||||
enum DEBUG_LEVEL {
|
||||
DEBUG_LEVEL_NOTE = 0,
|
||||
DEBUG_LEVEL_WARN,
|
||||
DEBUG_LEVEL_KILL
|
||||
DEBUG_LEVEL_KILL,
|
||||
DEBUG_LEVEL_TEST
|
||||
};
|
||||
|
||||
void luppp_debug( int warnLevel, const char* name, const char* file, const char* func, int line,
|
||||
const char* format = 0, ... );
|
||||
|
||||
|
||||
#define LUPPP_NOTE( format, args... ) luppp_debug( DEBUG_LEVEL_NOTE, NAME, __FILE__, __FUNCTION__, __LINE__, format, ## args )
|
||||
#define LUPPP_WARN( format, args... ) luppp_debug( DEBUG_LEVEL_WARN, NAME, __FILE__, __FUNCTION__, __LINE__, format, ## args )
|
||||
#define LUPPP_KILL( format, args... ) luppp_debug( DEBUG_LEVEL_KILL, NAME, __FILE__, __FUNCTION__, __LINE__, format, ## args )
|
||||
#define LUPPP_KILL( format, args... ) luppp_debug( DEBUG_LEVEL_TEST, NAME, __FILE__, __FUNCTION__, __LINE__, format, ## args )
|
||||
|
||||
// only gets printed if #definde BUILD_TESTS
|
||||
#define LUPPP_PRINT_TEST( format, args... ) luppp_debug( DEBUG_LEVEL_DEBUG_ONLY, NAME, __FILE__, __FUNCTION__, __LINE__, format, ## args )
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -18,11 +18,6 @@ const char* GridLogic::StateString[8] = {
|
|||
|
||||
GridLogic::GridLogic()
|
||||
{
|
||||
LUPPP_NOTE( "%s", "GridLogic() note" );
|
||||
LUPPP_WARN( "%s", "GridLogic() warn" );
|
||||
//LUPPP_KILL( "%s", "GridLogic() kill" );
|
||||
//luppp_debug( "GridLogic", __FILE__, __LINE__ );
|
||||
//luppp_debug( "GridLogic", __FILE__, __LINE__, "%s", "Starting up..." );
|
||||
sceneLaunch = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -60,8 +60,8 @@ static void gui_header_callback(Fl_Widget *w, void *data)
|
|||
}
|
||||
else if ( strcmp(m->label(), "New Session") == 0 )
|
||||
{
|
||||
int yes = fl_ask("Start a new session?","");
|
||||
if ( yes )
|
||||
int no = fl_choice("Start a new session?","Cancel","Yes",0);
|
||||
if ( no )
|
||||
{
|
||||
EventStateReset ev;
|
||||
writeToDspRingbuffer( &ev );
|
||||
|
@ -131,6 +131,7 @@ Gui::Gui() :
|
|||
diskReader( new DiskReader ),
|
||||
diskWriter( new DiskWriter )
|
||||
{
|
||||
LUPPP_NOTE( "%s", "Gui()" );
|
||||
window.color(FL_BLACK);
|
||||
window.label("Luppp");
|
||||
//window.callback( close_cb, 0 );
|
||||
|
|
23
src/main.cxx
23
src/main.cxx
|
@ -45,17 +45,29 @@ int main(int argc, char** argv)
|
|||
rbToDsp = jack_ringbuffer_create( 5000 * sizeof(EventBase));
|
||||
rbToGui = jack_ringbuffer_create( 5000 * sizeof(EventBase));
|
||||
|
||||
gui = new Gui();
|
||||
jack = new Jack();
|
||||
|
||||
#ifdef BUILD_TESTS
|
||||
if ( runTests )
|
||||
{
|
||||
// setup the testing Gui / JACK
|
||||
gui = new Gui();
|
||||
jack = new Jack();
|
||||
|
||||
// test offline functionality
|
||||
gui->getDiskWriter()->runTests();
|
||||
|
||||
|
||||
delete gui;
|
||||
delete jack;
|
||||
|
||||
gui = new Gui();
|
||||
jack = new Jack();
|
||||
|
||||
// test realtime functionality
|
||||
jack->getGridLogic()->runTests();
|
||||
|
||||
delete gui;
|
||||
delete jack;
|
||||
|
||||
#ifdef BUILD_COVERAGE_TEST
|
||||
if ( stopAfterTest )
|
||||
{
|
||||
|
@ -66,6 +78,11 @@ int main(int argc, char** argv)
|
|||
}
|
||||
// FIXME: Reset the state of GUI / GridLogic here. Create a "new session"?
|
||||
#endif
|
||||
|
||||
// setup the "real" GUI / JACK
|
||||
gui = new Gui();
|
||||
jack = new Jack();
|
||||
|
||||
jack->activate();
|
||||
gui->show();
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ extern Gui* gui;
|
|||
|
||||
int DiskWriter::runTests()
|
||||
{
|
||||
QUnit::UnitTest qunit( QUnit::verbose );
|
||||
QUnit::UnitTest qunit( QUnit::normal );
|
||||
//AudioBuffer ab;
|
||||
//QUNIT_IS_TRUE( gui->getDiskWriter()->writeAudioBuffer(0, 0, &ab) == LUPPP_RETURN_OK );
|
||||
|
||||
|
|
|
@ -15,22 +15,18 @@ extern Jack* jack;
|
|||
|
||||
int GridLogic::runTests()
|
||||
{
|
||||
QUnit::UnitTest qunit( QUnit::verbose );
|
||||
QUnit::UnitTest qunit( QUnit::normal );
|
||||
int t = 0;
|
||||
int s = 0;
|
||||
LooperClip* lc = jack->getLooper( t )->getClip( s );
|
||||
|
||||
/// LA
|
||||
lc->init();
|
||||
GridLogic::State s1 = lc->getState();
|
||||
|
||||
/// SCENE LAUNCH
|
||||
lc->init();
|
||||
jack->getGridLogic()->launchScene( s );
|
||||
QUNIT_IS_TRUE( jack->getGridLogic()->getLaunchedScene() == s );
|
||||
|
||||
|
||||
/// PAD STATE CHECKSfds
|
||||
/// PAD STATE CHECKS
|
||||
// empty -> recording
|
||||
lc->init();
|
||||
QUNIT_IS_TRUE( lc->getState() == GridLogic::STATE_EMPTY );
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include <sstream>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <libgen.h>
|
||||
using namespace std;
|
||||
|
||||
#define QUNIT_COLOUR_PASS "\033[1;32m"
|
||||
|
@ -118,19 +119,22 @@ namespace QUnit {
|
|||
if( (ok && !(verboseLevel_ > normal)) || verboseLevel_ == silent )
|
||||
return;
|
||||
|
||||
cout << file << ( ok ? ";" : ":" ) << line << ": ";
|
||||
|
||||
char* baseFile = strdup(file);
|
||||
cout << basename(baseFile) << " " << line << " : ";
|
||||
free( baseFile );
|
||||
if ( ok ) {
|
||||
cout << QUNIT_COLOUR_PASS;
|
||||
} else {
|
||||
cout << QUNIT_COLOUR_ERROR;
|
||||
}
|
||||
cout << ( ok ? "OK" : "FAILED" ) << QUNIT_COLOUR_RESET << "/" << func << "(): ";
|
||||
cout << ( ok ? "OK" : "FAILED" ) << QUNIT_COLOUR_RESET << " : ";
|
||||
if( compare ) {
|
||||
const std::string cmp = ( result ? "==" : "!=" );
|
||||
cout << "compare {" << str1 << "} " << cmp << " {" << str2 << "} "
|
||||
<< "got {\"" << val1 << "\"} " << cmp << " {\"" << val2 << "\"}";
|
||||
} else {
|
||||
cout << "evaluate {" << str1 << "} == " << val1;
|
||||
cout << str1 << " == " << val1;
|
||||
}
|
||||
cout << std::endl;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue