1 /* apitest.cc: tests the Xapian API
3 * Copyright 1999,2000,2001 BrightStation PLC
4 * Copyright 2002 Ananova Ltd
5 * Copyright 2003,2004,2006,2007,2008,2009 Olly Betts
6 * Copyright 2008 Lemur Consulting Ltd
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of the
11 * License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
29 #include "backendmanager.h"
30 #include "stringutils.h"
31 #include "testrunner.h"
32 #include "testsuite.h"
41 std::string
get_dbtype()
43 return backendmanager
->get_dbtype();
47 get_database(const string
&dbname
)
49 return backendmanager
->get_database(dbname
);
53 get_database(const string
&dbname
, const string
&dbname2
)
55 vector
<string
> dbnames
;
56 dbnames
.push_back(dbname
);
57 dbnames
.push_back(dbname2
);
58 return backendmanager
->get_database(dbnames
);
62 get_database(const std::string
&dbname
,
63 void (*gen
)(Xapian::WritableDatabase
&,
65 const std::string
&arg
)
67 return backendmanager
->get_database(dbname
, gen
, arg
);
71 get_database_path(const string
&dbname
)
73 return backendmanager
->get_database_path(dbname
);
77 get_database_path(const std::string
&dbname
,
78 void (*gen
)(Xapian::WritableDatabase
&,
80 const std::string
&arg
)
82 return backendmanager
->get_database_path(dbname
, gen
, arg
);
85 Xapian::WritableDatabase
86 get_writable_database(const string
&dbname
)
88 return backendmanager
->get_writable_database("dbw", dbname
);
91 Xapian::WritableDatabase
92 get_named_writable_database(const std::string
&name
, const std::string
&source
)
94 return backendmanager
->get_writable_database("dbw__" + name
, source
);
98 get_named_writable_database_path(const std::string
&name
)
100 return backendmanager
->get_writable_database_path("dbw__" + name
);
104 get_remote_database(const string
&dbname
, unsigned int timeout
)
106 vector
<string
> dbnames
;
107 dbnames
.push_back(dbname
);
108 return backendmanager
->get_remote_database(dbnames
, timeout
);
112 get_writable_database_as_database()
114 return backendmanager
->get_writable_database_as_database();
117 Xapian::WritableDatabase
118 get_writable_database_again()
120 return backendmanager
->get_writable_database_again();
124 skip_test_unless_backend(const std::string
& backend_prefix
)
126 if (!startswith(get_dbtype(), backend_prefix
)) {
127 SKIP_TEST("Test only supported for " << backend_prefix
<< " backend");
132 skip_test_for_backend(const std::string
& backend_prefix
)
134 if (startswith(get_dbtype(), backend_prefix
)) {
135 SKIP_TEST("Test not supported for " << backend_prefix
<< " backend");
139 class ApiTestRunner
: public TestRunner
144 #include "api_collated.h"
145 test_driver::report(test_driver::subtotal
,
146 "backend " + backendmanager
->get_dbtype());
147 test_driver::total
+= test_driver::subtotal
;
148 test_driver::subtotal
.reset();
153 int main(int argc
, char **argv
)
155 ApiTestRunner runner
;
156 return runner
.run_tests(argc
, argv
);