tdb2: test: import tdb1's tests.
[ccan] / ccan / tdb2 / test / run-tdb1-oldhash.c
1 #include "tdb2-source.h"
2 #include <ccan/tap/tap.h>
3 #include <stdlib.h>
4 #include <err.h>
5 #include "tdb1-logging.h"
6
7 int main(int argc, char *argv[])
8 {
9         struct tdb1_context *tdb;
10
11         plan_tests(8);
12
13         /* Old format (with zeroes in the hash magic fields) should
14          * open with any hash (since we don't know what hash they used). */
15         tdb = tdb1_open_ex("test/old-nohash-le.tdb1", 0, 0, O_RDWR, 0,
16                           &taplogctx, NULL);
17         ok1(tdb);
18         ok1(tdb1_check(tdb, NULL, NULL) == 0);
19         tdb1_close(tdb);
20
21         tdb = tdb1_open_ex("test/old-nohash-be.tdb1", 0, 0, O_RDWR, 0,
22                           &taplogctx, NULL);
23         ok1(tdb);
24         ok1(tdb1_check(tdb, NULL, NULL) == 0);
25         tdb1_close(tdb);
26
27         tdb = tdb1_open_ex("test/old-nohash-le.tdb1", 0, 0, O_RDWR, 0,
28                           &taplogctx, tdb1_jenkins_hash);
29         ok1(tdb);
30         ok1(tdb1_check(tdb, NULL, NULL) == 0);
31         tdb1_close(tdb);
32
33         tdb = tdb1_open_ex("test/old-nohash-be.tdb1", 0, 0, O_RDWR, 0,
34                           &taplogctx, tdb1_jenkins_hash);
35         ok1(tdb);
36         ok1(tdb1_check(tdb, NULL, NULL) == 0);
37         tdb1_close(tdb);
38
39         return exit_status();
40 }