tdb: add test for tdb_summary
[ccan] / ccan / tdb / test / run-oldhash.c
1 #define _XOPEN_SOURCE 500
2 #include <ccan/tdb/tdb.h>
3 #include <ccan/tdb/io.c>
4 #include <ccan/tdb/tdb.c>
5 #include <ccan/tdb/lock.c>
6 #include <ccan/tdb/freelist.c>
7 #include <ccan/tdb/traverse.c>
8 #include <ccan/tdb/transaction.c>
9 #include <ccan/tdb/error.c>
10 #include <ccan/tdb/open.c>
11 #include <ccan/tdb/check.c>
12 #include <ccan/tdb/hash.c>
13 #include <ccan/tap/tap.h>
14 #include <stdlib.h>
15 #include <err.h>
16 #include "logging.h"
17
18 int main(int argc, char *argv[])
19 {
20         struct tdb_context *tdb;
21
22         plan_tests(8);
23
24         /* Old format (with zeroes in the hash magic fields) should
25          * open with any hash (since we don't know what hash they used). */
26         tdb = tdb_open_ex("test/old-nohash-le.tdb", 0, 0, O_RDWR, 0,
27                           &taplogctx, NULL);
28         ok1(tdb);
29         ok1(tdb_check(tdb, NULL, NULL) == 0);
30         tdb_close(tdb);
31
32         tdb = tdb_open_ex("test/old-nohash-be.tdb", 0, 0, O_RDWR, 0,
33                           &taplogctx, NULL);
34         ok1(tdb);
35         ok1(tdb_check(tdb, NULL, NULL) == 0);
36         tdb_close(tdb);
37
38         tdb = tdb_open_ex("test/old-nohash-le.tdb", 0, 0, O_RDWR, 0,
39                           &taplogctx, tdb_jenkins_hash);
40         ok1(tdb);
41         ok1(tdb_check(tdb, NULL, NULL) == 0);
42         tdb_close(tdb);
43
44         tdb = tdb_open_ex("test/old-nohash-be.tdb", 0, 0, O_RDWR, 0,
45                           &taplogctx, tdb_jenkins_hash);
46         ok1(tdb);
47         ok1(tdb_check(tdb, NULL, NULL) == 0);
48         tdb_close(tdb);
49
50         return exit_status();
51 }