3 #include "tap-interface.h"
11 int main(int argc
, char *argv
[])
14 struct ntdb_context
*ntdb
;
15 int flags
[] = { NTDB_DEFAULT
, NTDB_NOMMAP
,
16 NTDB_CONVERT
, NTDB_NOMMAP
|NTDB_CONVERT
};
18 plan_tests(sizeof(flags
) / sizeof(flags
[0]) * 11);
20 for (i
= 0; i
< sizeof(flags
) / sizeof(flags
[0]); i
++) {
21 union ntdb_attribute
*attr
;
22 NTDB_DATA key
= ntdb_mkdata("key", 3), data
;
24 ntdb
= ntdb_open("run-91-get-stats.ntdb", flags
[i
]|MAYBE_NOSYNC
,
25 O_RDWR
|O_CREAT
|O_TRUNC
, 0600, &tap_log_attr
);
27 /* Force an expansion */
29 data
.dptr
= calloc(data
.dsize
, 1);
30 ok1(ntdb_store(ntdb
, key
, data
, NTDB_REPLACE
) == 0);
33 /* Use malloc so valgrind will catch overruns. */
34 attr
= malloc(sizeof *attr
);
35 attr
->stats
.base
.attr
= NTDB_ATTRIBUTE_STATS
;
36 attr
->stats
.size
= sizeof(*attr
);
38 ok1(ntdb_get_attribute(ntdb
, attr
) == 0);
39 ok1(attr
->stats
.size
== sizeof(*attr
));
40 ok1(attr
->stats
.allocs
> 0);
41 ok1(attr
->stats
.expands
> 0);
42 ok1(attr
->stats
.locks
> 0);
46 attr
= malloc(offsetof(struct ntdb_attribute_stats
, allocs
)
47 + sizeof(attr
->stats
.allocs
));
48 attr
->stats
.base
.attr
= NTDB_ATTRIBUTE_STATS
;
49 attr
->stats
.size
= offsetof(struct ntdb_attribute_stats
, allocs
)
50 + sizeof(attr
->stats
.allocs
);
51 ok1(ntdb_get_attribute(ntdb
, attr
) == 0);
52 ok1(attr
->stats
.size
== sizeof(*attr
));
53 ok1(attr
->stats
.allocs
> 0);
55 ok1(tap_log_messages
== 0);