2019-09-09 18:40:24 +08:00
|
|
|
/*
|
2020-01-11 18:21:43 +08:00
|
|
|
* Copyright 2017-2020 Leonid Yuriev <leo@yuriev.ru>
|
2017-03-30 23:54:57 +08:00
|
|
|
* and other libmdbx authors: please see AUTHORS file.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted only as authorized by the OpenLDAP
|
|
|
|
* Public License.
|
|
|
|
*
|
|
|
|
* A copy of this license is available in the file LICENSE in the
|
|
|
|
* top-level directory of the distribution or, alternatively, at
|
|
|
|
* <http://www.OpenLDAP.org/license.html>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "test.h"
|
|
|
|
|
2017-05-18 01:10:56 +08:00
|
|
|
void configure_actor(unsigned &last_space_id, const actor_testcase testcase,
|
|
|
|
const char *space_id_cstr, const actor_params ¶ms) {
|
2017-03-30 23:54:57 +08:00
|
|
|
unsigned wait4id = 0;
|
|
|
|
if (params.waitfor_nops) {
|
|
|
|
for (auto i = global::actors.rbegin(); i != global::actors.rend(); ++i) {
|
|
|
|
if (i->is_waitable(params.waitfor_nops)) {
|
|
|
|
if (i->signal_nops && i->signal_nops != params.waitfor_nops)
|
|
|
|
failure("Previous waitable actor (id=%u) already linked on %u-ops\n",
|
2017-04-21 23:41:11 +08:00
|
|
|
i->actor_id, i->signal_nops);
|
|
|
|
wait4id = i->actor_id;
|
2017-03-30 23:54:57 +08:00
|
|
|
i->signal_nops = params.waitfor_nops;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!wait4id)
|
|
|
|
failure("No previous waitable actor for %u-ops\n", params.waitfor_nops);
|
|
|
|
}
|
|
|
|
|
2017-05-18 01:10:56 +08:00
|
|
|
unsigned space_id = 0;
|
|
|
|
if (!space_id_cstr || strcmp(space_id_cstr, "auto") == 0)
|
|
|
|
space_id = last_space_id + 1;
|
2017-03-30 23:54:57 +08:00
|
|
|
else {
|
|
|
|
char *end = nullptr;
|
|
|
|
errno = 0;
|
2017-05-18 01:10:56 +08:00
|
|
|
space_id = strtoul(space_id_cstr, &end, 0);
|
2017-03-30 23:54:57 +08:00
|
|
|
if (errno)
|
2017-05-18 01:10:56 +08:00
|
|
|
failure_perror("Expects an integer value for space-id\n", errno);
|
2017-03-30 23:54:57 +08:00
|
|
|
if (end && *end)
|
2017-05-18 01:10:56 +08:00
|
|
|
failure("The '%s' is unexpected for space-id\n", end);
|
2017-03-30 23:54:57 +08:00
|
|
|
}
|
|
|
|
|
2017-05-18 01:10:56 +08:00
|
|
|
if (space_id > ACTOR_ID_MAX)
|
|
|
|
failure("Invalid space-id %u\n", space_id);
|
|
|
|
last_space_id = space_id;
|
2017-03-30 23:54:57 +08:00
|
|
|
|
2017-05-18 01:10:56 +08:00
|
|
|
log_trace("configure_actor: space %u for %s", space_id,
|
|
|
|
testcase2str(testcase));
|
|
|
|
global::actors.emplace_back(
|
|
|
|
actor_config(testcase, params, space_id, wait4id));
|
2017-03-30 23:54:57 +08:00
|
|
|
global::databases.insert(params.pathname_db);
|
|
|
|
}
|
|
|
|
|
2017-04-21 23:41:11 +08:00
|
|
|
void testcase_setup(const char *casename, actor_params ¶ms,
|
2017-05-18 01:10:56 +08:00
|
|
|
unsigned &last_space_id) {
|
2017-03-30 23:54:57 +08:00
|
|
|
if (strcmp(casename, "basic") == 0) {
|
2017-04-21 23:41:11 +08:00
|
|
|
log_notice(">>> testcase_setup(%s)", casename);
|
2019-10-30 02:04:49 +08:00
|
|
|
configure_actor(last_space_id, ac_nested, nullptr, params);
|
2017-05-18 01:10:56 +08:00
|
|
|
configure_actor(last_space_id, ac_hill, nullptr, params);
|
2019-06-22 03:42:45 +08:00
|
|
|
configure_actor(last_space_id, ac_ttl, nullptr, params);
|
2018-11-04 23:57:36 +08:00
|
|
|
configure_actor(last_space_id, ac_copy, nullptr, params);
|
2019-02-04 03:37:57 +08:00
|
|
|
configure_actor(last_space_id, ac_append, nullptr, params);
|
2019-10-30 02:04:49 +08:00
|
|
|
configure_actor(last_space_id, ac_jitter, nullptr, params);
|
|
|
|
configure_actor(last_space_id, ac_try, nullptr, params);
|
|
|
|
configure_actor(last_space_id, ac_jitter, nullptr, params);
|
|
|
|
configure_actor(last_space_id, ac_try, nullptr, params);
|
2017-04-21 23:41:11 +08:00
|
|
|
log_notice("<<< testcase_setup(%s): done", casename);
|
|
|
|
} else {
|
|
|
|
failure("unknown testcase `%s`", casename);
|
2017-03-30 23:54:57 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-18 01:10:56 +08:00
|
|
|
void keycase_setup(const char *casename, actor_params ¶ms) {
|
|
|
|
if (strcmp(casename, "random") == 0 || strcmp(casename, "prng") == 0) {
|
|
|
|
log_notice(">>> keycase_setup(%s)", casename);
|
|
|
|
params.keygen.keycase = kc_random;
|
|
|
|
// TODO
|
|
|
|
log_notice("<<< keycase_setup(%s): done", casename);
|
|
|
|
} else if (strcmp(casename, "dashes") == 0 ||
|
|
|
|
strcmp(casename, "aside") == 0) {
|
|
|
|
log_notice(">>> keycase_setup(%s)", casename);
|
|
|
|
params.keygen.keycase = kc_dashes;
|
|
|
|
// TODO
|
|
|
|
log_notice("<<< keycase_setup(%s): done", casename);
|
|
|
|
} else if (strcmp(casename, "custom") == 0) {
|
|
|
|
log_notice("=== keycase_setup(%s): skip", casename);
|
|
|
|
params.keygen.keycase = kc_custom;
|
|
|
|
} else {
|
|
|
|
failure("unknown keycase `%s`", casename);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-30 23:54:57 +08:00
|
|
|
/* TODO */
|