2 * @brief tests the Xapian 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
, unsigned int timeout
)
113 vector
<string
> dbnames
;
114 dbnames
.push_back(dbname
);
115 return backendmanager
->get_remote_database(dbnames
, timeout
);
119 get_writable_database_as_database()
121 return backendmanager
->get_writable_database_as_database();
124 Xapian::WritableDatabase
125 get_writable_database_again()
127 return backendmanager
->get_writable_database_again();
131 skip_test_unless_backend(const std::string
& backend_prefix
)
133 if (!startswith(get_dbtype(), backend_prefix
)) {
134 SKIP_TEST("Test only supported for " << backend_prefix
<< " backend");
139 skip_test_for_backend(const std::string
& backend_prefix
)
141 if (startswith(get_dbtype(), backend_prefix
)) {
142 SKIP_TEST("Test not supported for " << backend_prefix
<< " backend");
147 XFAIL_FOR_BACKEND(const std::string
& backend_prefix
,
150 if (startswith(get_dbtype(), backend_prefix
)) {
155 class ApiTestRunner
: public TestRunner
160 #include "api_collated.h"
161 test_driver::report(test_driver::subtotal
,
162 "backend " + backendmanager
->get_dbtype());
163 test_driver::total
+= test_driver::subtotal
;
164 test_driver::subtotal
.reset();
169 int main(int argc
, char **argv
)
171 ApiTestRunner runner
;
172 return runner
.run_tests(argc
, argv
);