tdb/test: fix up tests for use in SAMBA tdb code.
authorRusty Russell <rusty@rustcorp.com.au>
Tue, 14 Feb 2012 04:15:21 +0000 (14:45 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Tue, 14 Feb 2012 04:15:21 +0000 (14:45 +1030)
1) Make sure we include "tdb_private.h" first, to get the right headers
   (esp. the correct setting of _FILE_OFFSET_BITS before unistd.h).
2) Fix 3G file test since expand logic has changed.
3) Fix nested transaction test, since default is to allow nesting.
4) Capture fdatasync, which was slowing down transaction expand.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
lib/tdb/test/lock-tracking.c
lib/tdb/test/run-3G-file.c
lib/tdb/test/run-nested-transactions.c
lib/tdb/test/run-open-during-transaction.c
lib/tdb/test/run-transaction-expand.c

index e66dae75cd69cd56ca5aea710a0defb55fec8cd4..b6f1cc27d006b2b73d9bea1fb21ae348fe8fe164 100644 (file)
@@ -1,10 +1,10 @@
 /* We save the locks so we can reaquire them. */
+#include "../common/tdb_private.h"
 #include <unistd.h>
 #include <fcntl.h>
 #include <stdarg.h>
 #include <stdlib.h>
 #include "tap-interface.h"
-#include "../common/tdb_private.h"
 #include "lock-tracking.h"
 
 struct lock {
index ba85d1473e0de05b3d1c82a0a284c7400d1f1f8f..5ea4fcfbde21fcdfda120d7054ba23baae414037 100644 (file)
@@ -81,8 +81,8 @@ int main(int argc, char *argv[])
        ok1(tdb);
        tdb->methods = &large_io_methods;
 
-       /* Enlarge the file (internally multiplies by 100). */
-       ok1(tdb_expand(tdb, 30000000) == 0);
+       /* Enlarge the file (internally multiplies by 2). */
+       ok1(tdb_expand(tdb, 1500000000) == 0);
 
        /* Put an entry in, and check it. */
        key.dsize = strlen("hi");
index 7c83846c2e90c92398456374a804a7691042c857..c4765def341fa78cc3f129485d9ca2b389119c58 100644 (file)
@@ -26,11 +26,11 @@ int main(int argc, char *argv[])
        key.dptr = (void *)"hi";
 
        tdb = tdb_open_ex("run-nested-transactions.tdb",
-                         1024, TDB_CLEAR_IF_FIRST,
+                         1024, TDB_CLEAR_IF_FIRST|TDB_DISALLOW_NESTING,
                          O_CREAT|O_TRUNC|O_RDWR, 0600, &taplogctx, NULL);
        ok1(tdb);
 
-       /* No nesting by default. */
+       /* Nesting disallowed. */
        ok1(tdb_transaction_start(tdb) == 0);
        data.dptr = (void *)"world";
        data.dsize = strlen("world");
@@ -53,8 +53,9 @@ int main(int argc, char *argv[])
        free(data.dptr);
        tdb_close(tdb);
 
+       /* Nesting allowed by default */
        tdb = tdb_open_ex("run-nested-transactions.tdb",
-                         1024, TDB_ALLOW_NESTING, O_RDWR, 0, &taplogctx, NULL);
+                         1024, TDB_DEFAULT, O_RDWR, 0, &taplogctx, NULL);
        ok1(tdb);
 
        ok1(tdb_transaction_start(tdb) == 0);
index bd6e33d563f4f3419222377c6e57434337f61c6c..f4a00525d8d9d65237e60523f3f9c7446648198f 100644 (file)
@@ -1,5 +1,4 @@
-#define _XOPEN_SOURCE 500
-#include <unistd.h>
+#include "../common/tdb_private.h"
 #include "lock-tracking.h"
 
 static ssize_t pwrite_check(int fd, const void *buf, size_t count, off_t offset);
@@ -11,7 +10,6 @@ static int ftruncate_check(int fd, off_t length);
 #define fcntl fcntl_with_lockcheck
 #define ftruncate ftruncate_check
 
-#include "../common/tdb_private.h"
 #include "../common/io.c"
 #include "../common/tdb.c"
 #include "../common/lock.c"
index e43eec412bb0dec6cc384b82e3eca2cd2dab208f..3b79dbb6eaec3e46bf45b803b05879d355efd626 100644 (file)
@@ -1,6 +1,3 @@
-/* We need this otherwise fcntl locking fails. */
-#define _FILE_OFFSET_BITS 64
-#define _XOPEN_SOURCE 500
 #include "../common/tdb_private.h"
 
 /* Speed up the tests: setting TDB_NOSYNC removed recovery altogether. */
@@ -18,7 +15,14 @@ static inline int fake_msync(void *addr, size_t length, int flags)
 #define msync fake_msync
 #endif
 
-#include "../common/tdb_private.h"
+#ifdef HAVE_FDATASYNC
+static inline int fake_fdatasync(int fd)
+{
+       return 0;
+}
+#define fdatasync fake_fdatasync
+#endif
+
 #include "../common/io.c"
 #include "../common/tdb.c"
 #include "../common/lock.c"