1 #include "tdb2-source.h"
2 #include <ccan/tap/tap.h>
7 int main(int argc, char *argv[])
9 struct tdb_context *tdb;
10 union tdb_attribute hsize, h2;
12 hsize.base.attr = TDB_ATTRIBUTE_TDB1_HASHSIZE;
13 hsize.base.next = &tap_log_attr;
14 hsize.tdb1_hashsize.hsize = 1024;
17 tdb = tdb_open("run-tdb1-hashsize.tdb1", TDB_VERSION1,
18 O_CREAT|O_TRUNC|O_RDWR, 0600, &hsize);
20 h2.base.attr = TDB_ATTRIBUTE_TDB1_HASHSIZE;
21 ok1(tdb_get_attribute(tdb, &h2) == TDB_SUCCESS);
22 ok1(h2.tdb1_hashsize.hsize == hsize.tdb1_hashsize.hsize);
25 /* Can't specify TDB_ATTRIBUTE_TDB1_HASHSIZE without O_CREAT */
26 tdb = tdb_open("run-tdb1-hashsize.tdb1", TDB_VERSION1,
27 O_RDWR, 0600, &hsize);
29 ok1(tap_log_messages == 1);
31 /* Can't specify TDB_ATTRIBUTE_TDB1_HASHSIZE for version2. */
32 tdb = tdb_open("run-tdb1-hashsize.tdb", TDB_DEFAULT,
33 O_CREAT|O_TRUNC|O_RDWR, 0600, &hsize);
35 ok1(tap_log_messages == 2);
37 /* We can get attribute even if we didn't set it though. */
38 tdb = tdb_open("run-tdb1-hashsize.tdb1", TDB_DEFAULT,
39 O_RDWR, 0600, &tap_log_attr);
42 memset(&h2, 0, sizeof(h2));
43 h2.base.attr = TDB_ATTRIBUTE_TDB1_HASHSIZE;
44 ok1(tdb_get_attribute(tdb, &h2) == TDB_SUCCESS);
45 ok1(h2.tdb1_hashsize.hsize == hsize.tdb1_hashsize.hsize);
48 /* Check for default hash size. */
49 tdb = tdb_open("run-tdb1-hashsize.tdb1", TDB_VERSION1,
50 O_CREAT|O_TRUNC|O_RDWR, 0600, &tap_log_attr);
53 memset(&h2, 0, sizeof(h2));
54 h2.base.attr = TDB_ATTRIBUTE_TDB1_HASHSIZE;
55 ok1(tdb_get_attribute(tdb, &h2) == TDB_SUCCESS);
56 ok1(h2.tdb1_hashsize.hsize == TDB1_DEFAULT_HASH_SIZE);
58 ok1(tap_log_messages == 2);