tdb2: speed up testing.
authorRusty Russell <rusty@rustcorp.com.au>
Tue, 13 Sep 2011 22:43:26 +0000 (08:13 +0930)
committerRusty Russell <rusty@rustcorp.com.au>
Tue, 13 Sep 2011 22:43:26 +0000 (08:13 +0930)
The time to run tests under valgrind has become excessive; particularly
the failure tests which fork().   Thus we cut down testing:

1) api-94-repack: reduce from 234 seconds to 2 seconds by cutting
   iterations, despite adding TDB_VERSION1 tests.

2) api-missing-entries: reduce from 17 seconds to under 1 second by
   not checking db inside loop, but at end.

This reduces the total ccanlint time from 729 to 489 seconds.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
(Imported from CCAN commit a99c2ccf97465d47c3277d997ea93f20ff97ad4d)

lib/tdb2/test/api-93-repack.c
lib/tdb2/test/api-missing-entries.c

index 0a2e6d5b82e79ac943ddca47807e2b15430d2c45..74a8b5eda218c852ce80f743229f7b09870a59a0 100644 (file)
@@ -5,7 +5,7 @@
 #include <fcntl.h>
 #include "logging.h"
 
-#define NUM_TESTS 50000
+#define NUM_TESTS 1000
 
 static bool store_all(struct tdb_context *tdb)
 {
@@ -53,6 +53,9 @@ int main(int argc, char *argv[])
        struct tdb_context *tdb;
        int flags[] = { TDB_DEFAULT, TDB_NOMMAP,
                        TDB_CONVERT, TDB_NOMMAP|TDB_CONVERT,
+                       TDB_VERSION1, TDB_VERSION1|TDB_NOMMAP,
+                       TDB_VERSION1|TDB_CONVERT,
+                       TDB_VERSION1|TDB_NOMMAP|TDB_CONVERT
        };
 
        plan_tests(sizeof(flags) / sizeof(flags[0]) * 6 + 1);
index 1932947a3a894a90fde7a848838406c91e7e2e9c..0b21e1ee0f854564a0202b1341a4e5e93fb6edab 100644 (file)
@@ -26,16 +26,15 @@ int main(int argc, char *argv[])
                                                .fn = failhash } };
 
        hattr.base.next = &tap_log_attr;
-       plan_tests(1 + 2 * NUM_RECORDS + 1);
+       plan_tests(1 + NUM_RECORDS + 2);
 
        tdb = tdb_open("run-missing-entries.tdb", TDB_INTERNAL,
                       O_RDWR|O_CREAT|O_TRUNC, 0600, &hattr);
-       ok1(tdb);
-       if (tdb) {
+       if (ok1(tdb)) {
                for (i = 0; i < NUM_RECORDS; i++) {
                        ok1(tdb_store(tdb, key, data, TDB_REPLACE) == 0);
-                       ok1(tdb_check(tdb, NULL, NULL) == 0);
                }
+               ok1(tdb_check(tdb, NULL, NULL) == 0);
                tdb_close(tdb);
        }