13
0

Update BBT_Time add and subtract interfaces (stubs, just for unit test building).

Build unit tests against libardour itself rather than compiling in bits.


git-svn-id: svn://localhost/ardour2/branches/3.0@5949 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
David Robillard 2009-10-27 17:47:54 +00:00
parent d51ce9ea71
commit da85f65ec0
10 changed files with 58 additions and 55 deletions

View File

@ -20,6 +20,7 @@
#ifndef __ardour_bbt_time_h__
#define __ardour_bbt_time_h__
#include <ostream>
#include <stdint.h>
namespace ARDOUR {
@ -49,11 +50,15 @@ struct BBT_Time {
bool operator== (const BBT_Time& other) const {
return bars == other.bars && beats == other.beats && ticks == other.ticks;
}
static bool add (BBT_Time& target, const BBT_Time& other, const TempoMetric& metric);
static bool subtract (BBT_Time& target, const BBT_Time& other, const TempoMetric& metric);
};
}
inline std::ostream&
operator<< (std::ostream& o, const ARDOUR::BBT_Time& bbt)
{
o << bbt.bars << '|' << bbt.beats << '|' << bbt.ticks;
return o;
}
#endif /* __ardour_bbt_time_h__ */

View File

@ -253,6 +253,9 @@ class TempoMap : public PBD::StatefulDestructible
int n_tempos () const;
int n_meters () const;
BBT_Time bbt_add (const BBT_Time& a, const BBT_Time& b, const TempoMetric& metric);
BBT_Time bbt_subtract (const BBT_Time& a, const BBT_Time& b);
nframes_t frame_rate () const { return _frame_rate; }
sigc::signal<void,ARDOUR::Change> StateChanged;

View File

@ -37,7 +37,6 @@
class XMLNode;
Glib::ustring legalize_for_path (Glib::ustring str);
std::ostream& operator<< (std::ostream& o, const ARDOUR::BBT_Time& bbt);
XMLNode* find_named_node (const XMLNode& node, std::string name);
std::string bool_as_string (bool);
bool string_is_affirmative (const std::string&);

View File

@ -1,36 +0,0 @@
/*
Copyright (C) 2009 Paul Davis
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "ardour/bbt_time.h"
#include "ardour/tempo.h"
using namespace ARDOUR;
bool
BBT_Time::add (BBT_Time& target, const BBT_Time& other, const TempoMetric& metric)
{
return true;
}
bool
BBT_Time::subtract (BBT_Time& target, const BBT_Time& other, const TempoMetric& metric)
{
return true;
}

View File

@ -1,11 +1,16 @@
#!/bin/sh
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:../../build/default/libs/ardour
if [ ! -f './bbt_time.cc' ]; then
if [ ! -f './tempo.cc' ]; then
echo "This script must be run from within the libs/ardour directory";
exit 1;
fi
srcdir=`pwd`
cd ../../build/default
cd ../../build/default/libs/ardour
./run-tests
libs='libs'
export LD_LIBRARY_PATH=$libs/vamp-sdk:$libs/surfaces:$libs/surfaces/control_protocol:$libs/ardour:$libs/midi++2:$libs/pbd:$libs/rubberband:$libs/soundtouch:$libs/gtkmm2ext:$libs/sigc++2:$libs/glibmm2:$libs/gtkmm2/atk:$libs/gtkmm2/pango:$libs/gtkmm2/gdk:$libs/gtkmm2/gtk:$libs/libgnomecanvasmm:$libs/libsndfile:$libs/appleutility:$libs/cairomm:$libs/taglib:$libs/evoral:$libs/evoral/src/libsmf:$LD_LIBRARY_PATH
echo $LD_LIBRARY_PATH
./libs/ardour/run-tests

View File

@ -1616,3 +1616,17 @@ TempoMap::insert_time (nframes_t where, nframes_t amount)
StateChanged (Change (0));
}
BBT_Time
TempoMap::bbt_add (const BBT_Time& a, const BBT_Time& b, const TempoMetric& /*metric*/)
{
// FIXME: Obviously not correct!
return BBT_Time(a.bars + b.bars, a.beats + b.beats, a.ticks + b.ticks);
}
BBT_Time
TempoMap::bbt_subtract (const BBT_Time& a, const BBT_Time& b)
{
// FIXME: Obviously not correct!
return BBT_Time(a.bars - b.bars, a.beats - b.beats, a.ticks - b.ticks);
}

