summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Mayberry <mojofunk@gmail.com>2015-11-05 14:06:03 +1000
committerTim Mayberry <mojofunk@gmail.com>2015-12-01 15:44:10 +1000
commit44f46d2b0dd0ef0265b823d0126857ec4458345b (patch)
treea53c2e407b3db86d88975df39777826965229bfb
parent7f3118c8fe651c722b48ed3d9f47f998507237be (diff)
Fix broken load-session utility and change it to load and save a session
Rename run-session-tests.sh script to load-save-session.sh and make it operate on only a single session and add a separate load-save-session-collection.sh script Add --massif option to load-save-session.sh script Rename some poorly named variables and add some documentation to the load-save-session.sh script
-rwxr-xr-xlibs/ardour/load-save-session-collection.sh18
-rwxr-xr-xlibs/ardour/load-save-session.sh48
-rwxr-xr-xlibs/ardour/run-session-tests.sh35
-rw-r--r--libs/ardour/test/load_save_session.cc121
-rw-r--r--libs/ardour/test/load_session.cc48
-rw-r--r--libs/ardour/wscript25
6 files changed, 200 insertions, 95 deletions
diff --git a/libs/ardour/load-save-session-collection.sh b/libs/ardour/load-save-session-collection.sh
new file mode 100755
index 0000000000..ee2957f65f
--- /dev/null
+++ b/libs/ardour/load-save-session-collection.sh
@@ -0,0 +1,18 @@
+#!/bin/bash
+#
+# This script will run the load-save-session.sh script over each session in a
+# directory containing session directories.
+#
+# This script only supports the default option of the load-save-session.sh
+# script, so no valgind or gdb options as it isn't useful on more than a single
+# session at a time, use load-save-session.sh directly for that.
+
+DIR_PATH=$1
+if [ "$DIR_PATH" == "" ]; then
+ echo "Syntax: load-save-session-collection.sh <session collection dir>"
+ exit 1
+fi
+
+for SESSION_DIR in `find $DIR_PATH -mindepth 1 -maxdepth 1 -type d`; do
+ ./load-save-session.sh $SESSION_DIR
+done
diff --git a/libs/ardour/load-save-session.sh b/libs/ardour/load-save-session.sh
new file mode 100755
index 0000000000..cfa1ef5b68
--- /dev/null
+++ b/libs/ardour/load-save-session.sh
@@ -0,0 +1,48 @@
+#!/bin/bash
+#
+# Run load-save-session utility program on an existing session, as the session
+# may be modified I would not use this utility on a session that you care
+# about.
+#
+# The utility outputs some basic timing information and can be used to look at
+# changes in the Session file resulting from the save if for instance the
+# session is contained in a git repository.
+#
+
+TOP=`dirname "$0"`/../..
+. $TOP/build/gtk2_ardour/ardev_common_waf.sh
+ARDOUR_LIBS_DIR=$TOP/build/libs/ardour
+PROGRAM_NAME=load-save-session
+
+if [ ! -f './tempo.cc' ];
+ then echo "This script must be run from within the libs/ardour directory";
+ exit 1;
+fi
+
+OPTION=""
+if [ "$1" == "--debug" -o "$1" == "--valgrind" -o "$1" == "--massif" ]; then
+ OPTION=$1
+ shift 1
+fi
+
+DIR_PATH=$1
+if [ "$DIR_PATH" == "" ]; then
+ echo "Syntax: load-save-session.sh <session dir>"
+ exit 1
+fi
+
+NAME=`basename $DIR_PATH`
+
+if [ "$OPTION" == "--debug" ]; then
+ gdb --args $ARDOUR_LIBS_DIR/$PROGRAM_NAME $DIR_PATH $NAME
+elif [ "$OPTION" == "--valgrind" ]; then
+ MEMCHECK_OPTIONS="--leak-check=full"
+ valgrind $MEMCHECK_OPTIONS \
+ $ARDOUR_LIBS_DIR/$PROGRAM_NAME $DIR_PATH $NAME
+elif [ "$OPTION" == "--massif" ]; then
+ MASSIF_OPTIONS="--time-unit=ms --massif-out-file=massif.out.$NAME"
+ valgrind --tool=massif $MASSIF_OPTIONS \
+ $ARDOUR_LIBS_DIR/$PROGRAM_NAME $DIR_PATH $NAME
+else
+ $ARDOUR_LIBS_DIR/$PROGRAM_NAME $DIR_PATH $NAME
+fi
diff --git a/libs/ardour/run-session-tests.sh b/libs/ardour/run-session-tests.sh
deleted file mode 100755
index 034f8b5a7f..0000000000
--- a/libs/ardour/run-session-tests.sh
+++ /dev/null
@@ -1,35 +0,0 @@
-#!/bin/bash
-#
-# Run simple session load tester over a corpus of sessions.
-#
-
-if [ ! -f './tempo.cc' ]; then
- echo "This script must be run from within the libs/ardour directory";
- exit 1;
-fi
-
-. test-env.sh
-
-f=""
-if [ "$1" == "--debug" -o "$1" == "--valgrind" ]; then
- f=$1
- shift 1
-fi
-
-d=$1
-if [ "$d" == "" ]; then
- echo "Syntax: run-session-tests.sh <corpus>"
- exit 1
-fi
-
-for s in `find $d -mindepth 1 -maxdepth 1 -type d`; do
- n=`basename $s`
- if [ "$f" == "--debug" ]; then
- gdb --args ./libs/ardour/load-session $s $n
- elif [ "$f" == "--valgrind" ]; then
- valgrind ./libs/ardour/load-session $s $n
- else
- ./libs/ardour/load-session $s $n
- fi
-done
-
diff --git a/libs/ardour/test/load_save_session.cc b/libs/ardour/test/load_save_session.cc
new file mode 100644
index 0000000000..ab4573c883
--- /dev/null
+++ b/libs/ardour/test/load_save_session.cc
@@ -0,0 +1,121 @@
+#include "test_util.h"
+
+#include <iostream>
+#include <cstdlib>
+
+#include <glib.h>
+
+#include "pbd/failed_constructor.h"
+#include "pbd/timing.h"
+
+#include "ardour/ardour.h"
+#include "ardour/audioengine.h"
+#include "ardour/session.h"
+
+#include "test_ui.h"
+
+using namespace std;
+using namespace ARDOUR;
+
+static const char* localedir = LOCALEDIR;
+
+static const int sleep_seconds = 2;
+
+static
+void
+pause_for_effect()
+{
+ // It may be useful to pause to make it easier to see what is happening in a
+ // visual tool like massif visualizer
+
+ std::cerr << "pausing for " << sleep_seconds << " seconds" << std::endl;
+
+ g_usleep(sleep_seconds*1000000);
+}
+
+int main (int argc, char* argv[])
+{
+ if (argc != 3) {
+ cerr << "Syntax: " << argv[0] << " <dir> <snapshot-name>\n";
+ exit (EXIT_FAILURE);
+ }
+
+ std::cerr << "ARDOUR::init" << std::endl;
+
+ PBD::Timing ardour_init_timing;
+
+ ARDOUR::init (false, true, localedir);
+ ardour_init_timing.update();
+
+ TestUI* test_ui = new TestUI();
+
+ std::cerr << "ARDOUR::init time : " << ardour_init_timing.elapsed()
+ << " usecs" << std::endl;
+
+ std::cerr << "Creating Dummy backend" << std::endl;
+
+ create_and_start_dummy_backend ();
+
+ std::cerr << "Loading session: " << argv[2] << std::endl;
+
+ PBD::Timing load_session_timing;
+
+ Session* s = 0;
+
+ try {
+ s = load_session (argv[1], argv[2]);
+ } catch (failed_constructor& e) {
+ cerr << "failed_constructor: " << e.what() << "\n";
+ exit (EXIT_FAILURE);
+ } catch (AudioEngine::PortRegistrationFailure& e) {
+ cerr << "PortRegistrationFailure: " << e.what() << "\n";
+ exit (EXIT_FAILURE);
+ } catch (exception& e) {
+ cerr << "exception: " << e.what() << "\n";
+ exit (EXIT_FAILURE);
+ } catch (...) {
+ cerr << "unknown exception.\n";
+ exit (EXIT_FAILURE);
+ }
+
+ load_session_timing.update();
+
+ std::cerr << "Loading session time : " << load_session_timing.elapsed()
+ << " usecs" << std::endl;
+
+ PBD::Timing save_session_timing;
+
+ pause_for_effect ();
+
+ std::cerr << "Saving session: " << argv[2] << std::endl;
+
+ s->save_state("");
+
+ save_session_timing.update();
+
+ std::cerr << "Saving session time : " << save_session_timing.elapsed()
+ << " usecs" << std::endl;
+
+ std::cerr << "AudioEngine::remove_session" << std::endl;
+
+ AudioEngine::instance()->remove_session ();
+
+ PBD::Timing destroy_session_timing;
+
+ delete s;
+
+ destroy_session_timing.update();
+
+ std::cerr << "Destroy session time : " << destroy_session_timing.elapsed()
+ << " usecs" << std::endl;
+
+ AudioEngine::instance()->stop ();
+
+ AudioEngine::destroy ();
+
+ delete test_ui;
+
+ ARDOUR::cleanup ();
+
+ return 0;
+}
diff --git a/libs/ardour/test/load_session.cc b/libs/ardour/test/load_session.cc
deleted file mode 100644
index 41dc48ef2f..0000000000
--- a/libs/ardour/test/load_session.cc
+++ /dev/null
@@ -1,48 +0,0 @@
-#include "test_util.h"
-#include "pbd/failed_constructor.h"
-#include "ardour/ardour.h"
-#include "ardour/audioengine.h"
-#include "ardour/session.h"
-#include <iostream>
-#include <cstdlib>
-
-using namespace std;
-using namespace ARDOUR;
-
-static const char* localedir = LOCALEDIR;
-
-int main (int argc, char* argv[])
-{
- if (argc != 3) {
- cerr << "Syntax: " << argv[0] << " <dir> <snapshot-name>\n";
- exit (EXIT_FAILURE);
- }
-
- ARDOUR::init (false, true, localedir);
-
- Session* s = 0;
-
- try {
- s = load_session (argv[1], argv[2]);
- } catch (failed_constructor& e) {
- cerr << "failed_constructor: " << e.what() << "\n";
- exit (EXIT_FAILURE);
- } catch (AudioEngine::PortRegistrationFailure& e) {
- cerr << "PortRegistrationFailure: " << e.what() << "\n";
- exit (EXIT_FAILURE);
- } catch (exception& e) {
- cerr << "exception: " << e.what() << "\n";
- exit (EXIT_FAILURE);
- } catch (...) {
- cerr << "unknown exception.\n";
- exit (EXIT_FAILURE);
- }
-
- AudioEngine::instance()->remove_session ();
- delete s;
- AudioEngine::instance()->stop ();
-
- AudioEngine::destroy ();
-
- return 0;
-}
diff --git a/libs/ardour/wscript b/libs/ardour/wscript
index ee84e39b79..c5cd78325d 100644
--- a/libs/ardour/wscript
+++ b/libs/ardour/wscript
@@ -527,23 +527,24 @@ def build(bld):
create_ardour_test_program(bld, obj.includes, 'libardour-tests', 'run-tests', test_sources)
- # Tester to just load a session
- session_load_tester = bld(features = 'cxx cxxprogram')
- session_load_tester.source = '''
+ # Utility to load and save a session
+ load_save_session = bld(features = 'cxx cxxprogram')
+ load_save_session.source = '''
test/test_util.cc
- test/load_session.cc
+ test/test_ui.cc
+ test/load_save_session.cc
test/dummy_lxvst.cc
'''.split()
- session_load_tester.includes = obj.includes
- session_load_tester.includes.append ('test')
- session_load_tester.uselib = ['CPPUNIT','SIGCPP','GLIBMM','GTHREAD',
+ load_save_session.includes = obj.includes
+ load_save_session.includes.append ('test')
+ load_save_session.uselib = ['CPPUNIT','SIGCPP','GLIBMM','GTHREAD',
'SAMPLERATE','XML','LRDF','COREAUDIO']
- session_load_tester.use = ['libpbd','libmidipp','libardour']
- session_load_tester.name = 'libardour-session-load-tester'
- session_load_tester.target = 'load-session'
- session_load_tester.install_path = ''
- session_load_tester.defines = [
+ load_save_session.use = ['libpbd','libmidipp','libardour']
+ load_save_session.name = 'libardour-load-save-session'
+ load_save_session.target = 'load-save-session'
+ load_save_session.install_path = ''
+ load_save_session.defines = [
'PACKAGE="libardour' + str(bld.env['MAJOR']) + 'profile"',
'DATA_DIR="' + os.path.normpath(bld.env['DATADIR']) + '"',
'CONFIG_DIR="' + os.path.normpath(bld.env['SYSCONFDIR']) + '"',