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
This commit is contained in:
Tim Mayberry 2015-11-05 14:06:03 +10:00
parent 7f3118c8fe
commit 44f46d2b0d
6 changed files with 200 additions and 95 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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']) + '"',