From 0fb127b9358a7ecebccac3bf4910fe8aa9561d27 Mon Sep 17 00:00:00 2001 From: Leonid Yuriev Date: Sun, 5 Jul 2020 02:25:52 +0300 Subject: [PATCH] mdbx-test: add `--random-writemap[=YES|no]` option. Change-Id: Ie83f64d4a7e199f828540f029c2c47deddb05c01 --- test/config.cc | 2 ++ test/config.h | 7 ++++--- test/main.cc | 5 +++++ test/test.cc | 8 +++++++- test/test.h | 3 ++- 5 files changed, 20 insertions(+), 5 deletions(-) diff --git a/test/config.cc b/test/config.cc index 5e197971..f8e6866f 100644 --- a/test/config.cc +++ b/test/config.cc @@ -373,6 +373,8 @@ void dump(const char *title) { i->params.pagesize); dump_verbs("mode", i->params.mode_flags, mode_bits); + log_verbose("random-writemap: %s\n", + i->params.random_writemap ? "Yes" : "No"); dump_verbs("table", i->params.table_flags, table_bits); if (i->params.test_nops) diff --git a/test/config.h b/test/config.h index 2ab4742a..5f033129 100644 --- a/test/config.h +++ b/test/config.h @@ -265,9 +265,10 @@ struct actor_params_pod { keygen_params_pod keygen; uint8_t loglevel{0}; - bool drop_table{0}; - bool ignore_dbfull{0}; - bool speculum{0}; + bool drop_table{false}; + bool ignore_dbfull{false}; + bool speculum{false}; + bool random_writemap{true}; }; struct actor_config_pod { diff --git a/test/main.cc b/test/main.cc index c6b15ea2..10016ab3 100644 --- a/test/main.cc +++ b/test/main.cc @@ -101,6 +101,7 @@ void __noreturn usage(void) { " notls == MDBX_NOTLS\n" " nordahead == MDBX_NORDAHEAD\n" " nomeminit == MDBX_NOMEMINIT\n" + " --random-writemap[=YES|no] Toggle MDBX_WRITEMAP randomly\n" "Key-value space/table options:\n" " --table={[+-]FLAG}[,[+-]FLAG]...\n" " key.reverse == MDBX_REVERSEKEY\n" @@ -165,6 +166,7 @@ void actor_params::set_defaults(const std::string &tmpdir) { drop_table = false; ignore_dbfull = false; speculum = false; + random_writemap = true; max_readers = 42; max_tables = 42; @@ -259,6 +261,9 @@ int main(int argc, char *const argv[]) { if (config::parse_option(argc, argv, narg, "mode", params.mode_flags, config::mode_bits)) continue; + if (config::parse_option(argc, argv, narg, "random-writemap", + params.random_writemap)) + continue; if (config::parse_option(argc, argv, narg, "table", params.table_flags, config::table_bits)) { if ((params.table_flags & MDBX_DUPFIXED) == 0) diff --git a/test/test.cc b/test/test.cc index beeba7ab..9af04ac9 100644 --- a/test/test.cc +++ b/test/test.cc @@ -144,8 +144,14 @@ void testcase::db_open() { db_prepare(); jitter_delay(true); + + unsigned mode = (unsigned)config.params.mode_flags; + if (config.params.random_writemap && flipcoin()) + mode ^= MDBX_WRITEMAP; + + actual_db_mode = mode; int rc = mdbx_env_open(db_guard.get(), config.params.pathname_db.c_str(), - (unsigned)config.params.mode_flags, 0640); + mode, 0640); if (unlikely(rc != MDBX_SUCCESS)) failure_perror("mdbx_env_open()", rc); diff --git a/test/test.h b/test/test.h index 8ecf5c46..43c6c038 100644 --- a/test/test.h +++ b/test/test.h @@ -169,8 +169,9 @@ protected: static int oom_callback(MDBX_env *env, mdbx_pid_t pid, mdbx_tid_t tid, uint64_t txn, unsigned gap, size_t space, int retry); + unsigned actual_db_mode{0}; bool is_nested_txn_available() const { - return (config.params.mode_flags & MDBX_WRITEMAP) == 0; + return (actual_db_mode & MDBX_WRITEMAP) == 0; } void kick_progress(bool active) const; void db_prepare();