1 /* We should be able to tdb_check a O_RDONLY tdb, and we were previously allowed
2 * to tdb_check() inside a transaction (though that's paranoia!). */
3 #include "../common/tdb_private.h"
4 #include "../common/io.c"
5 #include "../common/tdb.c"
6 #include "../common/lock.c"
7 #include "../common/freelist.c"
8 #include "../common/traverse.c"
9 #include "../common/transaction.c"
10 #include "../common/error.c"
11 #include "../common/open.c"
12 #include "../common/check.c"
13 #include "../common/hash.c"
14 #include "tap-interface.h"
19 int main(int argc, char *argv[])
21 struct tdb_context *tdb;
25 tdb = tdb_open_ex("run-readonly-check.tdb", 1024,
27 O_CREAT|O_TRUNC|O_RDWR, 0600, &taplogctx, NULL);
30 key.dsize = strlen("hi");
31 key.dptr = (void *)"hi";
32 data.dsize = strlen("world");
33 data.dptr = (void *)"world";
35 ok1(tdb_store(tdb, key, data, TDB_INSERT) == 0);
36 ok1(tdb_check(tdb, NULL, NULL) == 0);
38 /* We are also allowed to do a check inside a transaction. */
39 ok1(tdb_transaction_start(tdb) == 0);
40 ok1(tdb_check(tdb, NULL, NULL) == 0);
41 ok1(tdb_close(tdb) == 0);
43 tdb = tdb_open_ex("run-readonly-check.tdb", 1024,
44 TDB_DEFAULT, O_RDONLY, 0, &taplogctx, NULL);
47 ok1(tdb_store(tdb, key, data, TDB_MODIFY) == -1);
48 ok1(tdb_error(tdb) == TDB_ERR_RDONLY);
49 ok1(tdb_check(tdb, NULL, NULL) == 0);
50 ok1(tdb_close(tdb) == 0);