From da85f65ec01ce50372f70393db7421d170754b10 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Tue, 27 Oct 2009 17:47:54 +0000 Subject: 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 --- libs/ardour/ardour/bbt_time.h | 11 ++++++++--- libs/ardour/ardour/tempo.h | 3 +++ libs/ardour/ardour/utils.h | 1 - libs/ardour/bbt_time.cc | 36 ------------------------------------ libs/ardour/run-tests.sh | 13 +++++++++---- libs/ardour/tempo.cc | 14 ++++++++++++++ libs/ardour/test/BBTTest.cpp | 2 ++ libs/ardour/test/testrunner.cpp | 5 +++++ libs/ardour/utils.cc | 7 ------- libs/ardour/wscript | 21 +++++++++++++++++---- 10 files changed, 58 insertions(+), 55 deletions(-) delete mode 100644 libs/ardour/bbt_time.cc (limited to 'libs/ardour') diff --git a/libs/ardour/ardour/bbt_time.h b/libs/ardour/ardour/bbt_time.h index 279427cf7a..44921ae6cc 100644 --- a/libs/ardour/ardour/bbt_time.h +++ b/libs/ardour/ardour/bbt_time.h @@ -20,6 +20,7 @@ #ifndef __ardour_bbt_time_h__ #define __ardour_bbt_time_h__ +#include #include 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__ */ diff --git a/libs/ardour/ardour/tempo.h b/libs/ardour/ardour/tempo.h index 147c6a64e6..d3c3a6340b 100644 --- a/libs/ardour/ardour/tempo.h +++ b/libs/ardour/ardour/tempo.h @@ -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 StateChanged; diff --git a/libs/ardour/ardour/utils.h b/libs/ardour/ardour/utils.h index e41c5f64ee..027e95dae8 100644 --- a/libs/ardour/ardour/utils.h +++ b/libs/ardour/ardour/utils.h @@ -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&); diff --git a/libs/ardour/bbt_time.cc b/libs/ardour/bbt_time.cc deleted file mode 100644 index a6e27d061f..0000000000 --- a/libs/ardour/bbt_time.cc +++ /dev/null @@ -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; -} - diff --git a/libs/ardour/run-tests.sh b/libs/ardour/run-tests.sh index 85ddfeaf81..9bcaca6f5c 100755 --- a/libs/ardour/run-tests.sh +++ b/libs/ardour/run-tests.sh @@ -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 + +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 -cd ../../build/default/libs/ardour -./run-tests +echo $LD_LIBRARY_PATH +./libs/ardour/run-tests diff --git a/libs/ardour/tempo.cc b/libs/ardour/tempo.cc index a79dc2eb41..094c507dea 100644 --- a/libs/ardour/tempo.cc +++ b/libs/ardour/tempo.cc @@ -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); +} diff --git a/libs/ardour/test/BBTTest.cpp b/libs/ardour/test/BBTTest.cpp index fb1637b124..ec32eaa81e 100644 --- a/libs/ardour/test/BBTTest.cpp +++ b/libs/ardour/test/BBTTest.cpp @@ -1,4 +1,5 @@ #include +#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 diff --git a/libs/ardour/test/testrunner.cpp b/libs/ardour/test/testrunner.cpp index 468af59ae4..b680843558 100644 --- a/libs/ardour/test/testrunner.cpp +++ b/libs/ardour/test/testrunner.cpp @@ -4,10 +4,15 @@ #include #include #include +#include "ardour/ardour.h" int main() { + Glib::thread_init (); + PBD::ID::init (); + ARDOUR::init (false, false); + CppUnit::TestResult testresult; CppUnit::TestResultCollector collectedresults; diff --git a/libs/ardour/utils.cc b/libs/ardour/utils.cc index f7a4e14316..abed926983 100644 --- a/libs/ardour/utils.cc +++ b/libs/ardour/utils.cc @@ -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) { diff --git a/libs/ardour/wscript b/libs/ardour/wscript index 57b2a6cdeb..ac6559f2b8 100644 --- a/libs/ardour/wscript +++ b/libs/ardour/wscript @@ -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() -- cgit v1.2.3