Update BBT_Time add and subtract interfaces (stubs, just for unit test building).
authorDavid Robillard <d@drobilla.net>
Tue, 27 Oct 2009 17:47:54 +0000 (17:47 +0000)
committerDavid Robillard <d@drobilla.net>
Tue, 27 Oct 2009 17:47:54 +0000 (17:47 +0000)
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
libs/ardour/ardour/tempo.h
libs/ardour/ardour/utils.h
libs/ardour/bbt_time.cc [deleted file]
libs/ardour/run-tests.sh
libs/ardour/tempo.cc
libs/ardour/test/BBTTest.cpp
libs/ardour/test/testrunner.cpp
libs/ardour/utils.cc
libs/ardour/wscript

index 279427cf7a4c82864195d36fcd84f14630cf65d0..44921ae6cc5745594008efcd6e45a56c88a2d4fc 100644 (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__ */
index 147c6a64e602af17657be1374c6b1f12e196b23f..d3c3a6340b2ce08a1699dd538c13f33acd7ab1c9 100644 (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;
index e41c5f64eeccae52fdc2b75e7f3a1397060f6c4b..027e95dae8b26b912c6b6833372f2455c53bf04d 100644 (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&);
diff --git a/libs/ardour/bbt_time.cc b/libs/ardour/bbt_time.cc
deleted file mode 100644 (file)
index a6e27d0..0000000
+++ /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;
-}
-
index 85ddfeaf812aa0646c8026e774bb79eb6b241f28..9bcaca6f5ccadd1864157003d86261d5eb5e112d 100755 (executable)
@@ -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
index a79dc2eb41896c571657d0607a1a38552f0126fd..094c507dea0210424e249b6e91c50335eae49860 100644 (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);
+}
index fb1637b124f0bc8a8a1d2254131573db4db661dd..ec32eaa81ece79113949c2e75f8bfd32148c89f3 100644 (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
index 468af59ae463ddb949195f0b13e3096fca41c382..b6808435581b78bd9578a432731de816534d5740 100644 (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;
index f7a4e1431604a68797c9872602811a44fbfbe3b7..abed9269830251df28d3196f9f7e7e50f7b8375a 100644 (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)
 {
index 57b2a6cdeb307c48ffbea3f5a168ab293c5da117..ac6559f2b8ddbe98b8812f7d3d5d22fc9b879831 100644 (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()