Ticket #427: compacttest.patch

File compacttest.patch, 1.4 KB (added by Richard Boulton, 14 years ago)

Patch to testsuite to exhibit this bug

  • api_compact.cc

     
    8383}
    8484
    8585static void
     86make_multichunk_db(Xapian::WritableDatabase &db, const string &)
     87{
     88    // Need non-const pointer for strtoul(), but data isn't modified.
     89    int count = 10000;
     90
     91    while (count) {
     92        Xapian::Document doc;
     93        doc.add_term("a");
     94        db.add_document(doc);
     95        --count;
     96    }
     97
     98    db.commit();
     99}
     100
     101static void
    86102check_sparse_uid_terms(const string & path)
    87103{
    88104    Xapian::Database db(path);
     
    205221
    206222    return true;
    207223}
     224
     225// Test use of compact on a database which has multiple chunks for a term.
     226DEFINE_TESTCASE(compactmultichunks1, brass || chert || flint) {
     227    int status;
     228
     229    string cmd = "../bin/xapian-compact >/dev/null 2>&1 ";
     230    string indbpath = get_database_path("compactmultichunks1in",
     231                                        make_multichunk_db, "");
     232    string outdbpath = get_named_writable_database_path("compactmultichunks1out");
     233    rm_rf(outdbpath);
     234
     235    status = system(cmd + indbpath + ' ' + outdbpath);
     236    TEST_EQUAL(WEXITSTATUS(status), 0);
     237
     238    Xapian::Database indb(indbpath);
     239    Xapian::Database outdb(outdbpath);
     240
     241    TEST_EQUAL(indb.get_doccount(), outdb.get_doccount());
     242    dbcheck(outdb, outdb.get_doccount(), outdb.get_doccount());
     243
     244    return true;
     245}