00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <config.h>
00025
00026 #include "apitest.h"
00027
00028 #include "api_all.h"
00029 #include "backendmanager.h"
00030 #include "stringutils.h"
00031 #include "testrunner.h"
00032 #include "testsuite.h"
00033
00034 #include <xapian.h>
00035
00036 #include <string>
00037 #include <vector>
00038
00039 using namespace std;
00040
00041 std::string get_dbtype()
00042 {
00043 return backendmanager->get_dbtype();
00044 }
00045
00046 Xapian::Database
00047 get_database(const string &dbname)
00048 {
00049 return backendmanager->get_database(dbname);
00050 }
00051
00052 Xapian::Database
00053 get_database(const string &dbname, const string &dbname2)
00054 {
00055 vector<string> dbnames;
00056 dbnames.push_back(dbname);
00057 dbnames.push_back(dbname2);
00058 return backendmanager->get_database(dbnames);
00059 }
00060
00061 Xapian::Database
00062 get_database(const std::string &dbname,
00063 void (*gen)(Xapian::WritableDatabase&,
00064 const std::string &),
00065 const std::string &arg)
00066 {
00067 return backendmanager->get_database(dbname, gen, arg);
00068 }
00069
00070 string
00071 get_database_path(const string &dbname)
00072 {
00073 return backendmanager->get_database_path(dbname);
00074 }
00075
00076 string
00077 get_database_path(const std::string &dbname,
00078 void (*gen)(Xapian::WritableDatabase&,
00079 const std::string &),
00080 const std::string &arg)
00081 {
00082 return backendmanager->get_database_path(dbname, gen, arg);
00083 }
00084
00085 Xapian::WritableDatabase
00086 get_writable_database(const string &dbname)
00087 {
00088 return backendmanager->get_writable_database("dbw", dbname);
00089 }
00090
00091 Xapian::WritableDatabase
00092 get_named_writable_database(const std::string &name, const std::string &source)
00093 {
00094 return backendmanager->get_writable_database("dbw__" + name, source);
00095 }
00096
00097 std::string
00098 get_named_writable_database_path(const std::string &name)
00099 {
00100 return backendmanager->get_writable_database_path("dbw__" + name);
00101 }
00102
00103 Xapian::Database
00104 get_remote_database(const string &dbname, unsigned int timeout)
00105 {
00106 vector<string> dbnames;
00107 dbnames.push_back(dbname);
00108 return backendmanager->get_remote_database(dbnames, timeout);
00109 }
00110
00111 Xapian::Database
00112 get_writable_database_as_database()
00113 {
00114 return backendmanager->get_writable_database_as_database();
00115 }
00116
00117 Xapian::WritableDatabase
00118 get_writable_database_again()
00119 {
00120 return backendmanager->get_writable_database_again();
00121 }
00122
00123 void
00124 skip_test_unless_backend(const std::string & backend_prefix)
00125 {
00126 if (!startswith(get_dbtype(), backend_prefix)) {
00127 SKIP_TEST("Test only supported for " + backend_prefix + " backend");
00128 }
00129 }
00130
00131 void
00132 skip_test_for_backend(const std::string & backend_prefix)
00133 {
00134 if (startswith(get_dbtype(), backend_prefix)) {
00135 SKIP_TEST("Test not supported for " + backend_prefix + " backend");
00136 }
00137 }
00138
00139 class ApiTestRunner : public TestRunner
00140 {
00141 public:
00142 int run() const {
00143 int result = 0;
00144 #include "api_collated.h"
00145 test_driver::report(test_driver::subtotal,
00146 "backend " + backendmanager->get_dbtype());
00147 test_driver::total += test_driver::subtotal;
00148 test_driver::subtotal.reset();
00149 return result;
00150 }
00151 };
00152
00153 int main(int argc, char **argv)
00154 {
00155 ApiTestRunner runner;
00156 return runner.run_tests(argc, argv);
00157 }