1 #include "tdb2-source.h"
2 #include <ccan/tap/tap.h>
5 int main(int argc, char *argv[])
8 struct tdb_context *tdb;
9 int flags[] = { TDB_INTERNAL, TDB_DEFAULT, TDB_NOMMAP,
10 TDB_INTERNAL|TDB_CONVERT, TDB_CONVERT,
11 TDB_NOMMAP|TDB_CONVERT };
12 struct tdb_data key = { (unsigned char *)&j, sizeof(j) };
13 struct tdb_data data = { (unsigned char *)&j, sizeof(j) };
16 plan_tests(sizeof(flags) / sizeof(flags[0]) * (1 + 2 * 5) + 1);
17 for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) {
18 tdb = tdb_open("run-summary.tdb", flags[i],
19 O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr);
24 /* Put some stuff in there. */
25 for (j = 0; j < 500; j++) {
26 /* Make sure padding varies to we get some graphs! */
27 data.dsize = j % (sizeof(j) + 1);
28 if (tdb_store(tdb, key, data, TDB_REPLACE) != 0)
29 fail("Storing in tdb");
33 j <= TDB_SUMMARY_HISTOGRAMS;
34 j += TDB_SUMMARY_HISTOGRAMS) {
35 ok1(tdb_summary(tdb, j, &summary) == TDB_SUCCESS);
36 ok1(strstr(summary, "Number of records: 500\n"));
37 ok1(strstr(summary, "Smallest/average/largest keys: 4/4/4\n"));
38 ok1(strstr(summary, "Smallest/average/largest data: 0/2/4\n"));
39 if (j == TDB_SUMMARY_HISTOGRAMS)
40 ok1(strstr(summary, "|")
41 && strstr(summary, "*"));
43 ok1(!strstr(summary, "|")
44 && !strstr(summary, "*"));
50 ok1(tap_log_messages == 0);