tdb2: unify tdb1_store into tdb_store
[ccan] / ccan / tdb2 / test / run-tdb1-summary.c
index ccfc0958e11a1cdcef3689d459b79faef3c97f9b..5107b8e4363616569d7b83e432bcd1e8c07892f9 100644 (file)
@@ -6,18 +6,18 @@
 int main(int argc, char *argv[])
 {
        unsigned int i, j;
 int main(int argc, char *argv[])
 {
        unsigned int i, j;
-       struct tdb1_context *tdb;
-       int flags[] = { TDB1_INTERNAL, TDB1_DEFAULT, TDB1_NOMMAP,
-                       TDB1_INTERNAL|TDB1_CONVERT, TDB1_CONVERT,
-                       TDB1_NOMMAP|TDB1_CONVERT };
-       TDB1_DATA key = { (unsigned char *)&j, sizeof(j) };
-       TDB1_DATA data = { (unsigned char *)&j, sizeof(j) };
+       struct tdb_context *tdb;
+       int flags[] = { TDB_INTERNAL, TDB_DEFAULT, TDB_NOMMAP,
+                       TDB_INTERNAL|TDB_CONVERT, TDB_CONVERT,
+                       TDB_NOMMAP|TDB_CONVERT };
+       TDB_DATA key = { (unsigned char *)&j, sizeof(j) };
+       TDB_DATA data = { (unsigned char *)&j, sizeof(j) };
        char *summary;
 
        plan_tests(sizeof(flags) / sizeof(flags[0]) * 14);
        for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) {
        char *summary;
 
        plan_tests(sizeof(flags) / sizeof(flags[0]) * 14);
        for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) {
-               tdb = tdb1_open("run-summary.tdb", 131, flags[i],
-                              O_RDWR|O_CREAT|O_TRUNC, 0600);
+               tdb = tdb_open("run-summary.tdb1", flags[i]|TDB_VERSION1,
+                              O_RDWR|O_CREAT|O_TRUNC, 0600, NULL);
                ok1(tdb);
                if (!tdb)
                        continue;
                ok1(tdb);
                if (!tdb)
                        continue;
@@ -26,8 +26,10 @@ int main(int argc, char *argv[])
                for (j = 0; j < 500; j++) {
                        /* Make sure padding varies to we get some graphs! */
                        data.dsize = j % (sizeof(j) + 1);
                for (j = 0; j < 500; j++) {
                        /* Make sure padding varies to we get some graphs! */
                        data.dsize = j % (sizeof(j) + 1);
-                       if (tdb1_store(tdb, key, data, TDB1_REPLACE) != 0)
+                       if (tdb_store(tdb, key, data, TDB_REPLACE)
+                           != TDB_SUCCESS) {
                                fail("Storing in tdb");
                                fail("Storing in tdb");
+                       }
                }
 
                summary = tdb1_summary(tdb);
                }
 
                summary = tdb1_summary(tdb);
@@ -47,7 +49,7 @@ int main(int argc, char *argv[])
                ok1(strstr(summary, "Percentage keys/data/padding/free/dead/rechdrs&tailers/hashes: "));
 
                free(summary);
                ok1(strstr(summary, "Percentage keys/data/padding/free/dead/rechdrs&tailers/hashes: "));
 
                free(summary);
-               tdb1_close(tdb);
+               tdb_close(tdb);
        }
 
        return exit_status();
        }
 
        return exit_status();