1 #include "tdb2-source.h"
2 #include "tap-interface.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(tdb_check(tdb, NULL, NULL) == TDB_SUCCESS);
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);
31 tdb = tdb_open("run-check.tdb1", TDB_VERSION1, O_RDWR, 0, &tap_log_attr);
33 ok1(tdb_check(tdb, NULL, NULL) == TDB_SUCCESS);
36 tdb = tdb_open("test/tdb1.corrupt", TDB_VERSION1, O_RDWR, 0,
39 ok1(tdb_check(tdb, NULL, NULL) == TDB_ERR_CORRUPT);
40 ok1(tdb_error(tdb) == TDB_ERR_CORRUPT);
43 /* Big and little endian should work! */
44 tdb = tdb_open("test/old-nohash-le.tdb1", TDB_VERSION1, O_RDWR, 0,
47 ok1(tdb_check(tdb, NULL, NULL) == TDB_SUCCESS);
50 tdb = tdb_open("test/old-nohash-be.tdb1", TDB_VERSION1, O_RDWR, 0,
53 ok1(tdb_check(tdb, NULL, NULL) == TDB_SUCCESS);