xapian-core  1.4.20
Classes | Macros | Functions
api_backend.cc File Reference

Backend-related tests. More...

#include <config.h>
#include "api_backend.h"
#include <xapian.h>
#include "backendmanager.h"
#include "errno_to_string.h"
#include "filetests.h"
#include "str.h"
#include "testrunner.h"
#include "testsuite.h"
#include "testutils.h"
#include "unixcmds.h"
#include "apitest.h"
#include "safefcntl.h"
#include "safesysstat.h"
#include "safeunistd.h"
#include <cerrno>
#include <fstream>
#include <iterator>
+ Include dependency graph for api_backend.cc:

Go to the source code of this file.

Classes

class  CheckMatchDecider
 

Macros

#define XAPIAN_DEPRECATED(X)   X
 

Functions

 DEFINE_TESTCASE (lockfileumask1, chert||glass)
 Regression test - lockfile should honour umask, was only user-readable. More...
 
 DEFINE_TESTCASE (totaldoclen1, writable)
 Check that the backend handles total document length > 0xffffffff. More...
 
 DEFINE_TESTCASE (exceed32bitcombineddb1, writable)
 
 DEFINE_TESTCASE (dbstats1, backend)
 
 DEFINE_TESTCASE (dbstats2, backend)
 
 DEFINE_TESTCASE (alldocspl3, backend)
 Check handling of alldocs on an empty database. More...
 
 DEFINE_TESTCASE (modifiedpostlist1, writable)
 Regression test for bug#392 in ModifiedPostList iteration, fixed in 1.0.15. More...
 
 DEFINE_TESTCASE (doclenaftercommit1, writable)
 Regression test for chert bug fixed in 1.1.3 (ticket#397). More...
 
 DEFINE_TESTCASE (valuesaftercommit1, writable)
 
 DEFINE_TESTCASE (lockfilefd0or1, chert||glass)
 
 DEFINE_TESTCASE (lockfilealreadyopen1, chert||glass)
 Regression test for bug fixed in 1.2.13 and 1.3.1. More...
 
 DEFINE_TESTCASE (testlock1, chert||glass)
 Feature tests for Database::locked(). More...
 
 DEFINE_TESTCASE (testlock2, backend &&!writable)
 Test that locked() returns false for backends which don't support update. More...
 
 DEFINE_TESTCASE (testlock3, inmemory)
 Test locked() on inmemory Database objects. More...
 
 DEFINE_TESTCASE (testlock4, chert||glass)
 Test locked() on closed WritableDatabase. More...
 
 DEFINE_TESTCASE (matchdecider4, remote)
 Test Xapian::MatchDecider with remote backend fails. More...
 
 DEFINE_TESTCASE (replacedoc7, writable &&!inmemory &&!remote)
 Check that replacing an unmodified document doesn't increase the automatic flush counter. More...
 
 DEFINE_TESTCASE (replacedoc8, writable)
 Check that replacing a document deleted since the last flush works. More...
 
 DEFINE_TESTCASE (databasemodified1, writable &&!inmemory &&!remote &&!multi)
 Test coverage for DatabaseModifiedError. More...
 
 DEFINE_TESTCASE (qpmemoryleak1, writable &&!inmemory)
 Regression test for bug#462 fixed in 1.0.19 and 1.1.5. More...
 
static void make_msize1_db (Xapian::WritableDatabase &db, const string &)
 
 DEFINE_TESTCASE (msize1, generated)
 Regression test for ticket#464, fixed in 1.1.6 and 1.0.20. More...
 
static void make_msize2_db (Xapian::WritableDatabase &db, const string &)
 
 DEFINE_TESTCASE (msize2, generated)
 Regression test for bug related to ticket#464, fixed in 1.1.6 and 1.0.20. More...
 
static void make_xordecay1_db (Xapian::WritableDatabase &db, const string &)
 
 DEFINE_TESTCASE (xordecay1, generated)
 Regression test for bug in decay of XOR, fixed in 1.2.1 and 1.0.21. More...
 
static void make_ordecay_db (Xapian::WritableDatabase &db, const string &)
 
 DEFINE_TESTCASE (ordecay1, generated)
 Regression test for bug in decay of OR to AND, fixed in 1.2.1 and 1.0.21. More...
 
 DEFINE_TESTCASE (ordecay2, generated)
 Regression test for bug in decay of OR to AND_MAYBE, fixed in 1.2.1 and 1.0.21. More...
 
static void make_orcheck_db (Xapian::WritableDatabase &db, const string &)
 
 DEFINE_TESTCASE (orcheck1, generated)
 Regression test for bugs in the check() method of OrPostList. More...
 
 DEFINE_TESTCASE (failedreplace1, chert||glass)
 Regression test for bug fixed in 1.2.1 and 1.0.21. More...
 
 DEFINE_TESTCASE (failedreplace2, chert||glass)
 
 DEFINE_TESTCASE (phrase3, positional)
 Coverage for SelectPostList::skip_to(). More...
 
 DEFINE_TESTCASE (msetfirst2, backend)
 Check that get_mset(<large number>, 10) doesn't exhaust memory needlessly. More...
 
 DEFINE_TESTCASE (bm25weight2, backend)
 
 DEFINE_TESTCASE (unigramlmweight2, backend)
 
 DEFINE_TESTCASE (tradweight2, backend)
 
 DEFINE_TESTCASE (emptydb1, backend)
 
 DEFINE_TESTCASE (multiargop1, backend)
 Test operators which should allow more than two arguments. More...
 
 DEFINE_TESTCASE (stubdb7, !backend)
 Test error opening non-existent stub databases. More...
 
 DEFINE_TESTCASE (msetweights1, backend)
 Test which checks the weights are as expected. More...
 
 DEFINE_TESTCASE (itorskiptofromend1, backend)
 
 DEFINE_TESTCASE (blocksize1, chert||glass)
 Check handling of invalid block sizes. More...
 
 DEFINE_TESTCASE (notermlist1, glass)
 Feature test for Xapian::DB_NO_TERMLIST. More...
 
 DEFINE_TESTCASE (newfreelistblock1, writable)
 Regression test for bug starting a new glass freelist block. More...
 
 DEFINE_TESTCASE (readonlyparentdir1, chert||glass)
 Check that the parent directory for the database doesn't need to be writable. More...
 
static void make_phrasebug1_db (Xapian::WritableDatabase &db, const string &)
 
 DEFINE_TESTCASE (phrasebug1, generated &&positional)
 Regression test for ticket#653, fixed in 1.3.2 and 1.2.19. More...
 
 DEFINE_TESTCASE (retrylock1, writable &&path)
 Feature test for Xapian::DB_RETRY_LOCK. More...
 
 DEFINE_TESTCASE (dbfilefd012, chert||glass)
 
 DEFINE_TESTCASE (cursorbug1, chert||glass)
 Regression test for #675, fixed in 1.3.3 and 1.2.21. More...
 
 DEFINE_TESTCASE (sortvalue2, backend)
 
 DEFINE_TESTCASE (enquiregetquery1, backend)
 Check behaviour of Enquire::get_query(). More...
 
 DEFINE_TESTCASE (embedded1, singlefile)
 
 DEFINE_TESTCASE (exactxor1, backend)
 Regression test for bug fixed in 1.3.7. More...
 
 DEFINE_TESTCASE (getrevision1, chert||glass)
 Feature test for Database::get_revision(). More...
 
 DEFINE_TESTCASE (getrevision2, glass)
 Check get_revision() on an empty database reports 0. (Since 1.5.0) More...
 
 DEFINE_TESTCASE (getdocumentlazy1, backend)
 Feature test for DOC_ASSUME_VALID. More...
 
 DEFINE_TESTCASE (getdocumentlazy2, backend)
 Feature test for DOC_ASSUME_VALID for a docid that doesn't actually exist. More...
 
static void gen_uniqterms_gt_doclen_db (Xapian::WritableDatabase &db, const string &)
 
 DEFINE_TESTCASE (getuniqueterms1, generated)
 
 DEFINE_TESTCASE (nopositionbug1, generated)
 Regression test for bug fixed in 1.4.6. More...
 
 DEFINE_TESTCASE (checkatleast4, backend)
 Regression test for bug with get_mset(0, 0, N) (N > 0). More...
 
 DEFINE_TESTCASE (nodocs1, transactions &&!remote)
 Regression test for glass bug fixed in 1.4.6 and 1.5.0. More...
 
 DEFINE_TESTCASE (splitpostings1, writable)
 Regression test for split position handling - broken in 1.4.8. More...
 
 DEFINE_TESTCASE (multidb1, backend)
 Feature tests for Database::size(). More...
 
 DEFINE_TESTCASE (allterms7, backend)
 

Detailed Description

Backend-related tests.

Definition in file api_backend.cc.

Macro Definition Documentation

◆ XAPIAN_DEPRECATED

#define XAPIAN_DEPRECATED (   X)    X

Definition at line 27 of file api_backend.cc.

Function Documentation

◆ DEFINE_TESTCASE() [1/61]

DEFINE_TESTCASE ( lockfileumask1  ,
chert||  glass 
)

Regression test - lockfile should honour umask, was only user-readable.

Definition at line 57 of file api_backend.cc.

References get_named_writable_database(), get_named_writable_database_path(), TEST, and TEST_EQUAL.

◆ DEFINE_TESTCASE() [2/61]

DEFINE_TESTCASE ( totaldoclen1  ,
writable   
)

◆ DEFINE_TESTCASE() [3/61]

DEFINE_TESTCASE ( exceed32bitcombineddb1  ,
writable   
)

◆ DEFINE_TESTCASE() [4/61]

DEFINE_TESTCASE ( dbstats1  ,
backend   
)

◆ DEFINE_TESTCASE() [5/61]

DEFINE_TESTCASE ( dbstats2  ,
backend   
)

◆ DEFINE_TESTCASE() [6/61]

DEFINE_TESTCASE ( alldocspl3  ,
backend   
)

◆ DEFINE_TESTCASE() [7/61]

DEFINE_TESTCASE ( modifiedpostlist1  ,
writable   
)

◆ DEFINE_TESTCASE() [8/61]

DEFINE_TESTCASE ( doclenaftercommit1  ,
writable   
)

◆ DEFINE_TESTCASE() [9/61]

DEFINE_TESTCASE ( valuesaftercommit1  ,
writable   
)

◆ DEFINE_TESTCASE() [10/61]

DEFINE_TESTCASE ( lockfilefd0or1  ,
chert||  glass 
)

◆ DEFINE_TESTCASE() [11/61]

DEFINE_TESTCASE ( lockfilealreadyopen1  ,
chert||  glass 
)

Regression test for bug fixed in 1.2.13 and 1.3.1.

Definition at line 308 of file api_backend.cc.

References close(), Xapian::DB_CREATE_OR_OPEN, get_named_writable_database(), get_named_writable_database_path(), Xapian::InMemory::open(), TEST, and TEST_EXCEPTION.

◆ DEFINE_TESTCASE() [12/61]

DEFINE_TESTCASE ( testlock1  ,
chert||  glass 
)

◆ DEFINE_TESTCASE() [13/61]

DEFINE_TESTCASE ( testlock2  ,
backend &&!  writable 
)

Test that locked() returns false for backends which don't support update.

Regression test for bug fixed in 1.4.6.

Definition at line 371 of file api_backend.cc.

References Xapian::Database::close(), get_database(), Xapian::Database::locked(), and TEST.

◆ DEFINE_TESTCASE() [14/61]

DEFINE_TESTCASE ( testlock3  ,
inmemory   
)

Test locked() on inmemory Database objects.

An inmemory Database is always actually a WritableDatabase viewed as a Database, so it should always report being locked for writing, unless close() has been called.

Regression test for bug fixed in 1.4.14 - earlier versions always returned false for an inmemory Database here.

Regression test for bug fixed in 1.4.15 - false should be returned after close() has been called.

Definition at line 390 of file api_backend.cc.

References Xapian::Database::close(), get_database(), Xapian::Database::locked(), and TEST.

◆ DEFINE_TESTCASE() [15/61]

DEFINE_TESTCASE ( testlock4  ,
chert||  glass 
)

Test locked() on closed WritableDatabase.

Definition at line 398 of file api_backend.cc.

References Xapian::Database::close(), get_writable_database(), Xapian::Database::locked(), SKIP_TEST, and TEST.

◆ DEFINE_TESTCASE() [16/61]

DEFINE_TESTCASE ( matchdecider4  ,
remote   
)

◆ DEFINE_TESTCASE() [17/61]

DEFINE_TESTCASE ( replacedoc7  ,
writable &&!inmemory &&!  remote 
)

◆ DEFINE_TESTCASE() [18/61]

DEFINE_TESTCASE ( replacedoc8  ,
writable   
)

Check that replacing a document deleted since the last flush works.

Prior to 1.1.4/1.0.18, this failed to update the collection frequency and wdf, and caused an assertion failure when assertions were enabled.

Definition at line 484 of file api_backend.cc.

References Xapian::WritableDatabase::add_document(), Xapian::Document::add_term(), Xapian::WritableDatabase::delete_document(), Xapian::WritableDatabase::flush(), Xapian::Database::get_collection_freq(), get_writable_database(), Xapian::Database::postlist_begin(), Xapian::Database::postlist_end(), Xapian::WritableDatabase::replace_document(), Xapian::Document::set_data(), TEST, and TEST_EQUAL.

◆ DEFINE_TESTCASE() [19/61]

DEFINE_TESTCASE ( databasemodified1  ,
writable &&!inmemory &&!remote &&!  multi 
)

◆ DEFINE_TESTCASE() [20/61]

DEFINE_TESTCASE ( qpmemoryleak1  ,
writable &&!  inmemory 
)

◆ DEFINE_TESTCASE() [21/61]

DEFINE_TESTCASE ( msize1  ,
generated   
)

◆ DEFINE_TESTCASE() [22/61]

DEFINE_TESTCASE ( msize2  ,
generated   
)

◆ DEFINE_TESTCASE() [23/61]

DEFINE_TESTCASE ( xordecay1  ,
generated   
)

◆ DEFINE_TESTCASE() [24/61]

DEFINE_TESTCASE ( ordecay1  ,
generated   
)

Regression test for bug in decay of OR to AND, fixed in 1.2.1 and 1.0.21.

Definition at line 722 of file api_backend.cc.

References get_database(), Xapian::Database::get_doccount(), Xapian::Enquire::get_mset(), make_ordecay_db(), mset_range_is_same(), Xapian::Query::OP_OR, Xapian::Enquire::set_query(), Xapian::MSet::size(), and TEST.

◆ DEFINE_TESTCASE() [25/61]

DEFINE_TESTCASE ( ordecay2  ,
generated   
)

◆ DEFINE_TESTCASE() [26/61]

DEFINE_TESTCASE ( orcheck1  ,
generated   
)

Regression test for bugs in the check() method of OrPostList.

(ticket #485) Bugs introduced and fixed between 1.2.0 and 1.2.1 (never in a release).

Definition at line 798 of file api_backend.cc.

References get_database(), Xapian::Database::get_doccount(), Xapian::Enquire::get_mset(), make_orcheck_db(), mset_expect_order(), Xapian::Query::OP_AND, Xapian::Query::OP_OR, Xapian::Query::OP_VALUE_RANGE, Xapian::Enquire::set_query(), and tout.

◆ DEFINE_TESTCASE() [27/61]

DEFINE_TESTCASE ( failedreplace1  ,
chert||  glass 
)

◆ DEFINE_TESTCASE() [28/61]

DEFINE_TESTCASE ( failedreplace2  ,
chert||  glass 
)

◆ DEFINE_TESTCASE() [29/61]

DEFINE_TESTCASE ( phrase3  ,
positional   
)

◆ DEFINE_TESTCASE() [30/61]

DEFINE_TESTCASE ( msetfirst2  ,
backend   
)

Check that get_mset(<large number>, 10) doesn't exhaust memory needlessly.

Definition at line 893 of file api_backend.cc.

References get_database(), Xapian::MSet::get_firstitem(), Xapian::Enquire::get_mset(), Xapian::Query::MatchNothing, Xapian::Enquire::set_query(), and TEST_EQUAL.

◆ DEFINE_TESTCASE() [31/61]

DEFINE_TESTCASE ( bm25weight2  ,
backend   
)

◆ DEFINE_TESTCASE() [32/61]

DEFINE_TESTCASE ( unigramlmweight2  ,
backend   
)

◆ DEFINE_TESTCASE() [33/61]

DEFINE_TESTCASE ( tradweight2  ,
backend   
)

◆ DEFINE_TESTCASE() [34/61]

DEFINE_TESTCASE ( emptydb1  ,
backend   
)

◆ DEFINE_TESTCASE() [35/61]

DEFINE_TESTCASE ( multiargop1  ,
backend   
)

◆ DEFINE_TESTCASE() [36/61]

DEFINE_TESTCASE ( stubdb7  ,
backend 
)

Test error opening non-existent stub databases.

Definition at line 1012 of file api_backend.cc.

References Xapian::DB_BACKEND_STUB, Xapian::DB_OPEN, and TEST_EXCEPTION.

◆ DEFINE_TESTCASE() [37/61]

DEFINE_TESTCASE ( msetweights1  ,
backend   
)

Test which checks the weights are as expected.

Definition at line 1023 of file api_backend.cc.

References get_database(), Xapian::Enquire::get_mset(), Xapian::Query::OP_OR, Xapian::Enquire::set_query(), Xapian::MSet::size(), TEST_EQUAL, and TEST_EQUAL_DOUBLE.

◆ DEFINE_TESTCASE() [38/61]

DEFINE_TESTCASE ( itorskiptofromend1  ,
backend   
)

◆ DEFINE_TESTCASE() [39/61]

DEFINE_TESTCASE ( blocksize1  ,
chert||  glass 
)

◆ DEFINE_TESTCASE() [40/61]

DEFINE_TESTCASE ( notermlist1  ,
glass   
)

◆ DEFINE_TESTCASE() [41/61]

DEFINE_TESTCASE ( newfreelistblock1  ,
writable   
)

Regression test for bug starting a new glass freelist block.

Definition at line 1145 of file api_backend.cc.

References Xapian::WritableDatabase::add_document(), Xapian::Document::add_term(), Xapian::WritableDatabase::commit(), get_writable_database(), and Xapian::Internal::str().

◆ DEFINE_TESTCASE() [42/61]

DEFINE_TESTCASE ( readonlyparentdir1  ,
chert||  glass 
)

Check that the parent directory for the database doesn't need to be writable.

Regression test for early versions on the glass new btree branch which failed to append a "/" when generating a temporary filename from the database directory.

Definition at line 1169 of file api_backend.cc.

References Xapian::WritableDatabase::add_document(), Xapian::Document::add_term(), Xapian::WritableDatabase::commit(), get_named_writable_database(), get_named_writable_database_path(), Xapian::Document::set_data(), and TEST.

◆ DEFINE_TESTCASE() [43/61]

DEFINE_TESTCASE ( phrasebug1  ,
generated &&  positional 
)

Regression test for ticket#653, fixed in 1.3.2 and 1.2.19.

Definition at line 1207 of file api_backend.cc.

References get_database(), Xapian::Enquire::get_mset(), make_phrasebug1_db(), Xapian::Query::OP_PHRASE, Xapian::Enquire::set_query(), Xapian::MSet::size(), and TEST_EQUAL.

◆ DEFINE_TESTCASE() [44/61]

DEFINE_TESTCASE ( retrylock1  ,
writable &&  path 
)

◆ DEFINE_TESTCASE() [45/61]

DEFINE_TESTCASE ( dbfilefd012  ,
chert||  glass 
)

◆ DEFINE_TESTCASE() [46/61]

DEFINE_TESTCASE ( cursorbug1  ,
chert||  glass 
)

◆ DEFINE_TESTCASE() [47/61]

DEFINE_TESTCASE ( sortvalue2  ,
backend   
)

◆ DEFINE_TESTCASE() [48/61]

DEFINE_TESTCASE ( enquiregetquery1  ,
backend   
)

Check behaviour of Enquire::get_query().

Definition at line 1462 of file api_backend.cc.

References get_database(), Xapian::Query::get_description(), Xapian::Enquire::get_query(), and TEST_EQUAL.

◆ DEFINE_TESTCASE() [49/61]

DEFINE_TESTCASE ( embedded1  ,
singlefile   
)

◆ DEFINE_TESTCASE() [50/61]

DEFINE_TESTCASE ( exactxor1  ,
backend   
)

◆ DEFINE_TESTCASE() [51/61]

DEFINE_TESTCASE ( getrevision1  ,
chert||  glass 
)

◆ DEFINE_TESTCASE() [52/61]

DEFINE_TESTCASE ( getrevision2  ,
glass   
)

Check get_revision() on an empty database reports 0. (Since 1.5.0)

Definition at line 1547 of file api_backend.cc.

References Xapian::Database::get_revision(), and TEST_EQUAL.

◆ DEFINE_TESTCASE() [53/61]

DEFINE_TESTCASE ( getdocumentlazy1  ,
backend   
)

◆ DEFINE_TESTCASE() [54/61]

DEFINE_TESTCASE ( getdocumentlazy2  ,
backend   
)

Feature test for DOC_ASSUME_VALID for a docid that doesn't actually exist.

Definition at line 1564 of file api_backend.cc.

References Xapian::DOC_ASSUME_VALID, Xapian::Document::get_data(), get_database(), Xapian::Database::get_document(), Xapian::Database::get_lastdocid(), TEST, and TEST_EXCEPTION.

◆ DEFINE_TESTCASE() [55/61]

DEFINE_TESTCASE ( getuniqueterms1  ,
generated   
)

◆ DEFINE_TESTCASE() [56/61]

DEFINE_TESTCASE ( nopositionbug1  ,
generated   
)

Regression test for bug fixed in 1.4.6.

OP_NEAR would think a term without positional information occurred at position 1 if it had the lowest term frequency amongst the OP_NEAR's subqueries.

Definition at line 1619 of file api_backend.cc.

References gen_uniqterms_gt_doclen_db(), get_database(), Xapian::Enquire::get_mset(), Xapian::Query::OP_NEAR, Xapian::Query::OP_PHRASE, Xapian::Enquire::set_query(), Xapian::MSet::size(), and TEST_EQUAL.

◆ DEFINE_TESTCASE() [57/61]

DEFINE_TESTCASE ( checkatleast4  ,
backend   
)

Regression test for bug with get_mset(0, 0, N) (N > 0).

Fixed in 1.5.0 and 1.4.6.

Definition at line 1658 of file api_backend.cc.

References get_database(), Xapian::Enquire::get_mset(), Xapian::Enquire::set_query(), Xapian::MSet::size(), and TEST_EQUAL.

◆ DEFINE_TESTCASE() [58/61]

DEFINE_TESTCASE ( nodocs1  ,
transactions &&!  remote 
)

◆ DEFINE_TESTCASE() [59/61]

DEFINE_TESTCASE ( splitpostings1  ,
writable   
)

◆ DEFINE_TESTCASE() [60/61]

DEFINE_TESTCASE ( multidb1  ,
backend   
)

Feature tests for Database::size().

Definition at line 1713 of file api_backend.cc.

References Xapian::Database::add_database(), get_database(), Xapian::Database::size(), TEST, and TEST_EQUAL.

◆ DEFINE_TESTCASE() [61/61]

DEFINE_TESTCASE ( allterms7  ,
backend   
)

◆ gen_uniqterms_gt_doclen_db()

static void gen_uniqterms_gt_doclen_db ( Xapian::WritableDatabase db,
const string &   
)
static

◆ make_msize1_db()

static void make_msize1_db ( Xapian::WritableDatabase db,
const string &   
)
static

◆ make_msize2_db()

static void make_msize2_db ( Xapian::WritableDatabase db,
const string &   
)
static

◆ make_orcheck_db()

static void make_orcheck_db ( Xapian::WritableDatabase db,
const string &   
)
static

◆ make_ordecay_db()

static void make_ordecay_db ( Xapian::WritableDatabase db,
const string &   
)
static

◆ make_phrasebug1_db()

static void make_phrasebug1_db ( Xapian::WritableDatabase db,
const string &   
)
static

◆ make_xordecay1_db()

static void make_xordecay1_db ( Xapian::WritableDatabase db,
const string &   
)
static