This reduces test time from 31 seconds to 6, on my laptop.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
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;
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;
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)
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));
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;
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)
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);
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;
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;
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;
/* 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);
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);
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;
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));
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);
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;
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;
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;
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;
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;
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;
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);
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);
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);
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;
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. */
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;
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));
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));
--- /dev/null
+#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
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());
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;
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);
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);
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);
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);
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);
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;
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);
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. */
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 */
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);
/* 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;
/* 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;
}
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;
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;
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;
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());
}
/* 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());
/* 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());
(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;
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;
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;
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 */
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);
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;
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;
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;
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);
/* 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;
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. */
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. */
/* 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))
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. */
/* 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))
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;
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;
&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;
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);
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);
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)
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);
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]);
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;
*/
#include <stdio.h>
#include <ccan/err/err.h>
+#include "no-fsync.h"
#ifndef __location__
#define __TAP_STRING_LINE1__(s) #s