tests/harness/backendmanager_remoteprog.cc

Go to the documentation of this file.
00001 
00004 /* Copyright (C) 2007 Olly Betts
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License as
00008  * published by the Free Software Foundation; either version 2 of the
00009  * License, or (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00019  */
00020 
00021 #include <config.h>
00022 
00023 #include "backendmanager_remoteprog.h"
00024 
00025 #include <xapian.h>
00026 
00027 #include "utils.h"
00028 
00029 #ifdef HAVE_VALGRIND
00030 # include <valgrind/memcheck.h>
00031 #endif
00032 
00033 using namespace std;
00034 
00035 BackendManagerRemoteProg::~BackendManagerRemoteProg() { }
00036 
00037 const char *
00038 BackendManagerRemoteProg::get_dbtype() const
00039 {
00040     return "remoteprog";
00041 }
00042 
00043 Xapian::Database
00044 BackendManagerRemoteProg::get_database(const vector<string> & files)
00045 {
00046     // Default to a long (5 minute) timeout so that tests won't fail just
00047     // because the host is slow or busy.
00048     return BackendManagerRemoteProg::get_remote_database(files, 300000);
00049 }
00050 
00051 Xapian::Database
00052 BackendManagerRemoteProg::get_database(const string & file)
00053 {
00054     return BackendManagerRemoteProg::get_database(vector<string>(1, file));
00055 }
00056 
00057 Xapian::WritableDatabase
00058 BackendManagerRemoteProg::get_writable_database(const string & name,
00059                                                 const string & file)
00060 {
00061     last_wdb_name = name;
00062 
00063     vector<string> files(1, file);
00064     // Default to a long (5 minute) timeout so that tests won't fail just
00065     // because the host is slow or busy.
00066     string args = "-t300000 --writable ";
00067 
00068 #ifdef XAPIAN_HAS_FLINT_BACKEND
00069     (void)getwritedb_flint(name, files);
00070     args += ".flint/";
00071 #else
00072     (void)getwritedb_quartz(name, files);
00073     args += ".quartz/";
00074 #endif
00075     args += name;
00076 
00077 #ifdef HAVE_VALGRIND
00078     if (RUNNING_ON_VALGRIND) {
00079         args.insert(0, XAPIAN_PROGSRV" ");
00080         return Xapian::Remote::open_writable("./runsrv", args);
00081     }
00082 #endif
00083     return Xapian::Remote::open_writable(XAPIAN_PROGSRV, args);
00084 }
00085 
00086 Xapian::Database
00087 BackendManagerRemoteProg::get_remote_database(const vector<string> & files,
00088                                               unsigned int timeout)
00089 {
00090     string args = "-t";
00091     args += om_tostring(timeout);
00092     args += ' ';
00093 #ifdef XAPIAN_HAS_FLINT_BACKEND
00094     args += createdb_flint(files);
00095 #else
00096     args += createdb_quartz(files);
00097 #endif
00098 #ifdef HAVE_VALGRIND
00099     if (RUNNING_ON_VALGRIND) {
00100         args.insert(0, XAPIAN_PROGSRV" ");
00101         return Xapian::Remote::open("./runsrv", args);
00102     }
00103 #endif
00104     return Xapian::Remote::open(XAPIAN_PROGSRV, args);
00105 }
00106 
00107 Xapian::Database
00108 BackendManagerRemoteProg::get_writable_database_as_database()
00109 {
00110     string args = "-t300000 ";
00111 #ifdef XAPIAN_HAS_FLINT_BACKEND
00112     args += ".flint/";
00113 #else
00114     args += ".quartz/";
00115 #endif
00116     args += last_wdb_name;
00117 
00118 #ifdef HAVE_VALGRIND
00119     if (RUNNING_ON_VALGRIND) {
00120         args.insert(0, XAPIAN_PROGSRV" ");
00121         return Xapian::Remote::open("./runsrv", args);
00122     }
00123 #endif
00124     return Xapian::Remote::open(XAPIAN_PROGSRV, args);
00125 }
00126 
00127 Xapian::WritableDatabase
00128 BackendManagerRemoteProg::get_writable_database_again()
00129 {
00130     string args = "-t300000 --writable ";
00131 #ifdef XAPIAN_HAS_FLINT_BACKEND
00132     args += ".flint/";
00133 #else
00134     args += ".quartz/";
00135 #endif
00136     args += last_wdb_name;
00137 
00138 #ifdef HAVE_VALGRIND
00139     if (RUNNING_ON_VALGRIND) {
00140         args.insert(0, XAPIAN_PROGSRV" ");
00141         return Xapian::Remote::open_writable("./runsrv", args);
00142     }
00143 #endif
00144     return Xapian::Remote::open_writable(XAPIAN_PROGSRV, args);
00145 }

Documentation for Xapian (version 1.0.10).
Generated on 24 Dec 2008 by Doxygen 1.5.2.