1 #include "tdb2-source.h"
2 #include <ccan/tap/tap.h>
7 int main(int argc, char *argv[])
9 struct tdb_context *tdb;
13 tdb = tdb1_open("run-check.tdb", 1, TDB_DEFAULT,
14 O_CREAT|O_TRUNC|O_RDWR, 0600, &tap_log_attr);
17 ok1(tdb1_check(tdb, NULL, NULL) == 0);
19 key.dsize = strlen("hi");
20 key.dptr = (void *)"hi";
21 data.dsize = strlen("world");
22 data.dptr = (void *)"world";
24 ok1(tdb1_store(tdb, key, data, TDB_INSERT) == 0);
25 ok1(tdb1_check(tdb, NULL, NULL) == 0);
28 tdb = tdb1_open("run-check.tdb", 1024, 0, O_RDWR, 0,
31 ok1(tdb1_check(tdb, NULL, NULL) == 0);
34 tdb = tdb1_open("test/tdb1.corrupt", 1024, 0, O_RDWR, 0,
37 ok1(tdb1_check(tdb, NULL, NULL) == -1);
38 ok1(tdb_error(tdb) == TDB_ERR_CORRUPT);
41 /* Big and little endian should work! */
42 tdb = tdb1_open("test/old-nohash-le.tdb1", 1024, 0, O_RDWR, 0,
45 ok1(tdb1_check(tdb, NULL, NULL) == 0);
48 tdb = tdb1_open("test/old-nohash-be.tdb1", 1024, 0, O_RDWR, 0,
51 ok1(tdb1_check(tdb, NULL, NULL) == 0);