Make glass the default backend
[xapian.git] / xapian-core / tests / harness / backendmanager_remoteprog.cc
blob321345682da82b5a779c06eddfa36950277e308e
1 /** @file backendmanager_remoteprog.cc
2 * @brief BackendManager subclass for remoteprog databases.
3 */
4 /* Copyright (C) 2007,2008,2009 Olly Betts
5 * Copyright (C) 2008 Lemur Consulting Ltd
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #include <config.h>
24 #include "backendmanager_remoteprog.h"
26 #include <xapian.h>
28 #ifdef HAVE_VALGRIND
29 # include <valgrind/memcheck.h>
30 #endif
32 using namespace std;
34 std::string
35 BackendManagerRemoteProg::get_dbtype() const
37 return "remoteprog_" + remote_type;
40 Xapian::Database
41 BackendManagerRemoteProg::do_get_database(const vector<string> & files)
43 // Default to a long (5 minute) timeout so that tests won't fail just
44 // because the host is slow or busy.
45 return BackendManagerRemoteProg::get_remote_database(files, 300000);
48 Xapian::WritableDatabase
49 BackendManagerRemoteProg::get_writable_database(const string & name,
50 const string & file)
52 string args = get_writable_database_args(name, file);
54 #ifdef HAVE_VALGRIND
55 if (RUNNING_ON_VALGRIND) {
56 args.insert(0, XAPIAN_PROGSRV" ");
57 return Xapian::Remote::open_writable("./runsrv", args);
59 #endif
60 return Xapian::Remote::open_writable(XAPIAN_PROGSRV, args);
63 Xapian::Database
64 BackendManagerRemoteProg::get_remote_database(const vector<string> & files,
65 unsigned int timeout)
67 string args = get_remote_database_args(files, timeout);
69 #ifdef HAVE_VALGRIND
70 if (RUNNING_ON_VALGRIND) {
71 args.insert(0, XAPIAN_PROGSRV" ");
72 return Xapian::Remote::open("./runsrv", args);
74 #endif
75 return Xapian::Remote::open(XAPIAN_PROGSRV, args);
78 Xapian::Database
79 BackendManagerRemoteProg::get_writable_database_as_database()
81 string args = get_writable_database_as_database_args();
83 #ifdef HAVE_VALGRIND
84 if (RUNNING_ON_VALGRIND) {
85 args.insert(0, XAPIAN_PROGSRV" ");
86 return Xapian::Remote::open("./runsrv", args);
88 #endif
89 return Xapian::Remote::open(XAPIAN_PROGSRV, args);
92 Xapian::WritableDatabase
93 BackendManagerRemoteProg::get_writable_database_again()
95 string args = get_writable_database_again_args();
97 #ifdef HAVE_VALGRIND
98 if (RUNNING_ON_VALGRIND) {
99 args.insert(0, XAPIAN_PROGSRV" ");
100 return Xapian::Remote::open_writable("./runsrv", args);
102 #endif
103 return Xapian::Remote::open_writable(XAPIAN_PROGSRV, args);