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 "tdb2-source.h"
4 #include "tap-interface.h"
8 int main(int argc, char *argv[])
10 struct tdb_context *tdb;
12 union tdb_attribute hsize;
14 hsize.base.attr = TDB_ATTRIBUTE_TDB1_HASHSIZE;
15 hsize.base.next = &tap_log_attr;
16 hsize.tdb1_hashsize.hsize = 1024;
19 tdb = tdb_open("run-readonly-check.tdb1",
21 O_CREAT|O_TRUNC|O_RDWR, 0600, &hsize);
24 key = tdb_mkdata("hi", strlen("hi"));
25 data = tdb_mkdata("world", strlen("world"));
27 ok1(tdb_store(tdb, key, data, TDB_INSERT) == TDB_SUCCESS);
28 ok1(tdb_check(tdb, NULL, NULL) == TDB_SUCCESS);
30 /* We are also allowed to do a check inside a transaction. */
31 ok1(tdb_transaction_start(tdb) == TDB_SUCCESS);
32 ok1(tdb_check(tdb, NULL, NULL) == TDB_SUCCESS);
33 ok1(tdb_close(tdb) == 0);
35 tdb = tdb_open("run-readonly-check.tdb1",
36 TDB_DEFAULT, O_RDONLY, 0, &tap_log_attr);
39 ok1(tdb_store(tdb, key, data, TDB_MODIFY) == TDB_ERR_RDONLY);
40 ok1(tdb_check(tdb, NULL, NULL) == TDB_SUCCESS);
41 ok1(tdb_close(tdb) == 0);