View File

@ -1,4 +1,5 @@
#include <cassert>
#include "ardour/tempo.h"
#include "BBTTest.hpp"
CPPUNIT_TEST_SUITE_REGISTRATION(BBTTest);
@ -9,6 +10,7 @@ using namespace ARDOUR;
void
BBTTest::addTest ()
{
TempoMap map(48000);
}
void

View File

@ -4,10 +4,15 @@
#include <cppunit/TestResultCollector.h>
#include <cppunit/TestRunner.h>
#include <cppunit/BriefTestProgressListener.h>
#include "ardour/ardour.h"
int
main()
{
Glib::thread_init ();
PBD::ID::init ();
ARDOUR::init (false, false);
CppUnit::TestResult testresult;
CppUnit::TestResultCollector collectedresults;

View File

@ -111,13 +111,6 @@ string bump_name_once(std::string name)
}
ostream&
operator<< (ostream& o, const BBT_Time& bbt)
{
o << bbt.bars << '|' << bbt.beats << '|' << bbt.ticks;
return o;
}
XMLNode *
find_named_node (const XMLNode& node, string name)
{

View File

@ -55,7 +55,6 @@ libardour_sources = [
'automation.cc',
'automation_control.cc',
'automation_list.cc',
'bbt_time.cc',
'beats_frames_converter.cc',
'broadcast_info.cc',
'buffer.cc',
@ -316,16 +315,30 @@ def build(bld):
# Unit tests
testobj = bld.new_task_gen('cxx', 'program')
testobj.source = '''
interpolation.cc
test/BBTTest.cpp
test/InterpolationTest.cpp
test/testrunner.cpp
'''
'''.split()
testobj.includes = obj.includes + ['../pbd/']
testobj.uselib = 'CPPUNIT SIGCPP JACK GLIBMM SAMPLERATE'
testobj.uselib = 'CPPUNIT SIGCPP JACK GLIBMM SAMPLERATE XML LRDF'
testobj.uselib_local = 'libpbd libmidipp libardour'
testobj.name = 'libardour-tests'
testobj.target = 'run-tests'
testobj.install_path = ''
testobj.cxxflags = ['-DPACKAGE="libardour3test"']
testobj.cxxflags += ['-DDATA_DIR="' + os.path.normpath(bld.env['DATADIR']) + '"']
testobj.cxxflags += ['-DCONFIG_DIR="' + os.path.normpath(bld.env['CONFIGDIR']) + '"']
testobj.cxxflags += ['-DMODULE_DIR="' + os.path.normpath(bld.env['LIBDIR']) + '"']
testobj.cxxflags += ['-DLOCALEDIR="' + os.path.join(
os.path.normpath(bld.env['DATADIR']), 'locale') + '"']
testobj.cxxflags += ['-DVAMP_DIR="' + os.path.join(
os.path.normpath(bld.env['LIBDIR']), 'ardour3', 'vamp') + '"']
if bld.env['FPU_OPTIMIZATION']:
testobj.source += [ 'sse_functions_xmm.cc' ]
if bld.env['build_target'] == 'i386' or bld.env['build_target'] == 'i686':
testobj.source += [ 'sse_functions.s' ]
elif bld.env['build_target'] == 'x86_64':
testobj.source += [ 'sse_functions_64bit.s' ]
def shutdown():
autowaf.shutdown()