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 = tdb_open("run-check.tdb1", TDB_VERSION1,
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 = tdb_open("run-check.tdb1", TDB_VERSION1, O_RDWR, 0, &tap_log_attr);
35 ok1(tdb1_check(tdb, NULL, NULL) == 0);
38 tdb = tdb_open("test/tdb1.corrupt", TDB_VERSION1, O_RDWR, 0,
41 ok1(tdb1_check(tdb, NULL, NULL) == -1);
42 ok1(tdb_error(tdb) == TDB_ERR_CORRUPT);
45 /* Big and little endian should work! */
46 tdb = tdb_open("test/old-nohash-le.tdb1", TDB_VERSION1, O_RDWR, 0,
49 ok1(tdb1_check(tdb, NULL, NULL) == 0);
52 tdb = tdb_open("test/old-nohash-be.tdb1", TDB_VERSION1, O_RDWR, 0,
55 ok1(tdb1_check(tdb, NULL, NULL) == 0);