]> git.ozlabs.org Git - ccan/blob - ccan/tdb2/test/run-tdb1-oldhash.c
tdb2: add TDB_ATTRIBUTE_TDB1_HASHSIZE
[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 = tdb1_open("test/old-nohash-le.tdb1", 0, O_RDWR, 0,
21                         &tap_log_attr);
22         ok1(tdb);
23         ok1(tdb1_check(tdb, NULL, NULL) == 0);
24         tdb1_close(tdb);
25
26         tdb = tdb1_open("test/old-nohash-be.tdb1", 0, O_RDWR, 0,
27                         &tap_log_attr);
28         ok1(tdb);
29         ok1(tdb1_check(tdb, NULL, NULL) == 0);
30         tdb1_close(tdb);
31
32         tdb = tdb1_open("test/old-nohash-le.tdb1", 0, O_RDWR, 0,
33                         &incompat_hash_attr);
34         ok1(tdb);
35         ok1(tdb1_check(tdb, NULL, NULL) == 0);
36         tdb1_close(tdb);
37
38         tdb = tdb1_open("test/old-nohash-be.tdb1", 0, O_RDWR, 0,
39                         &incompat_hash_attr);
40         ok1(tdb);
41         ok1(tdb1_check(tdb, NULL, NULL) == 0);
42         tdb1_close(tdb);
43
44         return exit_status();
45 }