ntdb: fix occasional abort in testing.
authorRusty Russell <rusty@rustcorp.com.au>
Wed, 20 Jun 2012 12:01:21 +0000 (21:31 +0930)
committerRusty Russell <rusty@rustcorp.com.au>
Wed, 20 Jun 2012 14:50:20 +0000 (16:50 +0200)
Occasionally, the capability test inserts multiple used records and they
clash, but our primitive test layout engine doesn't handle hash clashes
and aborts.

Force a seed value which we know doesn't clash.

Reported-by: Andrew Bartlett <abartlet@samba.org>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Autobuild-User(master): Rusty Russell <rusty@rustcorp.com.au>
Autobuild-Date(master): Wed Jun 20 16:50:20 CEST 2012 on sn-devel-104

lib/ntdb/test/run-capabilities.c

index cb037468626918f9d6c589213846a0cc112d56d3..6503214c062ae4a8932a519da04b78fe6b419119 100644 (file)
@@ -30,6 +30,12 @@ static void create_ntdb(const char *name,
        struct ntdb_layout *layout;
        struct ntdb_context *ntdb;
        int fd, clen;
+       union ntdb_attribute seed_attr;
+
+       /* Force a seed which doesn't allow records to clash! */
+       seed_attr.base.attr = NTDB_ATTRIBUTE_SEED;
+       seed_attr.base.next = &tap_log_attr;
+       seed_attr.seed.seed = 0;
 
        key = ntdb_mkdata("Hello", 5);
        data = ntdb_mkdata("world", 5);
@@ -61,7 +67,7 @@ static void create_ntdb(const char *name,
        va_end(ap);
 
        /* We open-code this, because we need to use the failtest write. */
-       ntdb = ntdb_layout_get(layout, failtest_free, &tap_log_attr);
+       ntdb = ntdb_layout_get(layout, failtest_free, &seed_attr);
 
        fd = open(name, O_RDWR|O_TRUNC|O_CREAT, 0600);
        if (fd < 0)