tdb2: add -1 and -2 options to tdbtorture
authorRusty Russell <rusty@rustcorp.com.au>
Mon, 30 Jan 2012 05:29:16 +0000 (15:59 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Mon, 30 Jan 2012 05:29:16 +0000 (15:59 +1030)
(For now, -1 is the default).

lib/tdb2/tools/tdb2torture.c

index db6515d0cf517b81c192e07e507ff24c5c300d7c..83847da027f2c5b95b5c715a0709bf2aac929382 100644 (file)
@@ -16,6 +16,9 @@
 #include <time.h>
 #include <sys/wait.h>
 
+/* Currently we default to creating a tdb1.  This will change! */
+#define TDB2_IS_DEFAULT false
+
 //#define REOPEN_PROB 30
 #define DELETE_PROB 8
 #define STORE_PROB 4
@@ -346,14 +349,16 @@ int main(int argc, char * const *argv)
        int kill_random = 0;
        int *done;
        int tdb_flags = TDB_DEFAULT;
+       bool tdb2 = TDB2_IS_DEFAULT;
        char *test_tdb;
 
        log_attr.base.attr = TDB_ATTRIBUTE_LOG;
        log_attr.base.next = &seed_attr;
        log_attr.log.fn = tdb_log;
        seed_attr.base.attr = TDB_ATTRIBUTE_SEED;
+       seed_attr.base.next = NULL;
 
-       while ((c = getopt(argc, argv, "n:l:s:thkS")) != -1) {
+       while ((c = getopt(argc, argv, "n:l:s:thkS12")) != -1) {
                switch (c) {
                case 'n':
                        num_procs = strtol(optarg, NULL, 0);
@@ -378,11 +383,23 @@ int main(int argc, char * const *argv)
                case 'k':
                        kill_random = 1;
                        break;
+               case '1':
+                       tdb2 = false;
+                       break;
+               case '2':
+                       tdb2 = true;
+                       break;
                default:
                        usage();
                }
        }
 
+       if (!tdb2) {
+               tdb_flags |= TDB_VERSION1;
+               /* TDB1 tdbs don't use seed. */
+               log_attr.base.next = NULL;
+       }
+
        test_tdb = test_path("torture.tdb");
 
        unlink(test_tdb);