From 0265837ee8ab98b00c18411bee3770075e27f900 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Fri, 22 Jun 2012 09:17:13 +0930 Subject: [PATCH] ntdb: respect TDB_NO_FSYNC flag for 'make test' This reduces test time from 31 seconds to 6, on my laptop. Signed-off-by: Rusty Russell --- lib/ntdb/test/api-12-store.c | 4 +-- lib/ntdb/test/api-13-delete.c | 6 ++-- lib/ntdb/test/api-14-exists.c | 2 +- lib/ntdb/test/api-16-wipe_all.c | 2 +- lib/ntdb/test/api-20-alloc-attr.c | 2 +- lib/ntdb/test/api-21-parse_record.c | 5 ++-- lib/ntdb/test/api-55-transaction.c | 5 ++-- lib/ntdb/test/api-80-tdb_fd.c | 2 +- lib/ntdb/test/api-81-seqnum.c | 5 ++-- lib/ntdb/test/api-82-lockattr.c | 16 +++++----- lib/ntdb/test/api-83-openhook.c | 8 ++--- lib/ntdb/test/api-91-get-stats.c | 4 +-- lib/ntdb/test/api-92-get-set-readonly.c | 10 ++++--- lib/ntdb/test/api-93-repack.c | 5 ++-- lib/ntdb/test/api-add-remove-flags.c | 5 ++-- lib/ntdb/test/api-check-callback.c | 5 ++-- lib/ntdb/test/api-firstkey-nextkey.c | 7 +++-- lib/ntdb/test/api-fork-test.c | 5 ++-- lib/ntdb/test/api-locktimeout.c | 5 ++-- lib/ntdb/test/api-missing-entries.c | 2 +- lib/ntdb/test/api-open-multiple-times.c | 15 ++++++---- lib/ntdb/test/api-record-expand.c | 5 ++-- lib/ntdb/test/api-simple-delete.c | 5 ++-- lib/ntdb/test/api-summary.c | 4 +-- lib/ntdb/test/external-agent.c | 4 +-- lib/ntdb/test/no-fsync.h | 6 ++++ lib/ntdb/test/run-01-new_database.c | 4 +-- lib/ntdb/test/run-02-expand.c | 4 +-- lib/ntdb/test/run-03-coalesce.c | 20 ++++++------- lib/ntdb/test/run-04-basichash.c | 4 +-- lib/ntdb/test/run-05-readonly-open.c | 12 ++++---- lib/ntdb/test/run-10-simple-store.c | 5 ++-- lib/ntdb/test/run-11-simple-fetch.c | 5 ++-- lib/ntdb/test/run-12-check.c | 4 +-- lib/ntdb/test/run-15-append.c | 12 ++++---- lib/ntdb/test/run-25-hashoverload.c | 5 ++-- lib/ntdb/test/run-30-exhaust-before-expand.c | 5 ++-- lib/ntdb/test/run-35-convert.c | 14 ++++----- .../test/run-56-open-during-transaction.c | 4 +-- lib/ntdb/test/run-57-die-during-transaction.c | 4 +-- lib/ntdb/test/run-64-bit-tdb.c | 4 +-- lib/ntdb/test/run-90-get-set-attributes.c | 12 ++++---- lib/ntdb/test/run-capabilities.c | 30 +++++++++---------- lib/ntdb/test/run-expand-in-transaction.c | 5 ++-- lib/ntdb/test/run-features.c | 8 ++--- lib/ntdb/test/run-lockall.c | 4 +-- lib/ntdb/test/run-remap-in-read_traverse.c | 2 +- lib/ntdb/test/run-seed.c | 2 +- lib/ntdb/test/run-tdb_foreach.c | 20 ++++++++----- lib/ntdb/test/run-traverse.c | 4 +-- lib/ntdb/test/tap-interface.h | 1 + 51 files changed, 187 insertions(+), 151 deletions(-) create mode 100644 lib/ntdb/test/no-fsync.h diff --git a/lib/ntdb/test/api-12-store.c b/lib/ntdb/test/api-12-store.c index 8f1f42352b1..45274e0c67d 100644 --- a/lib/ntdb/test/api-12-store.c +++ b/lib/ntdb/test/api-12-store.c @@ -34,8 +34,8 @@ int main(int argc, char *argv[]) plan_tests(sizeof(flags) / sizeof(flags[0]) * (1 + 500 * 3) + 1); for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) { - ntdb = ntdb_open("run-12-store.ntdb", flags[i], - O_RDWR|O_CREAT|O_TRUNC, 0600, &fixed_hattr); + ntdb = ntdb_open("run-12-store.ntdb", flags[i]|MAYBE_NOSYNC, + O_RDWR|O_CREAT|O_TRUNC, 0600, &fixed_hattr); ok1(ntdb); if (!ntdb) continue; diff --git a/lib/ntdb/test/api-13-delete.c b/lib/ntdb/test/api-13-delete.c index 9bf4026d12d..cded8fde0bd 100644 --- a/lib/ntdb/test/api-13-delete.c +++ b/lib/ntdb/test/api-13-delete.c @@ -160,8 +160,8 @@ int main(int argc, char *argv[]) plan_tests(sizeof(flags) / sizeof(flags[0]) * (39 * 3 + 5 + sizeof(vals)/sizeof(vals[0])*2) + 1); for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) { - ntdb = ntdb_open("run-13-delete.ntdb", flags[i], - O_RDWR|O_CREAT|O_TRUNC, 0600, &clash_hattr); + ntdb = ntdb_open("run-13-delete.ntdb", flags[i]|MAYBE_NOSYNC, + O_RDWR|O_CREAT|O_TRUNC, 0600, &clash_hattr); ok1(ntdb); if (!ntdb) continue; @@ -180,7 +180,7 @@ int main(int argc, char *argv[]) ntdb_close(ntdb); /* Deleting these entries in the db gave problems. */ - ntdb = ntdb_open("run-13-delete.ntdb", flags[i], + ntdb = ntdb_open("run-13-delete.ntdb", flags[i]|MAYBE_NOSYNC, O_RDWR|O_CREAT|O_TRUNC, 0600, &fixed_hattr); ok1(ntdb); if (!ntdb) diff --git a/lib/ntdb/test/api-14-exists.c b/lib/ntdb/test/api-14-exists.c index 88663cad655..abaaae0ee54 100644 --- a/lib/ntdb/test/api-14-exists.c +++ b/lib/ntdb/test/api-14-exists.c @@ -42,7 +42,7 @@ int main(int argc, char *argv[]) plan_tests(sizeof(flags) / sizeof(flags[0]) * 2 + 1); for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) { - ntdb = ntdb_open("run-14-exists.ntdb", flags[i], + ntdb = ntdb_open("run-14-exists.ntdb", flags[i]|MAYBE_NOSYNC, O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); if (ok1(ntdb)) ok1(test_records(ntdb)); diff --git a/lib/ntdb/test/api-16-wipe_all.c b/lib/ntdb/test/api-16-wipe_all.c index c1bda8e4f40..6a6075275eb 100644 --- a/lib/ntdb/test/api-16-wipe_all.c +++ b/lib/ntdb/test/api-16-wipe_all.c @@ -30,7 +30,7 @@ int main(int argc, char *argv[]) plan_tests(sizeof(flags) / sizeof(flags[0]) * 4 + 1); for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) { - ntdb = ntdb_open("run-16-wipe_all.ntdb", flags[i], + ntdb = ntdb_open("run-16-wipe_all.ntdb", flags[i]|MAYBE_NOSYNC, O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); if (ok1(ntdb)) { NTDB_DATA key; diff --git a/lib/ntdb/test/api-20-alloc-attr.c b/lib/ntdb/test/api-20-alloc-attr.c index 5b4fb131f00..e4ec89a334f 100644 --- a/lib/ntdb/test/api-20-alloc-attr.c +++ b/lib/ntdb/test/api-20-alloc-attr.c @@ -82,7 +82,7 @@ int main(int argc, char *argv[]) for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) { curr_ntdb = NULL; curr_file = NULL; - ntdb = ntdb_open("run-12-store.ntdb", flags[i], + ntdb = ntdb_open("run-12-store.ntdb", flags[i]|MAYBE_NOSYNC, O_RDWR|O_CREAT|O_TRUNC, 0600, &alloc_attr); ok1(ntdb); if (!ntdb) diff --git a/lib/ntdb/test/api-21-parse_record.c b/lib/ntdb/test/api-21-parse_record.c index fa48562e177..975bbfaf1c9 100644 --- a/lib/ntdb/test/api-21-parse_record.c +++ b/lib/ntdb/test/api-21-parse_record.c @@ -55,8 +55,9 @@ int main(int argc, char *argv[]) plan_tests(sizeof(flags) / sizeof(flags[0]) * 2 + 1); for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) { - ntdb = ntdb_open("api-21-parse_record.ntdb", flags[i], - O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); + ntdb = ntdb_open("api-21-parse_record.ntdb", + flags[i]|MAYBE_NOSYNC, + O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); if (ok1(ntdb)) ok1(test_records(ntdb)); ntdb_close(ntdb); diff --git a/lib/ntdb/test/api-55-transaction.c b/lib/ntdb/test/api-55-transaction.c index d51dd0b13e8..01a1dcea1b8 100644 --- a/lib/ntdb/test/api-55-transaction.c +++ b/lib/ntdb/test/api-55-transaction.c @@ -24,8 +24,9 @@ int main(int argc, char *argv[]) plan_tests(sizeof(flags) / sizeof(flags[0]) * 20 + 1); for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) { - ntdb = ntdb_open("run-55-transaction.ntdb", flags[i], - O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); + ntdb = ntdb_open("run-55-transaction.ntdb", + flags[i]|MAYBE_NOSYNC, + O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); ok1(ntdb); if (!ntdb) continue; diff --git a/lib/ntdb/test/api-80-tdb_fd.c b/lib/ntdb/test/api-80-tdb_fd.c index 39a9df414eb..81b7284749e 100644 --- a/lib/ntdb/test/api-80-tdb_fd.c +++ b/lib/ntdb/test/api-80-tdb_fd.c @@ -16,7 +16,7 @@ int main(int argc, char *argv[]) plan_tests(sizeof(flags) / sizeof(flags[0]) * 3); for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) { - ntdb = ntdb_open("api-80-ntdb_fd.ntdb", flags[i], + ntdb = ntdb_open("api-80-ntdb_fd.ntdb", flags[i]|MAYBE_NOSYNC, O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); if (!ok1(ntdb)) continue; diff --git a/lib/ntdb/test/api-81-seqnum.c b/lib/ntdb/test/api-81-seqnum.c index 93ad53ab077..04f49cdbe3d 100644 --- a/lib/ntdb/test/api-81-seqnum.c +++ b/lib/ntdb/test/api-81-seqnum.c @@ -20,8 +20,9 @@ int main(int argc, char *argv[]) plan_tests(sizeof(flags) / sizeof(flags[0]) * 15 + 4 * 13); for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) { - ntdb = ntdb_open("api-81-seqnum.ntdb", flags[i]|NTDB_SEQNUM, - O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); + ntdb = ntdb_open("api-81-seqnum.ntdb", + flags[i]|NTDB_SEQNUM|MAYBE_NOSYNC, + O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); if (!ok1(ntdb)) continue; diff --git a/lib/ntdb/test/api-82-lockattr.c b/lib/ntdb/test/api-82-lockattr.c index 30de7dfddfb..4fbe1d232a6 100644 --- a/lib/ntdb/test/api-82-lockattr.c +++ b/lib/ntdb/test/api-82-lockattr.c @@ -65,31 +65,31 @@ int main(int argc, char *argv[]) /* Nonblocking open; expect no error message. */ lock_err = EAGAIN; - ntdb = ntdb_open("run-82-lockattr.ntdb", flags[i], - O_RDWR|O_CREAT|O_TRUNC, 0600, &lock_attr); + ntdb = ntdb_open("run-82-lockattr.ntdb", flags[i]|MAYBE_NOSYNC, + O_RDWR|O_CREAT|O_TRUNC, 0600, &lock_attr); ok(errno == lock_err, "Errno is %u", errno); ok1(!ntdb); ok1(tap_log_messages == 0); lock_err = EINTR; - ntdb = ntdb_open("run-82-lockattr.ntdb", flags[i], - O_RDWR|O_CREAT|O_TRUNC, 0600, &lock_attr); + ntdb = ntdb_open("run-82-lockattr.ntdb", flags[i]|MAYBE_NOSYNC, + O_RDWR|O_CREAT|O_TRUNC, 0600, &lock_attr); ok(errno == lock_err, "Errno is %u", errno); ok1(!ntdb); ok1(tap_log_messages == 0); /* Forced fail open. */ lock_err = ENOMEM; - ntdb = ntdb_open("run-82-lockattr.ntdb", flags[i], - O_RDWR|O_CREAT|O_TRUNC, 0600, &lock_attr); + ntdb = ntdb_open("run-82-lockattr.ntdb", flags[i]|MAYBE_NOSYNC, + O_RDWR|O_CREAT|O_TRUNC, 0600, &lock_attr); ok1(errno == lock_err); ok1(!ntdb); ok1(tap_log_messages == 1); tap_log_messages = 0; lock_err = 0; - ntdb = ntdb_open("run-82-lockattr.ntdb", flags[i], - O_RDWR|O_CREAT|O_TRUNC, 0600, &lock_attr); + ntdb = ntdb_open("run-82-lockattr.ntdb", flags[i]|MAYBE_NOSYNC, + O_RDWR|O_CREAT|O_TRUNC, 0600, &lock_attr); if (!ok1(ntdb)) continue; ok1(tap_log_messages == 0); diff --git a/lib/ntdb/test/api-83-openhook.c b/lib/ntdb/test/api-83-openhook.c index 666b4b8d8fa..31c789ead85 100644 --- a/lib/ntdb/test/api-83-openhook.c +++ b/lib/ntdb/test/api-83-openhook.c @@ -60,15 +60,15 @@ int main(int argc, char *argv[]) plan_tests(sizeof(flags) / sizeof(flags[0]) * 13); for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) { /* Create it */ - ntdb = ntdb_open("run-83-openhook.ntdb", flags[i], - O_RDWR|O_CREAT|O_TRUNC, 0600, NULL); + ntdb = ntdb_open("run-83-openhook.ntdb", flags[i]|MAYBE_NOSYNC, + O_RDWR|O_CREAT|O_TRUNC, 0600, NULL); ok1(ntdb); ok1(ntdb_store(ntdb, key, key, NTDB_REPLACE) == 0); ntdb_close(ntdb); /* Now, open with CIF, should clear it. */ - ntdb = ntdb_open("run-83-openhook.ntdb", flags[i], - O_RDWR, 0, &cif); + ntdb = ntdb_open("run-83-openhook.ntdb", flags[i]|MAYBE_NOSYNC, + O_RDWR, 0, &cif); ok1(ntdb); ok1(!ntdb_exists(ntdb, key)); ok1(ntdb_store(ntdb, key, key, NTDB_REPLACE) == 0); diff --git a/lib/ntdb/test/api-91-get-stats.c b/lib/ntdb/test/api-91-get-stats.c index e44b8a5061f..1ed36f028da 100644 --- a/lib/ntdb/test/api-91-get-stats.c +++ b/lib/ntdb/test/api-91-get-stats.c @@ -21,8 +21,8 @@ int main(int argc, char *argv[]) union ntdb_attribute *attr; NTDB_DATA key = ntdb_mkdata("key", 3), data; - ntdb = ntdb_open("run-91-get-stats.ntdb", flags[i], - O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); + ntdb = ntdb_open("run-91-get-stats.ntdb", flags[i]|MAYBE_NOSYNC, + O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); ok1(ntdb); /* Force an expansion */ data.dsize = 65536; diff --git a/lib/ntdb/test/api-92-get-set-readonly.c b/lib/ntdb/test/api-92-get-set-readonly.c index 7abd304eef2..81eadff3232 100644 --- a/lib/ntdb/test/api-92-get-set-readonly.c +++ b/lib/ntdb/test/api-92-get-set-readonly.c @@ -19,8 +19,9 @@ int main(int argc, char *argv[]) for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) { /* RW -> R0 */ - ntdb = ntdb_open("run-92-get-set-readonly.ntdb", flags[i], - O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); + ntdb = ntdb_open("run-92-get-set-readonly.ntdb", + flags[i]|MAYBE_NOSYNC, + O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); ok1(ntdb); ok1(!(ntdb_get_flags(ntdb) & NTDB_RDONLY)); @@ -69,8 +70,9 @@ int main(int argc, char *argv[]) ntdb_close(ntdb); /* R0 -> RW */ - ntdb = ntdb_open("run-92-get-set-readonly.ntdb", flags[i], - O_RDONLY, 0600, &tap_log_attr); + ntdb = ntdb_open("run-92-get-set-readonly.ntdb", + flags[i]|MAYBE_NOSYNC, + O_RDONLY, 0600, &tap_log_attr); ok1(ntdb); ok1(ntdb_get_flags(ntdb) & NTDB_RDONLY); diff --git a/lib/ntdb/test/api-93-repack.c b/lib/ntdb/test/api-93-repack.c index 168bc24c0a9..4a30c57edfa 100644 --- a/lib/ntdb/test/api-93-repack.c +++ b/lib/ntdb/test/api-93-repack.c @@ -59,8 +59,9 @@ int main(int argc, char *argv[]) plan_tests(sizeof(flags) / sizeof(flags[0]) * 6 + 1); for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) { - ntdb = ntdb_open("run-93-repack.ntdb", flags[i], - O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); + ntdb = ntdb_open("run-93-repack.ntdb", + flags[i]|MAYBE_NOSYNC, + O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); ok1(ntdb); if (!ntdb) break; diff --git a/lib/ntdb/test/api-add-remove-flags.c b/lib/ntdb/test/api-add-remove-flags.c index 4888c32f065..c5a3f421fc9 100644 --- a/lib/ntdb/test/api-add-remove-flags.c +++ b/lib/ntdb/test/api-add-remove-flags.c @@ -16,8 +16,9 @@ int main(int argc, char *argv[]) plan_tests(87); for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) { - ntdb = ntdb_open("run-add-remove-flags.ntdb", flags[i], - O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); + ntdb = ntdb_open("run-add-remove-flags.ntdb", + flags[i]|MAYBE_NOSYNC, + O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); ok1(ntdb); if (!ntdb) continue; diff --git a/lib/ntdb/test/api-check-callback.c b/lib/ntdb/test/api-check-callback.c index 3050fcddd97..0263f616da5 100644 --- a/lib/ntdb/test/api-check-callback.c +++ b/lib/ntdb/test/api-check-callback.c @@ -65,8 +65,9 @@ int main(int argc, char *argv[]) for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) { bool array[NUM_RECORDS]; - ntdb = ntdb_open("run-check-callback.ntdb", flags[i], - O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); + ntdb = ntdb_open("run-check-callback.ntdb", + flags[i]|MAYBE_NOSYNC, + O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); ok1(ntdb); if (!ntdb) continue; diff --git a/lib/ntdb/test/api-firstkey-nextkey.c b/lib/ntdb/test/api-firstkey-nextkey.c index da1a68043bb..5e83e6bf77d 100644 --- a/lib/ntdb/test/api-firstkey-nextkey.c +++ b/lib/ntdb/test/api-firstkey-nextkey.c @@ -65,9 +65,10 @@ int main(int argc, char *argv[]) plan_tests(sizeof(flags) / sizeof(flags[0]) * (NUM_RECORDS*6 + (NUM_RECORDS-1)*3 + 22) + 1); for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) { - ntdb = ntdb_open("api-firstkey-nextkey.ntdb", flags[i], - O_RDWR|O_CREAT|O_TRUNC, 0600, - &seed_attr); + ntdb = ntdb_open("api-firstkey-nextkey.ntdb", + flags[i]|MAYBE_NOSYNC, + O_RDWR|O_CREAT|O_TRUNC, 0600, + &seed_attr); ok1(ntdb); if (!ntdb) continue; diff --git a/lib/ntdb/test/api-fork-test.c b/lib/ntdb/test/api-fork-test.c index 63003dad3a9..6298a4af018 100644 --- a/lib/ntdb/test/api-fork-test.c +++ b/lib/ntdb/test/api-fork-test.c @@ -64,8 +64,9 @@ int main(int argc, char *argv[]) tap_log_messages = 0; - ntdb = ntdb_open("run-fork-test.ntdb", flags[i], - O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); + ntdb = ntdb_open("run-fork-test.ntdb", + flags[i]|MAYBE_NOSYNC, + O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); if (!ok1(ntdb)) continue; diff --git a/lib/ntdb/test/api-locktimeout.c b/lib/ntdb/test/api-locktimeout.c index cafe067d0bb..5e24d58dc43 100644 --- a/lib/ntdb/test/api-locktimeout.c +++ b/lib/ntdb/test/api-locktimeout.c @@ -142,8 +142,9 @@ int main(int argc, char *argv[]) for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) { enum NTDB_ERROR ecode; - ntdb = ntdb_open("run-locktimeout.ntdb", flags[i], - O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); + ntdb = ntdb_open("run-locktimeout.ntdb", + flags[i]|MAYBE_NOSYNC, + O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); if (!ok1(ntdb)) break; diff --git a/lib/ntdb/test/api-missing-entries.c b/lib/ntdb/test/api-missing-entries.c index b77f8ff31f4..d9a1fd97d5a 100644 --- a/lib/ntdb/test/api-missing-entries.c +++ b/lib/ntdb/test/api-missing-entries.c @@ -30,7 +30,7 @@ int main(int argc, char *argv[]) plan_tests(1 + NUM_RECORDS + 2); ntdb = ntdb_open("run-missing-entries.ntdb", NTDB_INTERNAL, - O_RDWR|O_CREAT|O_TRUNC, 0600, &hattr); + O_RDWR|O_CREAT|O_TRUNC, 0600, &hattr); if (ok1(ntdb)) { for (i = 0; i < NUM_RECORDS; i++) { ok1(ntdb_store(ntdb, key, data, NTDB_REPLACE) == 0); diff --git a/lib/ntdb/test/api-open-multiple-times.c b/lib/ntdb/test/api-open-multiple-times.c index 70bad005685..217732d227b 100644 --- a/lib/ntdb/test/api-open-multiple-times.c +++ b/lib/ntdb/test/api-open-multiple-times.c @@ -19,14 +19,16 @@ int main(int argc, char *argv[]) plan_tests(sizeof(flags) / sizeof(flags[0]) * 28); for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) { - ntdb = ntdb_open("run-open-multiple-times.ntdb", flags[i], - O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); + ntdb = ntdb_open("run-open-multiple-times.ntdb", + flags[i]|MAYBE_NOSYNC, + O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); ok1(ntdb); if (!ntdb) continue; - ntdb2 = ntdb_open("run-open-multiple-times.ntdb", flags[i], - O_RDWR|O_CREAT, 0600, &tap_log_attr); + ntdb2 = ntdb_open("run-open-multiple-times.ntdb", + flags[i]|MAYBE_NOSYNC, + O_RDWR|O_CREAT, 0600, &tap_log_attr); ok1(ntdb_check(ntdb, NULL, NULL) == 0); ok1(ntdb_check(ntdb2, NULL, NULL) == 0); @@ -49,8 +51,9 @@ int main(int argc, char *argv[]) free(d.dptr); /* Reopen */ - ntdb = ntdb_open("run-open-multiple-times.ntdb", flags[i], - O_RDWR|O_CREAT, 0600, &tap_log_attr); + ntdb = ntdb_open("run-open-multiple-times.ntdb", + flags[i]|MAYBE_NOSYNC, + O_RDWR|O_CREAT, 0600, &tap_log_attr); ok1(ntdb); ok1(ntdb_transaction_start(ntdb2) == 0); diff --git a/lib/ntdb/test/api-record-expand.c b/lib/ntdb/test/api-record-expand.c index cea5a10bfbb..8786fc7e5c4 100644 --- a/lib/ntdb/test/api-record-expand.c +++ b/lib/ntdb/test/api-record-expand.c @@ -26,8 +26,9 @@ int main(int argc, char *argv[]) plan_tests(sizeof(flags) / sizeof(flags[0]) * (3 + (1 + (MAX_SIZE/SIZE_STEP)) * 2) + 1); for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) { - ntdb = ntdb_open("run-record-expand.ntdb", flags[i], - O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); + ntdb = ntdb_open("run-record-expand.ntdb", + flags[i]|MAYBE_NOSYNC, + O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); ok1(ntdb); if (!ntdb) continue; diff --git a/lib/ntdb/test/api-simple-delete.c b/lib/ntdb/test/api-simple-delete.c index 2b20e199ee2..dedc433d1fc 100644 --- a/lib/ntdb/test/api-simple-delete.c +++ b/lib/ntdb/test/api-simple-delete.c @@ -18,8 +18,9 @@ int main(int argc, char *argv[]) plan_tests(sizeof(flags) / sizeof(flags[0]) * 7 + 1); for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) { - ntdb = ntdb_open("run-simple-delete.ntdb", flags[i], - O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); + ntdb = ntdb_open("run-simple-delete.ntdb", + flags[i]|MAYBE_NOSYNC, + O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); ok1(ntdb); if (ntdb) { /* Delete should fail. */ diff --git a/lib/ntdb/test/api-summary.c b/lib/ntdb/test/api-summary.c index 8060ef29be7..df5d092a60b 100644 --- a/lib/ntdb/test/api-summary.c +++ b/lib/ntdb/test/api-summary.c @@ -20,8 +20,8 @@ int main(int argc, char *argv[]) plan_tests(sizeof(flags) / sizeof(flags[0]) * (1 + 2 * 5) + 1); for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) { - ntdb = ntdb_open("run-summary.ntdb", flags[i], - O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); + ntdb = ntdb_open("run-summary.ntdb", flags[i]|MAYBE_NOSYNC, + O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); ok1(ntdb); if (!ntdb) continue; diff --git a/lib/ntdb/test/external-agent.c b/lib/ntdb/test/external-agent.c index 46654c2e64b..a06b70f7885 100644 --- a/lib/ntdb/test/external-agent.c +++ b/lib/ntdb/test/external-agent.c @@ -76,7 +76,7 @@ static enum agent_return do_operation(enum operation op, const char *name) diag("Already have ntdb %s open", ntdb_name(ntdb)); return OTHER_FAILURE; } - ntdb = ntdb_open(name, NTDB_DEFAULT, O_RDWR, 0, &tap_log_attr); + ntdb = ntdb_open(name, MAYBE_NOSYNC, O_RDWR, 0, &tap_log_attr); if (!ntdb) { if (!locking_would_block) diag("Opening ntdb gave %s", strerror(errno)); @@ -93,7 +93,7 @@ static enum agent_return do_operation(enum operation op, const char *name) cif.openhook.base.attr = NTDB_ATTRIBUTE_OPENHOOK; cif.openhook.base.next = &tap_log_attr; cif.openhook.fn = clear_if_first; - ntdb = ntdb_open(name, NTDB_DEFAULT, O_RDWR, 0, &cif); + ntdb = ntdb_open(name, MAYBE_NOSYNC, O_RDWR, 0, &cif); if (!ntdb) { if (!locking_would_block) diag("Opening ntdb gave %s", strerror(errno)); diff --git a/lib/ntdb/test/no-fsync.h b/lib/ntdb/test/no-fsync.h new file mode 100644 index 00000000000..f0c098e23c8 --- /dev/null +++ b/lib/ntdb/test/no-fsync.h @@ -0,0 +1,6 @@ +#ifndef NTDB_NO_FSYNC_H +#define NTDB_NO_FSYNC_H +/* Obey $TDB_NO_FSYNC, a bit like tdb does (only note our NTDB_NOSYNC + * does less) */ +#define MAYBE_NOSYNC (getenv("TDB_NO_FSYNC") ? NTDB_NOSYNC : 0) +#endif diff --git a/lib/ntdb/test/run-01-new_database.c b/lib/ntdb/test/run-01-new_database.c index ae70e86e072..fe142bdece3 100644 --- a/lib/ntdb/test/run-01-new_database.c +++ b/lib/ntdb/test/run-01-new_database.c @@ -18,8 +18,8 @@ int main(int argc, char *argv[]) failtest_exit_check = exit_check_log; plan_tests(sizeof(flags) / sizeof(flags[0]) * 3); for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) { - ntdb = ntdb_open("run-new_database.ntdb", flags[i], - O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); + ntdb = ntdb_open("run-new_database.ntdb", flags[i]|MAYBE_NOSYNC, + O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); if (!ok1(ntdb)) failtest_exit(exit_status()); diff --git a/lib/ntdb/test/run-02-expand.c b/lib/ntdb/test/run-02-expand.c index 2c8b1a291b4..635bf892065 100644 --- a/lib/ntdb/test/run-02-expand.c +++ b/lib/ntdb/test/run-02-expand.c @@ -22,8 +22,8 @@ int main(int argc, char *argv[]) for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) { failtest_suppress = true; - ntdb = ntdb_open("run-expand.ntdb", flags[i], - O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); + ntdb = ntdb_open("run-expand.ntdb", flags[i]|MAYBE_NOSYNC, + O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); if (!ok1(ntdb)) break; diff --git a/lib/ntdb/test/run-03-coalesce.c b/lib/ntdb/test/run-03-coalesce.c index 363c078fc6b..dc76e6a4ad3 100644 --- a/lib/ntdb/test/run-03-coalesce.c +++ b/lib/ntdb/test/run-03-coalesce.c @@ -38,8 +38,8 @@ int main(int argc, char *argv[]) ntdb_layout_add_free(layout, len, 0); ntdb_layout_write(layout, free, &tap_log_attr, "run-03-coalesce.ntdb"); /* NOMMAP is for lockcheck. */ - ntdb = ntdb_open("run-03-coalesce.ntdb", NTDB_NOMMAP, O_RDWR, 0, - &tap_log_attr); + ntdb = ntdb_open("run-03-coalesce.ntdb", NTDB_NOMMAP|MAYBE_NOSYNC, + O_RDWR, 0, &tap_log_attr); ok1(ntdb_check(ntdb, NULL, NULL) == 0); ok1(free_record_length(ntdb, layout->elem[1].base.off) == len); @@ -64,8 +64,8 @@ int main(int argc, char *argv[]) ntdb_layout_add_used(layout, key, data, 6); ntdb_layout_write(layout, free, &tap_log_attr, "run-03-coalesce.ntdb"); /* NOMMAP is for lockcheck. */ - ntdb = ntdb_open("run-03-coalesce.ntdb", NTDB_NOMMAP, O_RDWR, 0, - &tap_log_attr); + ntdb = ntdb_open("run-03-coalesce.ntdb", NTDB_NOMMAP|MAYBE_NOSYNC, + O_RDWR, 0, &tap_log_attr); ok1(free_record_length(ntdb, layout->elem[1].base.off) == 15528); ok1(ntdb_check(ntdb, NULL, NULL) == 0); @@ -90,8 +90,8 @@ int main(int argc, char *argv[]) ntdb_layout_add_free(layout, 14520, 0); ntdb_layout_write(layout, free, &tap_log_attr, "run-03-coalesce.ntdb"); /* NOMMAP is for lockcheck. */ - ntdb = ntdb_open("run-03-coalesce.ntdb", NTDB_NOMMAP, O_RDWR, 0, - &tap_log_attr); + ntdb = ntdb_open("run-03-coalesce.ntdb", NTDB_NOMMAP|MAYBE_NOSYNC, + O_RDWR, 0, &tap_log_attr); ok1(free_record_length(ntdb, layout->elem[1].base.off) == 1024); ok1(free_record_length(ntdb, layout->elem[2].base.off) == 14520); ok1(ntdb_check(ntdb, NULL, NULL) == 0); @@ -120,8 +120,8 @@ int main(int argc, char *argv[]) ntdb_layout_add_used(layout, key, data, 6); ntdb_layout_write(layout, free, &tap_log_attr, "run-03-coalesce.ntdb"); /* NOMMAP is for lockcheck. */ - ntdb = ntdb_open("run-03-coalesce.ntdb", NTDB_NOMMAP, O_RDWR, 0, - &tap_log_attr); + ntdb = ntdb_open("run-03-coalesce.ntdb", NTDB_NOMMAP|MAYBE_NOSYNC, + O_RDWR, 0, &tap_log_attr); ok1(free_record_length(ntdb, layout->elem[1].base.off) == 1024); ok1(free_record_length(ntdb, layout->elem[2].base.off) == 14488); ok1(ntdb_check(ntdb, NULL, NULL) == 0); @@ -149,8 +149,8 @@ int main(int argc, char *argv[]) ntdb_layout_add_free(layout, 13992, 0); ntdb_layout_write(layout, free, &tap_log_attr, "run-03-coalesce.ntdb"); /* NOMMAP is for lockcheck. */ - ntdb = ntdb_open("run-03-coalesce.ntdb", NTDB_NOMMAP, O_RDWR, 0, - &tap_log_attr); + ntdb = ntdb_open("run-03-coalesce.ntdb", NTDB_NOMMAP|MAYBE_NOSYNC, + O_RDWR, 0, &tap_log_attr); ok1(free_record_length(ntdb, layout->elem[1].base.off) == 1024); ok1(free_record_length(ntdb, layout->elem[2].base.off) == 512); ok1(free_record_length(ntdb, layout->elem[3].base.off) == 13992); diff --git a/lib/ntdb/test/run-04-basichash.c b/lib/ntdb/test/run-04-basichash.c index 264932b988a..9888f6e551d 100644 --- a/lib/ntdb/test/run-04-basichash.c +++ b/lib/ntdb/test/run-04-basichash.c @@ -30,8 +30,8 @@ int main(int argc, char *argv[]) struct hash_info h; ntdb_off_t new_off, new_off2, off; - ntdb = ntdb_open("run-04-basichash.ntdb", flags[i], - O_RDWR|O_CREAT|O_TRUNC, 0600, &hattr); + ntdb = ntdb_open("run-04-basichash.ntdb", flags[i]|MAYBE_NOSYNC, + O_RDWR|O_CREAT|O_TRUNC, 0600, &hattr); ok1(ntdb); if (!ntdb) continue; diff --git a/lib/ntdb/test/run-05-readonly-open.c b/lib/ntdb/test/run-05-readonly-open.c index dd5aa26d0d1..e0de0d96e3a 100644 --- a/lib/ntdb/test/run-05-readonly-open.c +++ b/lib/ntdb/test/run-05-readonly-open.c @@ -27,15 +27,17 @@ int main(int argc, char *argv[]) failtest_suppress = true; plan_tests(sizeof(flags) / sizeof(flags[0]) * 11); for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) { - ntdb = ntdb_open("run-05-readonly-open.ntdb", flags[i], - O_RDWR|O_CREAT|O_TRUNC, 0600, - &seed_attr); + ntdb = ntdb_open("run-05-readonly-open.ntdb", + flags[i]|MAYBE_NOSYNC, + O_RDWR|O_CREAT|O_TRUNC, 0600, + &seed_attr); ok1(ntdb_store(ntdb, key, data, NTDB_INSERT) == 0); ntdb_close(ntdb); failtest_suppress = false; - ntdb = ntdb_open("run-05-readonly-open.ntdb", flags[i], - O_RDONLY, 0600, &tap_log_attr); + ntdb = ntdb_open("run-05-readonly-open.ntdb", + flags[i]|MAYBE_NOSYNC, + O_RDONLY, 0600, &tap_log_attr); if (!ok1(ntdb)) break; ok1(tap_log_messages == msgs); diff --git a/lib/ntdb/test/run-10-simple-store.c b/lib/ntdb/test/run-10-simple-store.c index 6e718bf61f5..3e5959a647a 100644 --- a/lib/ntdb/test/run-10-simple-store.c +++ b/lib/ntdb/test/run-10-simple-store.c @@ -22,8 +22,9 @@ int main(int argc, char *argv[]) failtest_suppress = true; plan_tests(sizeof(flags) / sizeof(flags[0]) * 7 + 1); for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) { - ntdb = ntdb_open("run-10-simple-store.ntdb", flags[i], - O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); + ntdb = ntdb_open("run-10-simple-store.ntdb", + flags[i]|MAYBE_NOSYNC, + O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); if (!ok1(ntdb)) break; /* Modify should fail. */ diff --git a/lib/ntdb/test/run-11-simple-fetch.c b/lib/ntdb/test/run-11-simple-fetch.c index 525cf46444c..9565ade930d 100644 --- a/lib/ntdb/test/run-11-simple-fetch.c +++ b/lib/ntdb/test/run-11-simple-fetch.c @@ -22,8 +22,9 @@ int main(int argc, char *argv[]) failtest_suppress = true; plan_tests(sizeof(flags) / sizeof(flags[0]) * 8 + 1); for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) { - ntdb = ntdb_open("run-11-simple-fetch.ntdb", flags[i], - O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); + ntdb = ntdb_open("run-11-simple-fetch.ntdb", + flags[i]|MAYBE_NOSYNC, + O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); ok1(ntdb); if (ntdb) { NTDB_DATA d = { NULL, 0 }; /* Bogus GCC warning */ diff --git a/lib/ntdb/test/run-12-check.c b/lib/ntdb/test/run-12-check.c index 60406370486..8abc86dff91 100644 --- a/lib/ntdb/test/run-12-check.c +++ b/lib/ntdb/test/run-12-check.c @@ -23,8 +23,8 @@ int main(int argc, char *argv[]) failtest_suppress = true; plan_tests(sizeof(flags) / sizeof(flags[0]) * 3 + 1); for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) { - ntdb = ntdb_open("run-12-check.ntdb", flags[i], - O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); + ntdb = ntdb_open("run-12-check.ntdb", flags[i]|MAYBE_NOSYNC, + O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); ok1(ntdb); ok1(ntdb_store(ntdb, key, data, NTDB_INSERT) == 0); diff --git a/lib/ntdb/test/run-15-append.c b/lib/ntdb/test/run-15-append.c index a797944b533..05fa594b6b5 100644 --- a/lib/ntdb/test/run-15-append.c +++ b/lib/ntdb/test/run-15-append.c @@ -41,8 +41,8 @@ int main(int argc, char *argv[]) /* Using ntdb_store. */ for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) { - ntdb = ntdb_open("run-append.ntdb", flags[i], - O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); + ntdb = ntdb_open("run-append.ntdb", flags[i]|MAYBE_NOSYNC, + O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); ok1(ntdb); if (!ntdb) continue; @@ -73,8 +73,8 @@ int main(int argc, char *argv[]) /* Using ntdb_append. */ for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) { size_t prev_len = 0; - ntdb = ntdb_open("run-append.ntdb", flags[i], - O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); + ntdb = ntdb_open("run-append.ntdb", flags[i]|MAYBE_NOSYNC, + O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); ok1(ntdb); if (!ntdb) continue; @@ -104,8 +104,8 @@ int main(int argc, char *argv[]) } for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) { - ntdb = ntdb_open("run-append.ntdb", flags[i], - O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); + ntdb = ntdb_open("run-append.ntdb", flags[i]|MAYBE_NOSYNC, + O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); ok1(ntdb); if (!ntdb) continue; diff --git a/lib/ntdb/test/run-25-hashoverload.c b/lib/ntdb/test/run-25-hashoverload.c index 1b69fe9a617..d82b3edb3d3 100644 --- a/lib/ntdb/test/run-25-hashoverload.c +++ b/lib/ntdb/test/run-25-hashoverload.c @@ -35,8 +35,9 @@ int main(int argc, char *argv[]) for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) { NTDB_DATA d = { NULL, 0 }; /* Bogus GCC warning */ - ntdb = ntdb_open("run-25-hashoverload.ntdb", flags[i], - O_RDWR|O_CREAT|O_TRUNC, 0600, &hattr); + ntdb = ntdb_open("run-25-hashoverload.ntdb", + flags[i]|MAYBE_NOSYNC, + O_RDWR|O_CREAT|O_TRUNC, 0600, &hattr); ok1(ntdb); if (!ntdb) continue; diff --git a/lib/ntdb/test/run-30-exhaust-before-expand.c b/lib/ntdb/test/run-30-exhaust-before-expand.c index cc9ea3fa3dd..bcf1c1f6655 100644 --- a/lib/ntdb/test/run-30-exhaust-before-expand.c +++ b/lib/ntdb/test/run-30-exhaust-before-expand.c @@ -37,8 +37,9 @@ int main(int argc, char *argv[]) k.dptr = (void *)&j; k.dsize = sizeof(j); - ntdb = ntdb_open("run-30-exhaust-before-expand.ntdb", flags[i], - O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); + ntdb = ntdb_open("run-30-exhaust-before-expand.ntdb", + flags[i]|MAYBE_NOSYNC, + O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); ok1(ntdb); if (!ntdb) continue; diff --git a/lib/ntdb/test/run-35-convert.c b/lib/ntdb/test/run-35-convert.c index 5b8099c4487..b3ee737794d 100644 --- a/lib/ntdb/test/run-35-convert.c +++ b/lib/ntdb/test/run-35-convert.c @@ -18,8 +18,8 @@ int main(int argc, char *argv[]) failtest_exit_check = exit_check_log; plan_tests(sizeof(flags) / sizeof(flags[0]) * 4); for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) { - ntdb = ntdb_open("run-35-convert.ntdb", flags[i], - O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); + ntdb = ntdb_open("run-35-convert.ntdb", flags[i]|MAYBE_NOSYNC, + O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); if (!ok1(ntdb)) failtest_exit(exit_status()); @@ -30,8 +30,8 @@ int main(int argc, char *argv[]) } /* If we say NTDB_CONVERT, it must be converted */ ntdb = ntdb_open("run-35-convert.ntdb", - flags[i]|NTDB_CONVERT, - O_RDWR, 0600, &tap_log_attr); + flags[i]|NTDB_CONVERT|MAYBE_NOSYNC, + O_RDWR, 0600, &tap_log_attr); if (flags[i] & NTDB_CONVERT) { if (!ntdb) failtest_exit(exit_status()); @@ -47,11 +47,11 @@ int main(int argc, char *argv[]) /* If don't say NTDB_CONVERT, it *may* be converted */ ntdb = ntdb_open("run-35-convert.ntdb", - flags[i] & ~NTDB_CONVERT, - O_RDWR, 0600, &tap_log_attr); + (flags[i] & ~NTDB_CONVERT)|MAYBE_NOSYNC, + O_RDWR, 0600, &tap_log_attr); if (!ntdb) failtest_exit(exit_status()); - ok1(ntdb_get_flags(ntdb) == flags[i]); + ok1(ntdb_get_flags(ntdb) == (flags[i]|MAYBE_NOSYNC)); ntdb_close(ntdb); } failtest_exit(exit_status()); diff --git a/lib/ntdb/test/run-56-open-during-transaction.c b/lib/ntdb/test/run-56-open-during-transaction.c index f585aa13c81..1c8786ce2f4 100644 --- a/lib/ntdb/test/run-56-open-during-transaction.c +++ b/lib/ntdb/test/run-56-open-during-transaction.c @@ -144,8 +144,8 @@ int main(int argc, char *argv[]) (flags[i] & NTDB_CONVERT) ? "CONVERT" : "DEFAULT", (flags[i] & NTDB_NOMMAP) ? "no mmap" : "mmap"); unlink(TEST_DBNAME); - ntdb = ntdb_open(TEST_DBNAME, flags[i], - O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); + ntdb = ntdb_open(TEST_DBNAME, flags[i]|MAYBE_NOSYNC, + O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); ok1(ntdb); opened = true; diff --git a/lib/ntdb/test/run-57-die-during-transaction.c b/lib/ntdb/test/run-57-die-during-transaction.c index b6ce57590bb..32f781e4a89 100644 --- a/lib/ntdb/test/run-57-die-during-transaction.c +++ b/lib/ntdb/test/run-57-die-during-transaction.c @@ -167,8 +167,8 @@ static bool test_death(enum operation op, struct agent *agent, reset: unlink(TEST_DBNAME); - ntdb = ntdb_open(TEST_DBNAME, NTDB_NOMMAP, - O_CREAT|O_TRUNC|O_RDWR, 0600, &tap_log_attr); + ntdb = ntdb_open(TEST_DBNAME, NTDB_NOMMAP|MAYBE_NOSYNC, + O_CREAT|O_TRUNC|O_RDWR, 0600, &tap_log_attr); if (!ntdb) { diag("Failed opening NTDB: %s", strerror(errno)); return false; diff --git a/lib/ntdb/test/run-64-bit-tdb.c b/lib/ntdb/test/run-64-bit-tdb.c index 582deb22341..552866f8bad 100644 --- a/lib/ntdb/test/run-64-bit-tdb.c +++ b/lib/ntdb/test/run-64-bit-tdb.c @@ -29,8 +29,8 @@ int main(int argc, char *argv[]) struct ntdb_used_record rec; ntdb_off_t off; - ntdb = ntdb_open("run-64-bit-ntdb.ntdb", flags[i], - O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); + ntdb = ntdb_open("run-64-bit-ntdb.ntdb", flags[i]|MAYBE_NOSYNC, + O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); ok1(ntdb); if (!ntdb) continue; diff --git a/lib/ntdb/test/run-90-get-set-attributes.c b/lib/ntdb/test/run-90-get-set-attributes.c index 4f8792569f8..5548aa4f7e0 100644 --- a/lib/ntdb/test/run-90-get-set-attributes.c +++ b/lib/ntdb/test/run-90-get-set-attributes.c @@ -50,8 +50,9 @@ int main(int argc, char *argv[]) union ntdb_attribute attr; /* First open with no attributes. */ - ntdb = ntdb_open("run-90-get-set-attributes.ntdb", flags[i], - O_RDWR|O_CREAT|O_TRUNC, 0600, NULL); + ntdb = ntdb_open("run-90-get-set-attributes.ntdb", + flags[i] |MAYBE_NOSYNC, + O_RDWR|O_CREAT|O_TRUNC, 0600, NULL); ok1(ntdb); /* Get log on no attributes will fail */ @@ -111,9 +112,10 @@ int main(int argc, char *argv[]) ok1(tap_log_messages == 0); /* Now open with all attributes. */ - ntdb = ntdb_open("run-90-get-set-attributes.ntdb", flags[i], - O_RDWR|O_CREAT|O_TRUNC, 0600, - &seed_attr); + ntdb = ntdb_open("run-90-get-set-attributes.ntdb", + flags[i] | MAYBE_NOSYNC, + O_RDWR|O_CREAT|O_TRUNC, 0600, + &seed_attr); ok1(ntdb); diff --git a/lib/ntdb/test/run-capabilities.c b/lib/ntdb/test/run-capabilities.c index 6503214c062..dac9302fc65 100644 --- a/lib/ntdb/test/run-capabilities.c +++ b/lib/ntdb/test/run-capabilities.c @@ -96,8 +96,8 @@ int main(int argc, char *argv[]) create_ntdb("run-capabilities.ntdb", 1, false, false, false, 0); failtest_suppress = false; - ntdb = ntdb_open("run-capabilities.ntdb", NTDB_DEFAULT, O_RDWR, 0, - &tap_log_attr); + ntdb = ntdb_open("run-capabilities.ntdb", MAYBE_NOSYNC, O_RDWR, 0, + &tap_log_attr); failtest_suppress = true; if (!ok1(ntdb)) goto out; @@ -112,8 +112,8 @@ int main(int argc, char *argv[]) 2, false, false, false, 0); failtest_suppress = false; - ntdb = ntdb_open("run-capabilities.ntdb", NTDB_DEFAULT, O_RDWR, 0, - &tap_log_attr); + ntdb = ntdb_open("run-capabilities.ntdb", MAYBE_NOSYNC, O_RDWR, 0, + &tap_log_attr); failtest_suppress = true; if (!ok1(ntdb)) goto out; @@ -131,8 +131,8 @@ int main(int argc, char *argv[]) 2, true, false, false, 0); failtest_suppress = false; - ntdb = ntdb_open("run-capabilities.ntdb", NTDB_DEFAULT, O_RDWR, 0, - &tap_log_attr); + ntdb = ntdb_open("run-capabilities.ntdb", MAYBE_NOSYNC, O_RDWR, 0, + &tap_log_attr); failtest_suppress = true; if (!ok1(ntdb)) goto out; @@ -154,8 +154,8 @@ int main(int argc, char *argv[]) 2, false, true, false, 0); failtest_suppress = false; - ntdb = ntdb_open("run-capabilities.ntdb", NTDB_DEFAULT, O_RDWR, 0, - &tap_log_attr); + ntdb = ntdb_open("run-capabilities.ntdb", MAYBE_NOSYNC, O_RDWR, 0, + &tap_log_attr); failtest_suppress = true; /* We expect a message. */ ok1(!ntdb); @@ -167,8 +167,8 @@ int main(int argc, char *argv[]) /* We can open it read-only though! */ failtest_suppress = false; - ntdb = ntdb_open("run-capabilities.ntdb", NTDB_DEFAULT, O_RDONLY, 0, - &tap_log_attr); + ntdb = ntdb_open("run-capabilities.ntdb", MAYBE_NOSYNC, O_RDONLY, 0, + &tap_log_attr); failtest_suppress = true; if (!ok1(ntdb)) goto out; @@ -187,7 +187,7 @@ int main(int argc, char *argv[]) 2, false, false, true, 0); failtest_suppress = false; - ntdb = ntdb_open("run-capabilities.ntdb", NTDB_DEFAULT, O_RDWR, 0, + ntdb = ntdb_open("run-capabilities.ntdb", MAYBE_NOSYNC, O_RDWR, 0, &tap_log_attr); failtest_suppress = true; /* We expect a message. */ @@ -204,7 +204,7 @@ int main(int argc, char *argv[]) 3, false, true, false, 0); failtest_suppress = false; - ntdb = ntdb_open("run-capabilities.ntdb", NTDB_DEFAULT, O_RDWR, 0, + ntdb = ntdb_open("run-capabilities.ntdb", MAYBE_NOSYNC, O_RDWR, 0, &tap_log_attr); failtest_suppress = true; /* We expect a message. */ @@ -217,7 +217,7 @@ int main(int argc, char *argv[]) /* We can open it read-only though! */ failtest_suppress = false; - ntdb = ntdb_open("run-capabilities.ntdb", NTDB_DEFAULT, O_RDONLY, 0, + ntdb = ntdb_open("run-capabilities.ntdb", MAYBE_NOSYNC, O_RDONLY, 0, &tap_log_attr); failtest_suppress = true; if (!ok1(ntdb)) @@ -242,7 +242,7 @@ int main(int argc, char *argv[]) 0); failtest_suppress = false; - ntdb = ntdb_open("run-capabilities.ntdb", NTDB_DEFAULT, O_RDWR, 0, + ntdb = ntdb_open("run-capabilities.ntdb", MAYBE_NOSYNC, O_RDWR, 0, &tap_log_attr); failtest_suppress = true; /* We expect a message. */ @@ -255,7 +255,7 @@ int main(int argc, char *argv[]) /* We can open it read-only though! */ failtest_suppress = false; - ntdb = ntdb_open("run-capabilities.ntdb", NTDB_DEFAULT, O_RDONLY, 0, + ntdb = ntdb_open("run-capabilities.ntdb", MAYBE_NOSYNC, O_RDONLY, 0, &tap_log_attr); failtest_suppress = true; if (!ok1(ntdb)) diff --git a/lib/ntdb/test/run-expand-in-transaction.c b/lib/ntdb/test/run-expand-in-transaction.c index 71866a37c18..07c7129f8c9 100644 --- a/lib/ntdb/test/run-expand-in-transaction.c +++ b/lib/ntdb/test/run-expand-in-transaction.c @@ -16,8 +16,9 @@ int main(int argc, char *argv[]) for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) { size_t size; NTDB_DATA k, d; - ntdb = ntdb_open("run-expand-in-transaction.ntdb", flags[i], - O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); + ntdb = ntdb_open("run-expand-in-transaction.ntdb", + flags[i]|MAYBE_NOSYNC, + O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); ok1(ntdb); if (!ntdb) continue; diff --git a/lib/ntdb/test/run-features.c b/lib/ntdb/test/run-features.c index 0d6b3bce76c..a332572deb5 100644 --- a/lib/ntdb/test/run-features.c +++ b/lib/ntdb/test/run-features.c @@ -14,8 +14,8 @@ int main(int argc, char *argv[]) plan_tests(sizeof(flags) / sizeof(flags[0]) * 8 + 1); for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) { uint64_t features; - ntdb = ntdb_open("run-features.ntdb", flags[i], - O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); + ntdb = ntdb_open("run-features.ntdb", flags[i]|MAYBE_NOSYNC, + O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); ok1(ntdb); if (!ntdb) continue; @@ -36,8 +36,8 @@ int main(int argc, char *argv[]) &features, sizeof(features)) == 0); ntdb_close(ntdb); - ntdb = ntdb_open("run-features.ntdb", flags[i], O_RDWR, 0, - &tap_log_attr); + ntdb = ntdb_open("run-features.ntdb", flags[i]|MAYBE_NOSYNC, + O_RDWR, 0, &tap_log_attr); ok1(ntdb); if (!ntdb) continue; diff --git a/lib/ntdb/test/run-lockall.c b/lib/ntdb/test/run-lockall.c index c4bfb0e5cdb..5ec448c9822 100644 --- a/lib/ntdb/test/run-lockall.c +++ b/lib/ntdb/test/run-lockall.c @@ -33,8 +33,8 @@ int main(int argc, char *argv[]) enum agent_return ret; struct ntdb_context *ntdb; - ntdb = ntdb_open(TEST_DBNAME, flags[i], - O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); + ntdb = ntdb_open(TEST_DBNAME, flags[i]|MAYBE_NOSYNC, + O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); ok1(ntdb); ret = external_agent_operation(agent, OPEN, TEST_DBNAME); diff --git a/lib/ntdb/test/run-remap-in-read_traverse.c b/lib/ntdb/test/run-remap-in-read_traverse.c index 0e963fc5b18..ee72c615379 100644 --- a/lib/ntdb/test/run-remap-in-read_traverse.c +++ b/lib/ntdb/test/run-remap-in-read_traverse.c @@ -39,7 +39,7 @@ int main(int argc, char *argv[]) agent = prepare_external_agent(); - ntdb = ntdb_open(filename, NTDB_DEFAULT, + ntdb = ntdb_open(filename, MAYBE_NOSYNC, O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); ok1(external_agent_operation(agent, OPEN, filename) == SUCCESS); diff --git a/lib/ntdb/test/run-seed.c b/lib/ntdb/test/run-seed.c index 2514f728ac9..5d74dbc22e1 100644 --- a/lib/ntdb/test/run-seed.c +++ b/lib/ntdb/test/run-seed.c @@ -35,7 +35,7 @@ int main(int argc, char *argv[]) for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) { struct ntdb_header hdr; int fd; - ntdb = ntdb_open("run-seed.ntdb", flags[i], + ntdb = ntdb_open("run-seed.ntdb", flags[i]|MAYBE_NOSYNC, O_RDWR|O_CREAT|O_TRUNC, 0600, &attr); ok1(ntdb); if (!ntdb) diff --git a/lib/ntdb/test/run-tdb_foreach.c b/lib/ntdb/test/run-tdb_foreach.c index f1a2d009195..11eac5d0f25 100644 --- a/lib/ntdb/test/run-tdb_foreach.c +++ b/lib/ntdb/test/run-tdb_foreach.c @@ -38,12 +38,15 @@ int main(int argc, char *argv[]) plan_tests(sizeof(flags) / sizeof(flags[0]) * 8); for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) { - ntdb0 = ntdb_open("run-ntdb_foreach0.ntdb", flags[i], - O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); - ntdb1 = ntdb_open("run-ntdb_foreach1.ntdb", flags[i], - O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); - ntdb = ntdb_open("run-ntdb_foreach2.ntdb", flags[i], - O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); + ntdb0 = ntdb_open("run-ntdb_foreach0.ntdb", + flags[i]|MAYBE_NOSYNC, + O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); + ntdb1 = ntdb_open("run-ntdb_foreach1.ntdb", + flags[i]|MAYBE_NOSYNC, + O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); + ntdb = ntdb_open("run-ntdb_foreach2.ntdb", + flags[i]|MAYBE_NOSYNC, + O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); memset(found, 0, sizeof(found)); ntdb_foreach(set_found, found); @@ -64,8 +67,9 @@ int main(int argc, char *argv[]) ntdb_foreach(set_found, found); ok1(found[0] && !found[1] && !found[2]); - ntdb1 = ntdb_open("run-ntdb_foreach1.ntdb", flags[i], - O_RDWR, 0600, &tap_log_attr); + ntdb1 = ntdb_open("run-ntdb_foreach1.ntdb", + flags[i]|MAYBE_NOSYNC, + O_RDWR, 0600, &tap_log_attr); memset(found, 0, sizeof(found)); ntdb_foreach(set_found, found); ok1(found[0] && found[1] && !found[2]); diff --git a/lib/ntdb/test/run-traverse.c b/lib/ntdb/test/run-traverse.c index ed95f336045..a326b9c5d55 100644 --- a/lib/ntdb/test/run-traverse.c +++ b/lib/ntdb/test/run-traverse.c @@ -113,8 +113,8 @@ int main(int argc, char *argv[]) plan_tests(sizeof(flags) / sizeof(flags[0]) * 32 + 1); for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) { - ntdb = ntdb_open("run-traverse.ntdb", flags[i], - O_RDWR|O_CREAT|O_TRUNC, 0600, &hattr); + ntdb = ntdb_open("run-traverse.ntdb", flags[i]|MAYBE_NOSYNC, + O_RDWR|O_CREAT|O_TRUNC, 0600, &hattr); ok1(ntdb); if (!ntdb) continue; diff --git a/lib/ntdb/test/tap-interface.h b/lib/ntdb/test/tap-interface.h index 9df64a16cb5..5363c32b4d4 100644 --- a/lib/ntdb/test/tap-interface.h +++ b/lib/ntdb/test/tap-interface.h @@ -23,6 +23,7 @@ */ #include #include +#include "no-fsync.h" #ifndef __location__ #define __TAP_STRING_LINE1__(s) #s -- 2.34.1