mdbx-test: add params-review by actors.

Change-Id: I79fb6cb19c73facd8cc8cefc3bf3101e9d0c672c
This commit is contained in:
Leonid Yuriev 2021-03-16 01:45:49 +03:00
parent b48958c177
commit f4781b63a8
3 changed files with 22 additions and 15 deletions

View File

@ -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 &params) {
return testcase::review_params(params);
}
};
REGISTER_TESTCASE(append);

View File

@ -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 &params) {
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;

View File

@ -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<std::string, const record *> 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 &params);
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 &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;
return true;
}