mdbx-test: more auto-adjustment of min/max length of key/values.

Change-Id: I22ac3845a341f8f4414ac0719f1a4c007f035b60
This commit is contained in:
Leonid Yuriev 2020-10-23 23:21:51 +03:00
parent 7522246ccd
commit 56809cb711
3 changed files with 35 additions and 6 deletions

View File

@ -15,7 +15,15 @@
#include "test.h"
void configure_actor(unsigned &last_space_id, const actor_testcase testcase,
const char *space_id_cstr, const 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;
if (params.waitfor_nops) {
for (auto i = global::actors.rbegin(); i != global::actors.rend(); ++i) {
@ -56,7 +64,7 @@ void configure_actor(unsigned &last_space_id, const actor_testcase testcase,
global::databases.insert(params.pathname_db);
}
void testcase_setup(const char *casename, actor_params &params,
void testcase_setup(const char *casename, const actor_params &params,
unsigned &last_space_id) {
if (strcmp(casename, "basic") == 0) {
log_notice(">>> testcase_setup(%s)", casename);

View File

@ -270,6 +270,27 @@ int main(int argc, char *const argv[]) {
if ((params.table_flags & MDBX_DUPSORT) == 0)
params.table_flags &=
~(MDBX_DUPFIXED | MDBX_REVERSEDUP | MDBX_INTEGERDUP);
const unsigned keylen_max = params.mdbx_keylen_max();
if (params.keylen_min > keylen_max)
params.keylen_min = keylen_max;
if (params.keylen_max > keylen_max)
params.keylen_max = keylen_max;
const unsigned keylen_min = params.mdbx_keylen_min();
if (params.keylen_min < keylen_min)
params.keylen_min = keylen_min;
if (params.keylen_max < keylen_min)
params.keylen_max = keylen_min;
const unsigned datalen_max = params.mdbx_datalen_max();
if (params.datalen_min > datalen_max)
params.datalen_min = datalen_max;
if (params.datalen_max > datalen_max)
params.datalen_max = datalen_max;
const unsigned datalen_min = params.mdbx_datalen_min();
if (params.datalen_min < datalen_min)
params.datalen_min = datalen_min;
if (params.datalen_max < datalen_min)
params.datalen_max = datalen_min;
continue;
}
@ -371,7 +392,7 @@ int main(int argc, char *const argv[]) {
params.datalen_min, config::no_scale,
params.mdbx_datalen_min(),
params.mdbx_datalen_max())) {
if ((params.table_flags & MDBX_DUPFIXED) ||
if ((params.table_flags & (MDBX_INTEGERDUP | MDBX_DUPFIXED)) ||
params.datalen_max < params.datalen_min)
params.datalen_max = params.datalen_min;
continue;
@ -380,7 +401,7 @@ int main(int argc, char *const argv[]) {
params.datalen_max, config::no_scale,
params.mdbx_datalen_min(),
params.mdbx_datalen_max())) {
if ((params.table_flags & MDBX_DUPFIXED) ||
if ((params.table_flags & (MDBX_INTEGERDUP | MDBX_DUPFIXED)) ||
params.datalen_min > params.datalen_max)
params.datalen_min = params.datalen_max;
continue;

View File

@ -42,10 +42,10 @@
bool test_execute(const actor_config &config);
std::string thunk_param(const actor_config &config);
void testcase_setup(const char *casename, actor_params &params,
void testcase_setup(const char *casename, const actor_params &params,
unsigned &last_space_id);
void configure_actor(unsigned &last_space_id, const actor_testcase testcase,
const char *space_id_cstr, const actor_params &params);
const char *space_id_cstr, actor_params params);
void keycase_setup(const char *casename, actor_params &params);
namespace global {