From 82c536ec81d7d20780c502163f851e102c6de073 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Fri, 16 Jul 2021 14:52:54 +0200 Subject: [PATCH] Fix test/profiling tools * use dummy-backend (don't expect engine to be running) * add required TestUI / Receiver Lots of regions: add scope to prevent SessionHandleRef existing across session deletion RunPC: take process-lock before processing, prevents various assert() and concurrency issues. --- libs/ardour/test/profiling/load_session.cc | 7 +++++-- libs/ardour/test/profiling/lots_of_regions.cc | 13 +++++++++++++ libs/ardour/test/profiling/runpc.cc | 14 ++++++++++++-- .../test/profiling/sessions/1region/instant.xml | 1 + libs/ardour/wscript | 1 + 5 files changed, 32 insertions(+), 4 deletions(-) diff --git a/libs/ardour/test/profiling/load_session.cc b/libs/ardour/test/profiling/load_session.cc index 41dc48ef2f..1a673762c0 100644 --- a/libs/ardour/test/profiling/load_session.cc +++ b/libs/ardour/test/profiling/load_session.cc @@ -1,3 +1,4 @@ +#include "test_ui.h" #include "test_util.h" #include "pbd/failed_constructor.h" #include "ardour/ardour.h" @@ -19,6 +20,8 @@ int main (int argc, char* argv[]) } ARDOUR::init (false, true, localedir); + TestUI* test_ui = new TestUI(); + create_and_start_dummy_backend (); Session* s = 0; @@ -41,8 +44,8 @@ int main (int argc, char* argv[]) AudioEngine::instance()->remove_session (); delete s; AudioEngine::instance()->stop (); - AudioEngine::destroy (); - + delete test_ui; + ARDOUR::cleanup (); return 0; } diff --git a/libs/ardour/test/profiling/lots_of_regions.cc b/libs/ardour/test/profiling/lots_of_regions.cc index afad346232..47c8376b79 100644 --- a/libs/ardour/test/profiling/lots_of_regions.cc +++ b/libs/ardour/test/profiling/lots_of_regions.cc @@ -1,3 +1,4 @@ +#include "test_ui.h" #include "test_util.h" #include "ardour/ardour.h" #include "ardour/midi_track.h" @@ -16,10 +17,14 @@ int main (int argc, char* argv[]) { ARDOUR::init (false, true, localedir); + TestUI* test_ui = new TestUI(); + create_and_start_dummy_backend (); Session* session = load_session ("../libs/ardour/test/profiling/sessions/1region", "1region"); assert (session->get_routes()->size() == 2); + { + /* Find the track */ boost::shared_ptr track = boost::dynamic_pointer_cast (session->get_routes()->back()); assert (track); @@ -48,4 +53,12 @@ main (int argc, char* argv[]) playlist->duplicate (region, region->last_sample() + 1, 1000); session->add_command (new StatefulDiffCommand (playlist)); session->commit_reversible_command (); + + } + + delete session; + stop_and_destroy_backend (); + delete test_ui; + ARDOUR::cleanup (); + return 0; } diff --git a/libs/ardour/test/profiling/runpc.cc b/libs/ardour/test/profiling/runpc.cc index 6538fcf88a..8bf054653e 100644 --- a/libs/ardour/test/profiling/runpc.cc +++ b/libs/ardour/test/profiling/runpc.cc @@ -4,6 +4,7 @@ #include "pbd/enumwriter.h" #include "ardour/session.h" #include "ardour/audioengine.h" +#include "test_ui.h" #include "test_util.h" using namespace std; @@ -21,6 +22,8 @@ main (int argc, char* argv[]) } ARDOUR::init (false, true, localedir); + TestUI* test_ui = new TestUI(); + create_and_start_dummy_backend (); Session* session = load_session ( string_compose ("../libs/ardour/test/profiling/sessions/%1", argv[1]), @@ -29,9 +32,16 @@ main (int argc, char* argv[]) cout << "INFO: " << session->get_routes()->size() << " routes.\n"; - for (int i = 0; i < 32768; ++i) { - session->process (session->engine().samples_per_cycle ()); + { + Glib::Threads::Mutex::Lock lm (AudioEngine::instance ()->process_lock ()); + for (int i = 0; i < 32768; ++i) { + session->process (session->engine().samples_per_cycle ()); + } } + delete session; + stop_and_destroy_backend (); + delete test_ui; + ARDOUR::cleanup (); return 0; } diff --git a/libs/ardour/test/profiling/sessions/1region/instant.xml b/libs/ardour/test/profiling/sessions/1region/instant.xml index 5f0c8e83dd..735d83f0db 100644 --- a/libs/ardour/test/profiling/sessions/1region/instant.xml +++ b/libs/ardour/test/profiling/sessions/1region/instant.xml @@ -10,4 +10,5 @@ + diff --git a/libs/ardour/wscript b/libs/ardour/wscript index 9c63a57995..f9717f072c 100644 --- a/libs/ardour/wscript +++ b/libs/ardour/wscript @@ -660,6 +660,7 @@ def build(bld): profilingobj.source = ''' test/dummy_lxvst.cc test/test_util.cc + test/test_ui.cc '''.split() profilingobj.source.append('test/profiling/%s.cc' % p)