From f4781b63a888190a3a772798c667214480ca0ed7 Mon Sep 17 00:00:00 2001 From: Leonid Yuriev Date: Tue, 16 Mar 2021 01:45:49 +0300 Subject: [PATCH] mdbx-test: add params-review by actors. Change-Id: I79fb6cb19c73facd8cc8cefc3bf3101e9d0c672c --- test/append.cc | 4 ++++ test/cases.cc | 16 ++++++---------- test/test.h | 17 ++++++++++++----- 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/test/append.cc b/test/append.cc index f26c0345..495d4be1 100644 --- a/test/append.cc +++ b/test/append.cc @@ -19,6 +19,10 @@ public: testcase_append(const actor_config &config, const mdbx_pid_t pid) : testcase(config, pid) {} bool run() override; + + static bool review_params(actor_params ¶ms) { + return testcase::review_params(params); + } }; REGISTER_TESTCASE(append); diff --git a/test/cases.cc b/test/cases.cc index cd5b6af2..999fb823 100644 --- a/test/cases.cc +++ b/test/cases.cc @@ -40,22 +40,15 @@ testcase *registry::create_actor(const actor_config &config, return instance()->id2record.at(config.testcase)->constructor(config, pid); } -bool registry::review_actor_config(actor_config &config) { - return instance()->id2record.at(config.testcase)->review_config(config); +bool registry::review_actor_params(const actor_testcase id, + actor_params ¶ms) { + return instance()->id2record.at(id)->review_params(params); } //----------------------------------------------------------------------------- void configure_actor(unsigned &last_space_id, const actor_testcase testcase, const char *space_id_cstr, actor_params params) { - // silently fix key/data length for fixed-length modes - if ((params.table_flags & MDBX_INTEGERKEY) && - params.keylen_min != params.keylen_max) - params.keylen_min = params.keylen_max; - if ((params.table_flags & (MDBX_INTEGERDUP | MDBX_DUPFIXED)) && - params.datalen_min != params.datalen_max) - params.datalen_min = params.datalen_max; - unsigned wait4id = 0; if (params.waitfor_nops) { for (auto i = global::actors.rbegin(); i != global::actors.rend(); ++i) { @@ -85,6 +78,9 @@ void configure_actor(unsigned &last_space_id, const actor_testcase testcase, failure("The '%s' is unexpected for space-id\n", end); } + if (!registry::review_actor_params(testcase, params)) + failure("Actor config-review failed for space-id %u\n", space_id); + if (space_id > ACTOR_ID_MAX) failure("Invalid space-id %u\n", space_id); last_space_id = space_id; diff --git a/test/test.h b/test/test.h index 1ee74758..8724cef5 100644 --- a/test/test.h +++ b/test/test.h @@ -102,7 +102,7 @@ class registry { struct record { actor_testcase id; std::string name; - bool (*review_config)(actor_config &); + bool (*review_params)(actor_params &); testcase *(*constructor)(const actor_config &, const mdbx_pid_t); }; std::unordered_map name2id; @@ -115,7 +115,7 @@ public: factory(const actor_testcase id, const char *name) { this->id = id; this->name = name; - review_config = TESTCASE::review; + review_params = TESTCASE::review_params; constructor = [](const actor_config &config, const mdbx_pid_t pid) -> testcase * { return new TESTCASE(config, pid); @@ -123,7 +123,8 @@ public: add(this); } }; - static bool review_actor_config(actor_config &config); + static bool review_actor_params(const actor_testcase id, + actor_params ¶ms); static testcase *create_actor(const actor_config &config, const mdbx_pid_t pid); }; @@ -288,8 +289,14 @@ public: memset(&last, 0, sizeof(last)); } - static bool review(actor_config &config) { - (void)config; + static bool review_params(actor_params ¶ms) { + // silently fix key/data length for fixed-length modes + if ((params.table_flags & MDBX_INTEGERKEY) && + params.keylen_min != params.keylen_max) + params.keylen_min = params.keylen_max; + if ((params.table_flags & (MDBX_INTEGERDUP | MDBX_DUPFIXED)) && + params.datalen_min != params.datalen_max) + params.datalen_min = params.datalen_max; return true; }