49 if (user_backend.empty())
51 if (backend_name == user_backend)
53 if (
startswith(backend_name, user_backend +
"_"))
62 struct BackendProperties {
68 static const BackendProperties backend_properties[] = {
70 {
"inmemory", INMEMORY|
71 BACKEND|POSITIONAL|WRITABLE|METADATA|VALUESTATS },
73 BACKEND|TRANSACTIONS|POSITIONAL|WRITABLE|
SPELLING|METADATA|
74 SYNONYMS|VALUESTATS|CHECK|COMPACT|PATH
75 #ifdef XAPIAN_HAS_REMOTE_BACKEND 80 BACKEND|TRANSACTIONS|POSITIONAL|WRITABLE|
SPELLING|METADATA|
81 SYNONYMS|VALUESTATS|CHECK|COMPACT|PATH
82 #ifdef XAPIAN_HAS_REMOTE_BACKEND 86 {
"multi_chert", MULTI|
87 BACKEND|TRANSACTIONS|POSITIONAL|WRITABLE|METADATA|VALUESTATS|
89 {
"multi_glass", MULTI|
90 BACKEND|TRANSACTIONS|POSITIONAL|WRITABLE|METADATA|VALUESTATS|
92 {
"remoteprog_chert", REMOTE|
93 BACKEND|TRANSACTIONS|POSITIONAL|WRITABLE|METADATA|VALUESTATS },
94 {
"remotetcp_chert", REMOTE|
95 BACKEND|TRANSACTIONS|POSITIONAL|WRITABLE|METADATA|VALUESTATS },
96 {
"multi_glass_remoteprog_glass", MULTI|REMOTE|
97 BACKEND|TRANSACTIONS|POSITIONAL|WRITABLE|METADATA|VALUESTATS },
98 {
"multi_remoteprog_glass", MULTI|REMOTE|
99 BACKEND|TRANSACTIONS|POSITIONAL|WRITABLE|METADATA|VALUESTATS },
100 {
"remoteprog_glass", REMOTE|
101 BACKEND|TRANSACTIONS|POSITIONAL|WRITABLE|METADATA|VALUESTATS
103 {
"remotetcp_glass", REMOTE|
104 BACKEND|TRANSACTIONS|POSITIONAL|WRITABLE|METADATA|VALUESTATS
106 {
"singlefile_glass", SINGLEFILE|
107 BACKEND|POSITIONAL|METADATA|
SPELLING|SYNONYMS|VALUESTATS|
113 for (
const BackendProperties * i = backend_properties; i->name; ++i) {
114 if (backend_name == i->name) {
115 properties = i->properties;
126 if (use_backend(backend_name)) {
127 set_properties_for_backend(backend_name);
128 cout <<
"Running tests with backend \"" << backend_name <<
"\"...\n";
129 backendmanager = manager;
130 result_so_far = max(result_so_far, run());
131 backendmanager = NULL;
143 string datadir =
srcdir +
"/testdata/";
147 #ifdef XAPIAN_HAS_INMEMORY_BACKEND 151 #ifdef XAPIAN_HAS_GLASS_BACKEND 156 vector<BackendManager*> multi_mans;
157 multi_mans = {&glass_man, &glass_man};
159 do_tests_for_backend(glass_man);
162 # ifdef XAPIAN_HAS_REMOTE_BACKEND 166 multi_mans = {&glass_man, &remoteprog_glass_man};
170 multi_mans = {&remoteprog_glass_man, &remoteprog_glass_man};
184 vector<BackendManager*> multi_mans;
185 multi_mans = {&chert_man, &chert_man};
187 #ifdef XAPIAN_HAS_CHERT_BACKEND 188 do_tests_for_backend(chert_man);
190 # ifdef XAPIAN_HAS_REMOTE_BACKEND 196 }
catch (
const std::exception& e) {
197 cerr <<
"\nTest harness failed with std::exception: " << e.what()
203 }
catch (
const std::string &e) {
204 cerr <<
"\nTest harness failed with \"" << e <<
"\"\n";
206 }
catch (
const char * e) {
210 return result_so_far;
Run multiple tests for different backends.
const char * backend_name(int code)
const std::string & get_dbtype() const
Get the database type currently in use.
static void parse_command_line(int argc, char **argv)
Parse the command line arguments.
BackendManager subclass for chert databases.
a generic test suite engine
void set_properties_for_backend(const std::string &backend_name)
Set the property flags to those for the named backend.
BackendManager subclass for singlefile databases.
BackendManager subclass for remotetcp databases.
BackendManager subclass for multi databases.
static std::string get_srcdir()
Read srcdir from environment and if not present, make a valiant attempt to guess a value...
static void add_command_line_option(const std::string &l, char s, std::string *arg)
Add a test-specific command line option.
virtual ~TestRunner()
Virtual destructor - needed for abstract class.
int run_tests(int argc, char **argv)
Run all the tests.
InvalidArgumentError indicates an invalid parameter value was passed to the API.
Base class for backend handling in test harness.
bool use_backend(const std::string &backend_name)
Return true iff we should use the named backend.
BackendManager subclass for remoteprog databases.
BackendManager subclass for remoteprog databases.
BackendManager * backendmanager
backendmanager is global so that it can be accessed by individual tests.
void do_tests_for_backend_(BackendManager *manager)
bool startswith(const std::string &s, char pfx)
BackendManager subclass for glass databases.
BackendManager subclass for remotetcp databases.
std::string get_description() const
Return a string describing this object.
BackendManager subclass for singlefile databases.
BackendManager subclass for chert databases.
BackendManager subclass for multi databases.
BackendManager subclass for inmemory databases.
All exceptions thrown by Xapian are subclasses of Xapian::Error.
BackendManager subclass for inmemory databases.
Various handy helpers which std::string really should provide.
BackendManager subclass for glass databases.