mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-06 18:54:14 +08:00
mdbx-test: add params-review by actors.
Change-Id: I79fb6cb19c73facd8cc8cefc3bf3101e9d0c672c
This commit is contained in:
parent
b48958c177
commit
f4781b63a8
@ -19,6 +19,10 @@ public:
|
|||||||
testcase_append(const actor_config &config, const mdbx_pid_t pid)
|
testcase_append(const actor_config &config, const mdbx_pid_t pid)
|
||||||
: testcase(config, pid) {}
|
: testcase(config, pid) {}
|
||||||
bool run() override;
|
bool run() override;
|
||||||
|
|
||||||
|
static bool review_params(actor_params ¶ms) {
|
||||||
|
return testcase::review_params(params);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
REGISTER_TESTCASE(append);
|
REGISTER_TESTCASE(append);
|
||||||
|
|
||||||
|
@ -40,22 +40,15 @@ testcase *registry::create_actor(const actor_config &config,
|
|||||||
return instance()->id2record.at(config.testcase)->constructor(config, pid);
|
return instance()->id2record.at(config.testcase)->constructor(config, pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool registry::review_actor_config(actor_config &config) {
|
bool registry::review_actor_params(const actor_testcase id,
|
||||||
return instance()->id2record.at(config.testcase)->review_config(config);
|
actor_params ¶ms) {
|
||||||
|
return instance()->id2record.at(id)->review_params(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
void configure_actor(unsigned &last_space_id, const actor_testcase testcase,
|
void configure_actor(unsigned &last_space_id, const actor_testcase testcase,
|
||||||
const char *space_id_cstr, actor_params params) {
|
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;
|
unsigned wait4id = 0;
|
||||||
if (params.waitfor_nops) {
|
if (params.waitfor_nops) {
|
||||||
for (auto i = global::actors.rbegin(); i != global::actors.rend(); ++i) {
|
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);
|
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)
|
if (space_id > ACTOR_ID_MAX)
|
||||||
failure("Invalid space-id %u\n", space_id);
|
failure("Invalid space-id %u\n", space_id);
|
||||||
last_space_id = space_id;
|
last_space_id = space_id;
|
||||||
|
17
test/test.h
17
test/test.h
@ -102,7 +102,7 @@ class registry {
|
|||||||
struct record {
|
struct record {
|
||||||
actor_testcase id;
|
actor_testcase id;
|
||||||
std::string name;
|
std::string name;
|
||||||
bool (*review_config)(actor_config &);
|
bool (*review_params)(actor_params &);
|
||||||
testcase *(*constructor)(const actor_config &, const mdbx_pid_t);
|
testcase *(*constructor)(const actor_config &, const mdbx_pid_t);
|
||||||
};
|
};
|
||||||
std::unordered_map<std::string, const record *> name2id;
|
std::unordered_map<std::string, const record *> name2id;
|
||||||
@ -115,7 +115,7 @@ public:
|
|||||||
factory(const actor_testcase id, const char *name) {
|
factory(const actor_testcase id, const char *name) {
|
||||||
this->id = id;
|
this->id = id;
|
||||||
this->name = name;
|
this->name = name;
|
||||||
review_config = TESTCASE::review;
|
review_params = TESTCASE::review_params;
|
||||||
constructor = [](const actor_config &config,
|
constructor = [](const actor_config &config,
|
||||||
const mdbx_pid_t pid) -> testcase * {
|
const mdbx_pid_t pid) -> testcase * {
|
||||||
return new TESTCASE(config, pid);
|
return new TESTCASE(config, pid);
|
||||||
@ -123,7 +123,8 @@ public:
|
|||||||
add(this);
|
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,
|
static testcase *create_actor(const actor_config &config,
|
||||||
const mdbx_pid_t pid);
|
const mdbx_pid_t pid);
|
||||||
};
|
};
|
||||||
@ -288,8 +289,14 @@ public:
|
|||||||
memset(&last, 0, sizeof(last));
|
memset(&last, 0, sizeof(last));
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool review(actor_config &config) {
|
static bool review_params(actor_params ¶ms) {
|
||||||
(void)config;
|
// 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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user