tdb2: make sure summary always has a graph in it.
authorRusty Russell <rusty@rustcorp.com.au>
Sun, 26 Sep 2010 07:30:32 +0000 (17:00 +0930)
committerRusty Russell <rusty@rustcorp.com.au>
Sun, 26 Sep 2010 07:30:32 +0000 (17:00 +0930)
We were getting occasional failures: if all values are the same it's a 1-line
graph and there's no "|" anywhere.

ccan/tdb2/test/run-summary.c

index d6ccf2fa7c570801f2802322e0dc3d3d238d7b2c..aff678da406cd5c747eb021100c0254155d5c6c4 100644 (file)
@@ -28,9 +28,12 @@ int main(int argc, char *argv[])
                        continue;
 
                /* Put some stuff in there. */
                        continue;
 
                /* Put some stuff in there. */
-               for (j = 0; j < 500; j++)
+               for (j = 0; j < 500; j++) {
+                       /* Make sure padding varies to we get some graphs! */
+                       data.dsize = j % (sizeof(j) + 1);
                        if (tdb_store(tdb, key, data, TDB_REPLACE) != 0)
                                fail("Storing in tdb");
                        if (tdb_store(tdb, key, data, TDB_REPLACE) != 0)
                                fail("Storing in tdb");
+               }
 
                for (j = 0;
                     j <= TDB_SUMMARY_HISTOGRAMS;
 
                for (j = 0;
                     j <= TDB_SUMMARY_HISTOGRAMS;
@@ -38,7 +41,7 @@ int main(int argc, char *argv[])
                        summary = tdb_summary(tdb, j);
                        ok1(strstr(summary, "Number of records: 500\n"));
                        ok1(strstr(summary, "Smallest/average/largest keys: 4/4/4\n"));
                        summary = tdb_summary(tdb, j);
                        ok1(strstr(summary, "Number of records: 500\n"));
                        ok1(strstr(summary, "Smallest/average/largest keys: 4/4/4\n"));
-                       ok1(strstr(summary, "Smallest/average/largest data: 4/4/4\n"));
+                       ok1(strstr(summary, "Smallest/average/largest data: 0/2/4\n"));
                        ok1(strstr(summary, "Free bucket 8"));
                        ok1(strstr(summary, "Free bucket 16"));
                        ok1(strstr(summary, "Free bucket 24"));
                        ok1(strstr(summary, "Free bucket 8"));
                        ok1(strstr(summary, "Free bucket 16"));
                        ok1(strstr(summary, "Free bucket 24"));