1 #include "tdb2-source.h"
2 #include <ccan/tap/tap.h>
7 int main(int argc, char *argv[])
9 struct tdb_context *tdb;
11 union tdb_attribute hsize;
13 hsize.base.attr = TDB_ATTRIBUTE_TDB1_HASHSIZE;
14 hsize.base.next = &tap_log_attr;
15 hsize.tdb1_hashsize.hsize = 1;
18 tdb = tdb1_open("run-check.tdb", TDB_DEFAULT,
19 O_CREAT|O_TRUNC|O_RDWR, 0600, &hsize);
22 ok1(tdb1_check(tdb, NULL, NULL) == 0);
24 key.dsize = strlen("hi");
25 key.dptr = (void *)"hi";
26 data.dsize = strlen("world");
27 data.dptr = (void *)"world";
29 ok1(tdb1_store(tdb, key, data, TDB_INSERT) == 0);
30 ok1(tdb1_check(tdb, NULL, NULL) == 0);
33 tdb = tdb1_open("run-check.tdb", 0, O_RDWR, 0,
36 ok1(tdb1_check(tdb, NULL, NULL) == 0);
39 tdb = tdb1_open("test/tdb1.corrupt", 0, O_RDWR, 0,
42 ok1(tdb1_check(tdb, NULL, NULL) == -1);
43 ok1(tdb_error(tdb) == TDB_ERR_CORRUPT);
46 /* Big and little endian should work! */
47 tdb = tdb1_open("test/old-nohash-le.tdb1", 0, O_RDWR, 0,
50 ok1(tdb1_check(tdb, NULL, NULL) == 0);
53 tdb = tdb1_open("test/old-nohash-be.tdb1", 0, O_RDWR, 0,
56 ok1(tdb1_check(tdb, NULL, NULL) == 0);