fix error reporting for a realpath(2) error
[ardour.git] / libs / ardour / test / load_session.cc
1 #include "test_util.h"
2 #include "pbd/failed_constructor.h"
3 #include "ardour/ardour.h"
4 #include "ardour/audioengine.h"
5 #include "ardour/session.h"
6 #include "midi++/manager.h"
7 #include <iostream>
8 #include <cstdlib>
9
10 using namespace std;
11 using namespace ARDOUR;
12
13 int main (int argc, char* argv[])
14 {
15         if (argc != 3) {
16                 cerr << "Syntax: " << argv[0] << " <dir> <snapshot-name>\n";
17                 exit (EXIT_FAILURE);
18         }
19
20         ARDOUR::init (false, true);
21
22         Session* s = 0;
23         
24         try {
25                 s = load_session (argv[1], argv[2]);
26         } catch (failed_constructor& e) {
27                 cerr << "failed_constructor: " << e.what() << "\n";
28                 exit (EXIT_FAILURE);
29         } catch (AudioEngine::PortRegistrationFailure& e) {
30                 cerr << "PortRegistrationFailure: " << e.what() << "\n";
31                 exit (EXIT_FAILURE);
32         } catch (exception& e) {
33                 cerr << "exception: " << e.what() << "\n";
34                 exit (EXIT_FAILURE);
35         } catch (...) {
36                 cerr << "unknown exception.\n";
37                 exit (EXIT_FAILURE);
38         }
39
40         AudioEngine::instance()->remove_session ();
41         delete s;
42         AudioEngine::instance()->stop (true);
43
44         MIDI::Manager::destroy ();
45         AudioEngine::destroy ();
46
47         return 0;
48 }