summaryrefslogtreecommitdiff
path: root/lib/tdb/test
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2012-06-22 15:07:44 +0930
committerRusty Russell <rusty@rustcorp.com.au>2012-06-22 07:35:17 +0200
commit1783fe34433f9bb4b939de3231a7c296390ec426 (patch)
tree42d25680bc9c1e209a841b1a0d8fdc1d92297db4 /lib/tdb/test
parent945473aac0abffd8509bbeef3ed5a32737b7df51 (diff)
downloadsamba-1783fe34433f9bb4b939de3231a7c296390ec426.tar.gz
samba-1783fe34433f9bb4b939de3231a7c296390ec426.tar.bz2
samba-1783fe34433f9bb4b939de3231a7c296390ec426.zip
tdb: make TDB_NOSYNC merely disable sync.
(As suggested by Stefan Metzmacher, based on the change to ntdb.) Since commit ec96ea690edbe3398d690b4a953d487ca1773f1c, we handle the case where a process dies during a transaction commit. Unfortunately, TDB_NOSYNC means this no longer works, as it disables the recovery area as well as the actual msync/fsync. We should do everything except the syncs. This also means we can do a complete test with $TDB_NO_FSYNC set; just to get more complete coverage, we disable it explicitly for one test (where we override the actual sync calls anyway). Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'lib/tdb/test')
-rw-r--r--lib/tdb/test/run-transaction-expand.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/tdb/test/run-transaction-expand.c b/lib/tdb/test/run-transaction-expand.c
index 3b79dbb6ea..bc22d2b53e 100644
--- a/lib/tdb/test/run-transaction-expand.c
+++ b/lib/tdb/test/run-transaction-expand.c
@@ -1,8 +1,10 @@
#include "../common/tdb_private.h"
-/* Speed up the tests: setting TDB_NOSYNC removed recovery altogether. */
+/* Speed up the tests, but do the actual sync tests. */
+static unsigned int sync_counts = 0;
static inline int fake_fsync(int fd)
{
+ sync_counts++;
return 0;
}
#define fsync fake_fsync
@@ -10,6 +12,7 @@ static inline int fake_fsync(int fd)
#ifdef MS_SYNC
static inline int fake_msync(void *addr, size_t length, int flags)
{
+ sync_counts++;
return 0;
}
#define msync fake_msync
@@ -18,6 +21,7 @@ static inline int fake_msync(void *addr, size_t length, int flags)
#ifdef HAVE_FDATASYNC
static inline int fake_fdatasync(int fd)
{
+ sync_counts++;
return 0;
}
#define fdatasync fake_fdatasync
@@ -59,7 +63,10 @@ int main(int argc, char *argv[])
struct tdb_record rec;
tdb_off_t off;
- plan_tests(4);
+ /* Do *not* suppress sync for this test; we do it ourselves. */
+ unsetenv("TDB_NO_FSYNC");
+
+ plan_tests(5);
tdb = tdb_open_ex("run-transaction-expand.tdb",
1024, TDB_CLEAR_IF_FIRST,
O_CREAT|O_TRUNC|O_RDWR, 0600, &taplogctx, NULL);
@@ -103,6 +110,9 @@ int main(int argc, char *argv[])
/* We should only be about 4 times larger than largest record. */
ok1(tdb->map_size < 5 * i * getpagesize());
+
+ /* We should have synchronized multiple times. */
+ ok1(sync_counts);
tdb_close(tdb);
free(data.dptr);