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