Unit-tests to check Lua session+DSP scripts
This commit is contained in:
parent
2eb58913e8
commit
99e9382cdb
|
@ -0,0 +1,81 @@
|
|||
#include <list>
|
||||
#include <glibmm.h>
|
||||
|
||||
#include "ardour/audio_track.h"
|
||||
#include "ardour/audioengine.h"
|
||||
#include "ardour/luascripting.h"
|
||||
#include "ardour/lua_script_params.h"
|
||||
#include "ardour/plugin_manager.h"
|
||||
#include "ardour/plugin_insert.h"
|
||||
#include "ardour/session.h"
|
||||
|
||||
#include "lua_script_test.h"
|
||||
|
||||
using namespace ARDOUR;
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(LuaScriptTest);
|
||||
|
||||
void
|
||||
LuaScriptTest::session_script_test ()
|
||||
{
|
||||
LuaScriptList scripts (LuaScripting::instance ().scripts (LuaScriptInfo::Session));
|
||||
printf("\n * Testing %ld Lua session scripts\n", scripts.size());
|
||||
|
||||
for (LuaScriptList::const_iterator s = scripts.begin(); s != scripts.end(); ++s) {
|
||||
const LuaScriptInfoPtr& spi (*s);
|
||||
|
||||
std::string script = "";
|
||||
|
||||
try {
|
||||
script = Glib::file_get_contents (spi->path);
|
||||
} catch (Glib::FileError e) {
|
||||
CPPUNIT_FAIL ("Cannot read script file");
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
LuaScriptParamList lsp = LuaScriptParams::script_params (spi, "sess_params");
|
||||
_session->register_lua_function ("test", script, lsp);
|
||||
} catch (SessionException e) {
|
||||
CPPUNIT_FAIL ("Cannot add script to session");
|
||||
continue;
|
||||
}
|
||||
CPPUNIT_ASSERT (!_session->registered_lua_functions ().empty());
|
||||
Glib::usleep(200000); // wait to script to execute during process()
|
||||
// if the script fails, it'll be removed.
|
||||
CPPUNIT_ASSERT (!_session->registered_lua_functions ().empty());
|
||||
_session->unregister_lua_function ("test");
|
||||
CPPUNIT_ASSERT (_session->registered_lua_functions ().empty());
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
LuaScriptTest::dsp_script_test ()
|
||||
{
|
||||
PluginManager& pm = PluginManager::instance ();
|
||||
std::list<boost::shared_ptr<AudioTrack> > tracks;
|
||||
|
||||
tracks = _session->new_audio_track (2, 2, NULL, 1, "", PresentationInfo::max_order);
|
||||
CPPUNIT_ASSERT (tracks.size() == 1);
|
||||
boost::shared_ptr<Route> r = tracks.front ();
|
||||
|
||||
std::cout << "\n";
|
||||
const PluginInfoList& plugs = pm.lua_plugin_info();
|
||||
for (PluginInfoList::const_iterator i = plugs.begin(); i != plugs.end(); ++i) {
|
||||
std::cout << "LuaProc: " <<(*i)->name << "\n";
|
||||
|
||||
PluginPtr p = (*i)->load (*_session);
|
||||
CPPUNIT_ASSERT (p);
|
||||
|
||||
boost::shared_ptr<Processor> processor (new PluginInsert (*_session, p));
|
||||
processor->enable (true);
|
||||
|
||||
int rv = r->add_processor (processor, boost::shared_ptr<Processor>(), 0);
|
||||
CPPUNIT_ASSERT (rv == 0);
|
||||
processor->enable (true);
|
||||
Glib::usleep(200000); // run process, failing plugins will be deactivated.
|
||||
CPPUNIT_ASSERT (processor->active());
|
||||
rv = r->remove_processor (processor, NULL, true);
|
||||
CPPUNIT_ASSERT (rv == 0);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
#include <boost/shared_ptr.hpp>
|
||||
#include "test_needing_session.h"
|
||||
|
||||
class LuaScriptTest : public TestNeedingSession
|
||||
{
|
||||
CPPUNIT_TEST_SUITE (LuaScriptTest);
|
||||
CPPUNIT_TEST (session_script_test);
|
||||
CPPUNIT_TEST (dsp_script_test);
|
||||
CPPUNIT_TEST_SUITE_END ();
|
||||
|
||||
public:
|
||||
void session_script_test ();
|
||||
void dsp_script_test ();
|
||||
};
|
|
@ -516,6 +516,7 @@ def build(bld):
|
|||
create_ardour_test_program(bld, obj.includes, 'bbt', 'test_bbt', ['test/bbt_test.cc'])
|
||||
create_ardour_test_program(bld, obj.includes, 'tempo', 'test_tempo', ['test/tempo_test.cc'])
|
||||
create_ardour_test_program(bld, obj.includes, 'interpolation', 'test_interpolation', ['test/interpolation_test.cc'])
|
||||
create_ardour_test_program(bld, obj.includes, 'lua_script', 'test_lua_script', ['test/lua_script_test.cc'])
|
||||
create_ardour_test_program(bld, obj.includes, 'midi_clock_slave', 'test_midi_clock_slave', ['test/midi_clock_slave_test.cc'])
|
||||
create_ardour_test_program(bld, obj.includes, 'resampled_source', 'test_resampled_source', ['test/resampled_source_test.cc'])
|
||||
create_ardour_test_program(bld, obj.includes, 'framewalk_to_beats', 'test_framewalk_to_beats', ['test/framewalk_to_beats_test.cc'])
|
||||
|
@ -537,6 +538,7 @@ def build(bld):
|
|||
test/dsp_load_calculator_test.cc
|
||||
test/tempo_test.cc
|
||||
test/interpolation_test.cc
|
||||
test/lua_script_test.cc
|
||||
test/midi_clock_slave_test.cc
|
||||
test/resampled_source_test.cc
|
||||
test/framewalk_to_beats_test.cc
|
||||
|
|
Loading…
Reference in New Issue