s3:lib/events: s/EVENT_FD/TEVENT_FD
[Samba/gebeck_regimport.git] / lib / tdb / test / run-readonly-check.c
blobfdd9507cdad225503e2506e26577542feb2357cc
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"
15 #include <stdlib.h>
16 #include "logging.h"
18 int main(int argc, char *argv[])
20 struct tdb_context *tdb;
21 TDB_DATA key, data;
23 plan_tests(11);
24 tdb = tdb_open_ex("run-readonly-check.tdb", 1024,
25 TDB_DEFAULT,
26 O_CREAT|O_TRUNC|O_RDWR, 0600, &taplogctx, NULL);
28 ok1(tdb);
29 key.dsize = strlen("hi");
30 key.dptr = (void *)"hi";
31 data.dsize = strlen("world");
32 data.dptr = (void *)"world";
34 ok1(tdb_store(tdb, key, data, TDB_INSERT) == 0);
35 ok1(tdb_check(tdb, NULL, NULL) == 0);
37 /* We are also allowed to do a check inside a transaction. */
38 ok1(tdb_transaction_start(tdb) == 0);
39 ok1(tdb_check(tdb, NULL, NULL) == 0);
40 ok1(tdb_close(tdb) == 0);
42 tdb = tdb_open_ex("run-readonly-check.tdb", 1024,
43 TDB_DEFAULT, O_RDONLY, 0, &taplogctx, NULL);
45 ok1(tdb);
46 ok1(tdb_store(tdb, key, data, TDB_MODIFY) == -1);
47 ok1(tdb_error(tdb) == TDB_ERR_RDONLY);
48 ok1(tdb_check(tdb, NULL, NULL) == 0);
49 ok1(tdb_close(tdb) == 0);
51 return exit_status();