s3:lib/events: s/EVENT_FD/TEVENT_FD
[Samba/gebeck_regimport.git] / lib / tdb / test / run-summary.c
blob22312843e79ec9dab4580271f86e023ebb53155b
1 #include "../common/tdb_private.h"
2 #include "../common/io.c"
3 #include "../common/tdb.c"
4 #include "../common/lock.c"
5 #include "../common/freelist.c"
6 #include "../common/traverse.c"
7 #include "../common/transaction.c"
8 #include "../common/error.c"
9 #include "../common/open.c"
10 #include "../common/check.c"
11 #include "../common/hash.c"
12 #include "../common/summary.c"
13 #include "tap-interface.h"
14 #include <stdlib.h>
16 int main(int argc, char *argv[])
18 unsigned int i, j;
19 struct tdb_context *tdb;
20 int flags[] = { TDB_INTERNAL, TDB_DEFAULT, TDB_NOMMAP,
21 TDB_INTERNAL|TDB_CONVERT, TDB_CONVERT,
22 TDB_NOMMAP|TDB_CONVERT };
23 TDB_DATA key = { (unsigned char *)&j, sizeof(j) };
24 TDB_DATA data = { (unsigned char *)&j, sizeof(j) };
25 char *summary;
27 plan_tests(sizeof(flags) / sizeof(flags[0]) * 14);
28 for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) {
29 tdb = tdb_open("run-summary.tdb", 131, flags[i],
30 O_RDWR|O_CREAT|O_TRUNC, 0600);
31 ok1(tdb);
32 if (!tdb)
33 continue;
35 /* Put some stuff in there. */
36 for (j = 0; j < 500; j++) {
37 /* Make sure padding varies to we get some graphs! */
38 data.dsize = j % (sizeof(j) + 1);
39 if (tdb_store(tdb, key, data, TDB_REPLACE) != 0)
40 fail("Storing in tdb");
43 summary = tdb_summary(tdb);
44 diag("%s", summary);
45 ok1(strstr(summary, "Size of file/data: "));
46 ok1(strstr(summary, "Number of records: 500\n"));
47 ok1(strstr(summary, "Smallest/average/largest keys: 4/4/4\n"));
48 ok1(strstr(summary, "Smallest/average/largest data: 0/2/4\n"));
49 ok1(strstr(summary, "Smallest/average/largest padding: "));
50 ok1(strstr(summary, "Number of dead records: 0\n"));
51 ok1(strstr(summary, "Number of free records: 1\n"));
52 ok1(strstr(summary, "Smallest/average/largest free records: "));
53 ok1(strstr(summary, "Number of hash chains: 131\n"));
54 ok1(strstr(summary, "Smallest/average/largest hash chains: "));
55 ok1(strstr(summary, "Number of uncoalesced records: 0\n"));
56 ok1(strstr(summary, "Smallest/average/largest uncoalesced runs: 0/0/0\n"));
57 ok1(strstr(summary, "Percentage keys/data/padding/free/dead/rechdrs&tailers/hashes: "));
59 free(summary);
60 tdb_close(tdb);
63 return exit_status();