]> git.ozlabs.org Git - ccan/blob - ccan/tdb2/test/run-tdb1-oldhash.c
185001db74b41876d1782a907aa04ca50c153450
[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 "logging.h"
6
7 int main(int argc, char *argv[])
8 {
9         struct tdb_context *tdb;
10         union tdb_attribute incompat_hash_attr;
11
12         incompat_hash_attr.base.attr = TDB_ATTRIBUTE_HASH;
13         incompat_hash_attr.base.next = &tap_log_attr;
14         incompat_hash_attr.hash.fn = tdb1_incompatible_hash;
15
16         plan_tests(8);
17
18         /* Old format (with zeroes in the hash magic fields) should
19          * open with any hash (since we don't know what hash they used). */
20         tdb = tdb_open("test/old-nohash-le.tdb1", TDB_VERSION1, O_RDWR, 0,
21                        &tap_log_attr);
22         ok1(tdb);
23         ok1(tdb1_check(tdb, NULL, NULL) == 0);
24         tdb_close(tdb);
25
26         tdb = tdb_open("test/old-nohash-be.tdb1", TDB_VERSION1, O_RDWR, 0,
27                        &tap_log_attr);
28         ok1(tdb);
29         ok1(tdb1_check(tdb, NULL, NULL) == 0);
30         tdb_close(tdb);
31
32         tdb = tdb_open("test/old-nohash-le.tdb1", TDB_VERSION1, O_RDWR, 0,
33                        &incompat_hash_attr);
34         ok1(tdb);
35         ok1(tdb1_check(tdb, NULL, NULL) == 0);
36         tdb_close(tdb);
37
38         tdb = tdb_open("test/old-nohash-be.tdb1", TDB_VERSION1, O_RDWR, 0,
39                        &incompat_hash_attr);
40         ok1(tdb);
41         ok1(tdb1_check(tdb, NULL, NULL) == 0);
42         tdb_close(tdb);
43
44         return exit_status();
45 }