LCOV - code coverage report
Current view: top level - lib/tdb/test - run-summary.c (source / functions) Hit Total Coverage
Test: coverage report for abartlet/fix-coverage dd10fb34 Lines: 29 31 93.5 %
Date: 2021-09-23 10:06:22 Functions: 1 1 100.0 %

          Line data    Source code
       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 "../common/mutex.c"
      14             : #include "tap-interface.h"
      15             : #include <stdlib.h>
      16             : 
      17           1 : int main(int argc, char *argv[])
      18             : {
      19             :         unsigned int i, j;
      20             :         struct tdb_context *tdb;
      21           1 :         int flags[] = { TDB_INTERNAL, TDB_DEFAULT, TDB_NOMMAP,
      22             :                         TDB_INTERNAL|TDB_CONVERT, TDB_CONVERT,
      23             :                         TDB_NOMMAP|TDB_CONVERT };
      24           1 :         TDB_DATA key = { (unsigned char *)&j, sizeof(j) };
      25           1 :         TDB_DATA data = { (unsigned char *)&j, sizeof(j) };
      26             :         char *summary;
      27             : 
      28             :         plan_tests(sizeof(flags) / sizeof(flags[0]) * 14);
      29           7 :         for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) {
      30           6 :                 tdb = tdb_open("run-summary.tdb", 131, flags[i],
      31             :                                O_RDWR|O_CREAT|O_TRUNC, 0600);
      32           6 :                 ok1(tdb);
      33           6 :                 if (!tdb)
      34           0 :                         continue;
      35             : 
      36             :                 /* Put some stuff in there. */
      37        3006 :                 for (j = 0; j < 500; j++) {
      38             :                         /* Make sure padding varies to we get some graphs! */
      39        3000 :                         data.dsize = j % (sizeof(j) + 1);
      40        3000 :                         if (tdb_store(tdb, key, data, TDB_REPLACE) != 0)
      41           0 :                                 fail("Storing in tdb");
      42             :                 }
      43             : 
      44           6 :                 summary = tdb_summary(tdb);
      45           6 :                 diag("%s", summary);
      46           6 :                 ok1(strstr(summary, "Size of file/data: "));
      47           6 :                 ok1(strstr(summary, "Number of records: 500\n"));
      48           6 :                 ok1(strstr(summary, "Smallest/average/largest keys: 4/4/4\n"));
      49           6 :                 ok1(strstr(summary, "Smallest/average/largest data: 0/2/4\n"));
      50           6 :                 ok1(strstr(summary, "Smallest/average/largest padding: "));
      51           6 :                 ok1(strstr(summary, "Number of dead records: 0\n"));
      52           6 :                 ok1(strstr(summary, "Number of free records: 1\n"));
      53           6 :                 ok1(strstr(summary, "Smallest/average/largest free records: "));
      54           6 :                 ok1(strstr(summary, "Number of hash chains: 131\n"));
      55           6 :                 ok1(strstr(summary, "Smallest/average/largest hash chains: "));
      56           6 :                 ok1(strstr(summary, "Number of uncoalesced records: 0\n"));
      57           6 :                 ok1(strstr(summary, "Smallest/average/largest uncoalesced runs: 0/0/0\n"));
      58           6 :                 ok1(strstr(summary, "Percentage keys/data/padding/free/dead/rechdrs&tailers/hashes: "));
      59             : 
      60           6 :                 free(summary);
      61           6 :                 tdb_close(tdb);
      62             :         }
      63             : 
      64           1 :         return exit_status();
      65             : }

Generated by: LCOV version 1.13