Update test to accept flags instead of a bool

This commit is contained in:
James Rouzier 2017-10-25 19:54:40 -04:00
parent 7c466e53f0
commit 2f1f4b19a0
5 changed files with 25 additions and 25 deletions

View File

@ -25,7 +25,7 @@ bool testcase_deadread::setup() {
bool testcase_deadread::run() {
db_open();
txn_begin(true);
txn_begin(MDBX_RDONLY);
return true;
}
@ -50,7 +50,7 @@ bool testcase_deadwrite::setup() {
bool testcase_deadwrite::run() {
db_open();
txn_begin(false);
txn_begin(0);
return true;
}

View File

@ -28,7 +28,7 @@ bool testcase_hill::setup() {
bool testcase_hill::run() {
db_open();
txn_begin(false);
txn_begin(0);
MDBX_dbi dbi = db_table_open(true);
txn_end(false);
@ -70,7 +70,7 @@ bool testcase_hill::run() {
uint64_t serial_count = 0;
unsigned txn_nops = 0;
if (!txn_guard)
txn_begin(false);
txn_begin(0);
while (should_continue()) {
const keygen::serial_t a_serial = serial_count;
@ -91,7 +91,7 @@ bool testcase_hill::run() {
failure_perror("mdbx_put(insert-a.1)", rc);
if (++txn_nops >= config.params.batch_write) {
txn_restart(false, false);
txn_restart(false, 0);
txn_nops = 0;
}
@ -104,7 +104,7 @@ bool testcase_hill::run() {
failure_perror("mdbx_put(insert-b)", rc);
if (++txn_nops >= config.params.batch_write) {
txn_restart(false, false);
txn_restart(false, 0);
txn_nops = 0;
}
@ -118,7 +118,7 @@ bool testcase_hill::run() {
failure_perror("mdbx_put(update-a: 1->0)", rc);
if (++txn_nops >= config.params.batch_write) {
txn_restart(false, false);
txn_restart(false, 0);
txn_nops = 0;
}
@ -129,7 +129,7 @@ bool testcase_hill::run() {
failure_perror("mdbx_del(b)", rc);
if (++txn_nops >= config.params.batch_write) {
txn_restart(false, false);
txn_restart(false, 0);
txn_nops = 0;
}
@ -164,7 +164,7 @@ bool testcase_hill::run() {
failure_perror("mdbx_put(update-a: 0->1)", rc);
if (++txn_nops >= config.params.batch_write) {
txn_restart(false, false);
txn_restart(false, 0);
txn_nops = 0;
}
@ -177,7 +177,7 @@ bool testcase_hill::run() {
failure_perror("mdbx_put(insert-b)", rc);
if (++txn_nops >= config.params.batch_write) {
txn_restart(false, false);
txn_restart(false, 0);
txn_nops = 0;
}
@ -189,7 +189,7 @@ bool testcase_hill::run() {
failure_perror("mdbx_del(a)", rc);
if (++txn_nops >= config.params.batch_write) {
txn_restart(false, false);
txn_restart(false, 0);
txn_nops = 0;
}
@ -200,7 +200,7 @@ bool testcase_hill::run() {
failure_perror("mdbx_del(b)", rc);
if (++txn_nops >= config.params.batch_write) {
txn_restart(false, false);
txn_restart(false, 0);
txn_nops = 0;
}
@ -212,7 +212,7 @@ bool testcase_hill::run() {
if (dbi) {
if (config.params.drop_table && !mode_readonly()) {
txn_begin(false);
txn_begin(0);
db_table_drop(dbi);
txn_end(false);
} else

View File

@ -30,7 +30,7 @@ bool testcase_jitter::run() {
if (flipcoin()) {
jitter_delay();
txn_begin(true);
txn_begin(MDBX_RDONLY);
fetch_canary();
jitter_delay();
txn_end(flipcoin());
@ -51,7 +51,7 @@ bool testcase_jitter::run() {
if (flipcoin()) {
jitter_delay();
txn_begin(true);
txn_begin(MDBX_RDONLY);
jitter_delay();
txn_end(flipcoin());
}

View File

@ -175,18 +175,18 @@ void testcase::db_close() {
log_trace("<< db_close");
}
void testcase::txn_begin(bool readonly) {
log_trace(">> txn_begin(%s)", readonly ? "read-only" : "read-write");
void testcase::txn_begin(unsigned flags) {
log_trace(">> txn_begin(%s)", flags & MDBX_RDONLY ? "read-only" : "read-write");
assert(!txn_guard);
MDBX_txn *txn = nullptr;
int rc =
mdbx_txn_begin(db_guard.get(), nullptr, readonly ? MDBX_RDONLY : 0, &txn);
mdbx_txn_begin(db_guard.get(), nullptr, flags, &txn);
if (unlikely(rc != MDBX_SUCCESS))
failure_perror("mdbx_txn_begin()", rc);
txn_guard.reset(txn);
log_trace("<< txn_begin(%s)", readonly ? "read-only" : "read-write");
log_trace("<< txn_begin(%s)", flags & MDBX_RDONLY ? "read-only" : "read-write");
}
void testcase::txn_end(bool abort) {
@ -207,10 +207,10 @@ void testcase::txn_end(bool abort) {
log_trace("<< txn_end(%s)", abort ? "abort" : "commit");
}
void testcase::txn_restart(bool abort, bool readonly) {
void testcase::txn_restart(bool abort, unsigned flags) {
if (txn_guard)
txn_end(abort);
txn_begin(readonly);
txn_begin(flags);
}
bool testcase::wait4start() {

View File

@ -104,9 +104,9 @@ protected:
void db_prepare();
void db_open();
void db_close();
void txn_begin(bool readonly);
void txn_begin(unsigned flags);
void txn_end(bool abort);
void txn_restart(bool abort, bool readonly);
void txn_restart(bool abort, unsigned flags);
void fetch_canary();
void update_canary(uint64_t increment);
void kick_progress(bool active) const;
@ -130,8 +130,8 @@ protected:
generate_pair(serial, key, data, data_age);
}
bool mode_readonly() const {
return (config.params.mode_flags & MDBX_RDONLY) ? true : false;
unsigned mode_readonly() const {
return (config.params.mode_flags & MDBX_RDONLY) ? MDBX_RDONLY : 0;
}
public: