|
rpm-build |
ca8475 |
/* We should be able to tdb_check a O_RDONLY tdb, and we were previously allowed
|
|
rpm-build |
ca8475 |
* to tdb_check() inside a transaction (though that's paranoia!). */
|
|
rpm-build |
ca8475 |
#include "../common/tdb_private.h"
|
|
rpm-build |
ca8475 |
#include "../common/io.c"
|
|
rpm-build |
ca8475 |
#include "../common/tdb.c"
|
|
rpm-build |
ca8475 |
#include "../common/lock.c"
|
|
rpm-build |
ca8475 |
#include "../common/freelist.c"
|
|
rpm-build |
ca8475 |
#include "../common/traverse.c"
|
|
rpm-build |
ca8475 |
#include "../common/transaction.c"
|
|
rpm-build |
ca8475 |
#include "../common/error.c"
|
|
rpm-build |
ca8475 |
#include "../common/open.c"
|
|
rpm-build |
ca8475 |
#include "../common/check.c"
|
|
rpm-build |
ca8475 |
#include "../common/hash.c"
|
|
rpm-build |
ca8475 |
#include "../common/mutex.c"
|
|
rpm-build |
ca8475 |
#include "tap-interface.h"
|
|
rpm-build |
ca8475 |
#include <stdlib.h>
|
|
rpm-build |
ca8475 |
#include "logging.h"
|
|
rpm-build |
ca8475 |
|
|
rpm-build |
ca8475 |
int main(int argc, char *argv[])
|
|
rpm-build |
ca8475 |
{
|
|
rpm-build |
ca8475 |
struct tdb_context *tdb;
|
|
rpm-build |
ca8475 |
TDB_DATA key, data;
|
|
rpm-build |
ca8475 |
|
|
rpm-build |
ca8475 |
plan_tests(11);
|
|
rpm-build |
ca8475 |
tdb = tdb_open_ex("run-readonly-check.tdb", 1024,
|
|
rpm-build |
ca8475 |
TDB_DEFAULT,
|
|
rpm-build |
ca8475 |
O_CREAT|O_TRUNC|O_RDWR, 0600, &taplogctx, NULL);
|
|
rpm-build |
ca8475 |
|
|
rpm-build |
ca8475 |
ok1(tdb);
|
|
rpm-build |
ca8475 |
key.dsize = strlen("hi");
|
|
rpm-build |
ca8475 |
key.dptr = discard_const_p(uint8_t, "hi");
|
|
rpm-build |
ca8475 |
data.dsize = strlen("world");
|
|
rpm-build |
ca8475 |
data.dptr = discard_const_p(uint8_t, "world");
|
|
rpm-build |
ca8475 |
|
|
rpm-build |
ca8475 |
ok1(tdb_store(tdb, key, data, TDB_INSERT) == 0);
|
|
rpm-build |
ca8475 |
ok1(tdb_check(tdb, NULL, NULL) == 0);
|
|
rpm-build |
ca8475 |
|
|
rpm-build |
ca8475 |
/* We are also allowed to do a check inside a transaction. */
|
|
rpm-build |
ca8475 |
ok1(tdb_transaction_start(tdb) == 0);
|
|
rpm-build |
ca8475 |
ok1(tdb_check(tdb, NULL, NULL) == 0);
|
|
rpm-build |
ca8475 |
ok1(tdb_close(tdb) == 0);
|
|
rpm-build |
ca8475 |
|
|
rpm-build |
ca8475 |
tdb = tdb_open_ex("run-readonly-check.tdb", 1024,
|
|
rpm-build |
ca8475 |
TDB_DEFAULT, O_RDONLY, 0, &taplogctx, NULL);
|
|
rpm-build |
ca8475 |
|
|
rpm-build |
ca8475 |
ok1(tdb);
|
|
rpm-build |
ca8475 |
ok1(tdb_store(tdb, key, data, TDB_MODIFY) == -1);
|
|
rpm-build |
ca8475 |
ok1(tdb_error(tdb) == TDB_ERR_RDONLY);
|
|
rpm-build |
ca8475 |
ok1(tdb_check(tdb, NULL, NULL) == 0);
|
|
rpm-build |
ca8475 |
ok1(tdb_close(tdb) == 0);
|
|
rpm-build |
ca8475 |
|
|
rpm-build |
ca8475 |
return exit_status();
|
|
rpm-build |
ca8475 |
}
|