~ubuntu-branches/ubuntu/utopic/ardour3/utopic

« back to all changes in this revision

Viewing changes to libs/ardour/test/test_common.cc

  • Committer: Package Import Robot
  • Author(s): Felipe Sateler
  • Date: 2013-09-21 19:05:02 UTC
  • Revision ID: package-import@ubuntu.com-20130921190502-8gsftrku6jnzhd7v
Tags: upstream-3.4~dfsg
ImportĀ upstreamĀ versionĀ 3.4~dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    Copyright (C) 2011 Tim Mayberry
 
3
 
 
4
    This program is free software; you can redistribute it and/or modify it
 
5
    under the terms of the GNU General Public License as published by the Free
 
6
    Software Foundation; either version 2 of the License, or (at your option)
 
7
    any later version.
 
8
 
 
9
    This program is distributed in the hope that it will be useful, but WITHOUT
 
10
    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
11
    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 
12
    for more details.
 
13
 
 
14
    You should have received a copy of the GNU General Public License along
 
15
    with this program; if not, write to the Free Software Foundation, Inc.,
 
16
    675 Mass Ave, Cambridge, MA 02139, USA.
 
17
*/
 
18
 
 
19
#include <sstream>
 
20
 
 
21
#include <glibmm/fileutils.h>
 
22
#include <glibmm/miscutils.h>
 
23
 
 
24
#include "test_common.h"
 
25
 
 
26
using namespace std;
 
27
 
 
28
PBD::SearchPath
 
29
test_search_path ()
 
30
{
 
31
#ifdef WIN32
 
32
        std::string wsp(g_win32_get_package_installation_directory_of_module(NULL));
 
33
        return Glib::build_filename (wsp, "ardour_testdata");
 
34
#else
 
35
        return Glib::getenv("ARDOUR_TEST_PATH");
 
36
#endif
 
37
}
 
38
 
 
39
std::string
 
40
new_test_output_dir ()
 
41
{
 
42
        std::string tmp_dir = Glib::build_filename (g_get_tmp_dir(), "ardour_test");
 
43
        std::string dir_name;
 
44
        std::string new_test_dir;
 
45
        do {
 
46
                ostringstream oss;
 
47
                oss << g_random_int ();
 
48
                dir_name = oss.str();
 
49
                new_test_dir = Glib::build_filename (tmp_dir, dir_name);
 
50
                if (Glib::file_test (new_test_dir, Glib::FILE_TEST_EXISTS)) continue;
 
51
        } while (g_mkdir_with_parents (new_test_dir.c_str(), 0755) != 0);
 
52
        return new_test_dir;
 
53
}