summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2012-02-14 14:45:21 +1030
committerRusty Russell <rusty@rustcorp.com.au>2012-02-14 14:45:21 +1030
commit205242e1769f96e0e8fccd52378965d35dd02093 (patch)
tree5bce8a0d01f0f6dd2360b93033934d27a93d9eef
parent8fa345d952328c5866f3a0f835f3599343c51b00 (diff)
downloadsamba-205242e1769f96e0e8fccd52378965d35dd02093.tar.gz
samba-205242e1769f96e0e8fccd52378965d35dd02093.tar.xz
samba-205242e1769f96e0e8fccd52378965d35dd02093.zip
tdb/test: fix up tests for use in SAMBA tdb code.
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>
-rw-r--r--lib/tdb/test/lock-tracking.c2
-rw-r--r--lib/tdb/test/run-3G-file.c4
-rw-r--r--lib/tdb/test/run-nested-transactions.c7
-rw-r--r--lib/tdb/test/run-open-during-transaction.c4
-rw-r--r--lib/tdb/test/run-transaction-expand.c12
5 files changed, 16 insertions, 13 deletions
diff --git a/lib/tdb/test/lock-tracking.c b/lib/tdb/test/lock-tracking.c
index e66dae75cd6..b6f1cc27d00 100644
--- a/lib/tdb/test/lock-tracking.c
+++ b/lib/tdb/test/lock-tracking.c
@@ -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 {
diff --git a/lib/tdb/test/run-3G-file.c b/lib/tdb/test/run-3G-file.c
index ba85d1473e0..5ea4fcfbde2 100644
--- a/lib/tdb/test/run-3G-file.c
+++ b/lib/tdb/test/run-3G-file.c
@@ -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");
diff --git a/lib/tdb/test/run-nested-transactions.c b/lib/tdb/test/run-nested-transactions.c
index 7c83846c2e9..c4765def341 100644
--- a/lib/tdb/test/run-nested-transactions.c
+++ b/lib/tdb/test/run-nested-transactions.c
@@ -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);
diff --git a/lib/tdb/test/run-open-during-transaction.c b/lib/tdb/test/run-open-during-transaction.c
index bd6e33d563f..f4a00525d8d 100644
--- a/lib/tdb/test/run-open-during-transaction.c
+++ b/lib/tdb/test/run-open-during-transaction.c
@@ -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"
diff --git a/lib/tdb/test/run-transaction-expand.c b/lib/tdb/test/run-transaction-expand.c
index e43eec412bb..3b79dbb6eae 100644
--- a/lib/tdb/test/run-transaction-expand.c
+++ b/lib/tdb/test/run-transaction-expand.c
@@ -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"