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 "../common/mutex.c"
13 #include "tap-interface.h"
17 int main(int argc
, char *argv
[])
19 struct tdb_context
*tdb
;
23 tdb
= tdb_open_ex("run-check.tdb", 1, TDB_CLEAR_IF_FIRST
,
24 O_CREAT
|O_TRUNC
|O_RDWR
, 0600, &taplogctx
, NULL
);
27 ok1(tdb_check(tdb
, NULL
, NULL
) == 0);
29 key
.dsize
= strlen("hi");
30 key
.dptr
= discard_const_p(uint8_t, "hi");
31 data
.dsize
= strlen("world");
32 data
.dptr
= discard_const_p(uint8_t, "world");
34 ok1(tdb_store(tdb
, key
, data
, TDB_INSERT
) == 0);
35 ok1(tdb_check(tdb
, NULL
, NULL
) == 0);
38 tdb
= tdb_open_ex("run-check.tdb", 1024, 0, O_RDWR
, 0,
41 ok1(tdb_check(tdb
, NULL
, NULL
) == 0);
44 tdb
= tdb_open_ex("test/tdb.corrupt", 1024, 0, O_RDWR
, 0,
47 ok1(tdb_check(tdb
, NULL
, NULL
) == -1);
48 ok1(tdb_error(tdb
) == TDB_ERR_CORRUPT
);
51 /* Big and little endian should work! */
52 tdb
= tdb_open_ex("test/old-nohash-le.tdb", 1024, 0, O_RDWR
, 0,
55 ok1(tdb_check(tdb
, NULL
, NULL
) == 0);
58 tdb
= tdb_open_ex("test/old-nohash-be.tdb", 1024, 0, O_RDWR
, 0,
61 ok1(tdb_check(tdb
, NULL
, NULL
) == 0);