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(tdb_check(tdb
, NULL
, NULL
) == TDB_SUCCESS
);
24 key
.dsize
= strlen("hi");
25 key
.dptr
= (void *)"hi";
26 data
.dsize
= strlen("world");
27 data
.dptr
= (void *)"world";
29 ok1(tdb_store(tdb
, key
, data
, TDB_INSERT
) == TDB_SUCCESS
);
30 ok1(tdb_check(tdb
, NULL
, NULL
) == TDB_SUCCESS
);
33 tdb
= tdb_open("run-check.tdb1", TDB_VERSION1
, O_RDWR
, 0, &tap_log_attr
);
35 ok1(tdb_check(tdb
, NULL
, NULL
) == TDB_SUCCESS
);
38 tdb
= tdb_open("test/tdb1.corrupt", TDB_VERSION1
, O_RDWR
, 0,
41 ok1(tdb_check(tdb
, NULL
, NULL
) == TDB_ERR_CORRUPT
);
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(tdb_check(tdb
, NULL
, NULL
) == TDB_SUCCESS
);
52 tdb
= tdb_open("test/old-nohash-be.tdb1", TDB_VERSION1
, O_RDWR
, 0,
55 ok1(tdb_check(tdb
, NULL
, NULL
) == TDB_SUCCESS
);