1 #include "../common/tdb_private.h"
2 #include "../common/io.c"
3 #include "../common/tdb.c"
4 #include "../common/lock.c"
5 #include "../common/freelist.c"
6 #include "../common/traverse.c"
7 #include "../common/transaction.c"
8 #include "../common/error.c"
9 #include "../common/open.c"
10 #include "../common/check.c"
11 #include "../common/hash.c"
12 #include "tap-interface.h"
16 int main(int argc
, char *argv
[])
18 struct tdb_context
*tdb
;
22 tdb
= tdb_open_ex("run-check.tdb", 1, TDB_CLEAR_IF_FIRST
,
23 O_CREAT
|O_TRUNC
|O_RDWR
, 0600, &taplogctx
, NULL
);
26 ok1(tdb_check(tdb
, NULL
, NULL
) == 0);
28 key
.dsize
= strlen("hi");
29 key
.dptr
= (void *)"hi";
30 data
.dsize
= strlen("world");
31 data
.dptr
= (void *)"world";
33 ok1(tdb_store(tdb
, key
, data
, TDB_INSERT
) == 0);
34 ok1(tdb_check(tdb
, NULL
, NULL
) == 0);
37 tdb
= tdb_open_ex("run-check.tdb", 1024, 0, O_RDWR
, 0,
40 ok1(tdb_check(tdb
, NULL
, NULL
) == 0);
43 tdb
= tdb_open_ex("test/tdb.corrupt", 1024, 0, O_RDWR
, 0,
46 ok1(tdb_check(tdb
, NULL
, NULL
) == -1);
47 ok1(tdb_error(tdb
) == TDB_ERR_CORRUPT
);
50 /* Big and little endian should work! */
51 tdb
= tdb_open_ex("test/old-nohash-le.tdb", 1024, 0, O_RDWR
, 0,
54 ok1(tdb_check(tdb
, NULL
, NULL
) == 0);
57 tdb
= tdb_open_ex("test/old-nohash-be.tdb", 1024, 0, O_RDWR
, 0,
60 ok1(tdb_check(tdb
, NULL
, NULL
) == 0);