28 # include <valgrind/memcheck.h>
37 #include <sys/types.h>
56 const vector<string> & files)
68 if (mkdir(dirname.c_str(), 0700) == 0) {
72 int mkdir_errno = errno;
73 if (mkdir_errno == EEXIST) {
101 return do_get_database(files);
107 return do_get_database(vector<string>(1, file));
113 const std::string &),
114 const std::string &arg)
116 string dbleaf =
"db__";
118 const string& path = get_generated_database_path(dbleaf);
133 return get_database_by_path(path);
139 string tmp_dbleaf(dbleaf);
141 string tmp_path(path);
148 finalise_generated_database(tmp_dbleaf);
149 rename(tmp_path.c_str(), path.c_str());
153 return get_database_by_path(path);
159 const std::string &),
160 const std::string &arg)
162 string dbleaf =
"db__";
164 const string& path = get_generated_database_path(dbleaf);
174 string tmp_dbleaf(dbleaf);
176 string tmp_path(path);
183 finalise_generated_database(tmp_dbleaf);
184 rename(tmp_path.c_str(), path.c_str());
198 return do_get_database_path(files);
204 return do_get_database_path(vector<string>(1, file));
216 string msg =
"BackendManager::get_remote_writable_database() "
217 "called for non-remote database (type is ";
257 string msg =
"BackendManager::get_remote_database() called for non-remote "
258 "database (type is ";
268 string msg =
"BackendManager::get_writable_database_args() "
269 "called for non-remote database (type is ";
284 string msg =
"Backend ";
286 msg +=
" doesn't support get_writable_database_again()";
293 string msg =
"Backend ";
295 msg +=
" doesn't support get_writable_database_path_again()";
308 "remotetcp databases");
315 if (RUNNING_ON_VALGRIND) {
Xapian::WritableDatabase get_writable_database(const string &dbname)
static void invalid_operation(const char *msg)
Base class for backend handling in test harness.
static const char * get_xapian_progsrv_command()
Get the command line required to run xapian-progsrv.
Xapian::Database get_database(const std::vector< std::string > &files)
Get a database instance of the current type.
virtual std::string get_compaction_output_path(const std::string &name)
Get a path to compact a database to.
virtual Xapian::WritableDatabase get_writable_database_again()
Create a WritableDatabase object for the last opened WritableDatabase.
virtual Xapian::WritableDatabase get_generated_database(const std::string &name)
Get a generated writable database instance.
virtual std::string do_get_database_path(const std::vector< std::string > &files)
Virtual method implementing get_database_path().
bool create_dir_if_needed(const std::string &dirname)
Create the directory dirname if needed.
virtual Xapian::Database do_get_database(const std::vector< std::string > &files)
Virtual method implementing get_database().
void index_files_to_database(Xapian::WritableDatabase &database, const std::vector< std::string > &files)
Index data from zero or more text files into a database.
virtual Xapian::WritableDatabase get_remote_writable_database(std::string args)
Get a remote Xapian::WritableDatabase instance with specified args.
virtual ~BackendManager()
We have virtual methods and want to be able to delete derived classes using a pointer to the base cla...
virtual std::string get_writable_database_args(const std::string &path, unsigned int timeout)
Get the args for opening a writable remote database with the specified timeout.
virtual Xapian::Database get_database_by_path(const std::string &path)
Get a database instance by path.
std::string get_database_path(const std::vector< std::string > &files)
Get the path of a database instance, if such a thing exists.
virtual std::string get_writable_database_path(const std::string &name)
Get the path of a writable database instance, if such a thing exists.
virtual std::string get_generated_database_path(const std::string &name)
Get the path to use for generating a database, if supported.
virtual Xapian::Database get_writable_database_as_database()
Create a Database object for the last opened WritableDatabase.
virtual void finalise_generated_database(const std::string &name)
Finalise the generated database.
virtual void clean_up()
Called after each test, to perform any necessary cleanup.
virtual Xapian::Database get_remote_database(const std::vector< std::string > &files, unsigned int timeout, int *port_ptr)
Get a remote database instance with the specified timeout.
virtual void kill_remote(const Xapian::Database &db)
Kill the remote server associated with db.
virtual Xapian::WritableDatabase get_writable_database(const std::string &name, const std::string &file)
Get a writable database instance.
virtual std::string get_writable_database_path_again()
Get the path of the last opened WritableDatabase.
void index_to(Xapian::WritableDatabase &db)
DatabaseOpeningError indicates failure to open a database.
An indexed database of documents.
InvalidOperationError indicates the API was used in an invalid way.
This class provides read/write access to a database.
Utility functions for testing files.
bool dir_exists(const char *path)
Test if a directory exists.
bool path_exists(const char *path)
Test if a path exists.
utility functions for indexing testcase data
include <sys/stat.h> with portability enhancements
void rm_rf(const string &filename)
Remove a directory and contents, just like the Unix "rm -rf" command.
C++ function versions of useful Unix commands.
Public interfaces for the Xapian library.