2 * @brief tests the Xapian Letor API
4 /* Copyright 1999,2000,2001 BrightStation PLC
5 * Copyright 2002 Ananova Ltd
6 * Copyright 2003,2004,2006,2007,2008,2009,2018 Olly Betts
7 * Copyright 2008 Lemur Consulting Ltd
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of the
12 * License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
30 #include "backendmanager.h"
31 #include "stringutils.h"
32 #include "testrunner.h"
33 #include "testsuite.h"
42 std::string
get_dbtype()
44 return backendmanager
->get_dbtype();
48 get_database(const string
&dbname
)
50 return backendmanager
->get_database(dbname
);
54 get_database(const string
&dbname
, const string
&dbname2
)
56 vector
<string
> dbnames
;
57 dbnames
.push_back(dbname
);
58 dbnames
.push_back(dbname2
);
59 return backendmanager
->get_database(dbnames
);
63 get_database(const std::string
&dbname
,
64 void (*gen
)(Xapian::WritableDatabase
&,
66 const std::string
&arg
)
68 return backendmanager
->get_database(dbname
, gen
, arg
);
72 get_database_path(const string
&dbname
)
74 return backendmanager
->get_database_path(dbname
);
78 get_database_path(const std::string
&dbname
,
79 void (*gen
)(Xapian::WritableDatabase
&,
81 const std::string
&arg
)
83 return backendmanager
->get_database_path(dbname
, gen
, arg
);
86 Xapian::WritableDatabase
87 get_writable_database(const string
&dbname
)
89 return backendmanager
->get_writable_database("dbw", dbname
);
92 Xapian::WritableDatabase
93 get_named_writable_database(const std::string
&name
, const std::string
&source
)
95 return backendmanager
->get_writable_database("dbw__" + name
, source
);
99 get_named_writable_database_path(const std::string
&name
)
101 return backendmanager
->get_writable_database_path("dbw__" + name
);
105 get_compaction_output_path(const std::string
& name
)
107 return backendmanager
->get_compaction_output_path(name
);
111 get_remote_database(const string
& dbname
,
112 unsigned int timeout
,
115 vector
<string
> dbnames
;
116 dbnames
.push_back(dbname
);
117 return backendmanager
->get_remote_database(dbnames
, timeout
, port_ptr
);
121 kill_remote(const Xapian::Database
& db
)
123 backendmanager
->kill_remote(db
);
127 get_writable_database_as_database()
129 return backendmanager
->get_writable_database_as_database();
132 Xapian::WritableDatabase
133 get_writable_database_again()
135 return backendmanager
->get_writable_database_again();
139 skip_test_unless_backend(const std::string
& backend_prefix
)
141 if (!startswith(get_dbtype(), backend_prefix
)) {
142 SKIP_TEST("Test only supported for " << backend_prefix
<< " backend");
147 skip_test_for_backend(const std::string
& backend_prefix
)
149 if (startswith(get_dbtype(), backend_prefix
)) {
150 SKIP_TEST("Test not supported for " << backend_prefix
<< " backend");
155 XFAIL_FOR_BACKEND(const std::string
& backend_prefix
,
158 if (startswith(get_dbtype(), backend_prefix
)) {
163 class ApiTestRunner
: public TestRunner
168 #include "api_collated.h"
169 test_driver::report(test_driver::subtotal
,
170 "backend " + backendmanager
->get_dbtype());
171 test_driver::total
+= test_driver::subtotal
;
172 test_driver::subtotal
.reset();
177 int main(int argc
, char **argv
)
179 ApiTestRunner runner
;
180 return runner
.run_tests(argc
, argv
);