2019-09-09 18:40:24 +08:00
|
|
|
/*
|
2023-01-16 21:24:51 +08:00
|
|
|
* Copyright 2017-2023 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>.
|
|
|
|
*/
|
|
|
|
|
2022-11-08 21:17:14 +08:00
|
|
|
#include "test.h++"
|
2017-03-30 23:54:57 +08:00
|
|
|
|
2019-10-30 22:12:46 +08:00
|
|
|
#if !(defined(_WIN32) || defined(_WIN64))
|
|
|
|
#include <sys/resource.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#endif /* !Windows */
|
|
|
|
|
2020-09-14 21:40:46 +08:00
|
|
|
MDBX_NORETURN void usage(void) {
|
2019-10-31 19:45:21 +08:00
|
|
|
puts(
|
|
|
|
"usage:\n"
|
|
|
|
" --help or -h Show this text\n"
|
|
|
|
"Common parameters:\n"
|
2022-11-04 20:07:46 +08:00
|
|
|
" --loglevel=[0-7]|[fatal..extra]s"
|
2019-10-31 19:45:21 +08:00
|
|
|
" --pathname=... Path and/or name of database files\n"
|
|
|
|
" --repeat=N Set repeat counter\n"
|
2020-09-22 11:51:47 +08:00
|
|
|
" --threads=N Number of thread (unsupported for now)\n"
|
2019-10-31 19:45:21 +08:00
|
|
|
" --timeout=N[s|m|h|d] Set timeout in seconds/minutes/hours/days\n"
|
|
|
|
" --failfast[=YES/no] Lill all actors on first failure/error\n"
|
|
|
|
" --max-readers=N See mdbx_env_set_maxreaders() description\n"
|
|
|
|
" --max-tables=N Se mdbx_env_set_maxdbs() description\n"
|
|
|
|
" --dump-config[=YES/no] Dump entire test config before run\n"
|
|
|
|
" --progress[=YES/no] Enable/disable progress `canary`\n"
|
|
|
|
" --console[=yes/no] Enable/disable console-like output\n"
|
|
|
|
" --cleanup-before[=YES/no] Cleanup/remove and re-create database\n"
|
|
|
|
" --cleanup-after[=YES/no] Cleanup/remove database after completion\n"
|
|
|
|
"Database size control:\n"
|
|
|
|
" --pagesize=... Database page size: min, max, 256..65536\n"
|
|
|
|
" --size-lower=N[K|M|G|T] Lower-bound of size in Kb/Mb/Gb/Tb\n"
|
|
|
|
" --size-upper Upper-bound of size in Kb/Mb/Gb/Tb\n"
|
|
|
|
" --size Initial size in Kb/Mb/Gb/Tb\n"
|
|
|
|
" --shrink-threshold Shrink threshold in Kb/Mb/Gb/Tb\n"
|
|
|
|
" --growth-step Grow step in Kb/Mb/Gb/Tb\n"
|
2020-09-22 11:51:47 +08:00
|
|
|
"Predefined complex scenarios/cases:\n"
|
2019-10-31 19:45:21 +08:00
|
|
|
" --case=... Only `basic` scenario implemented for now\n"
|
|
|
|
" basic == Simultaneous multi-process execution\n"
|
|
|
|
" of test-actors: nested,hill,ttl,copy,append,jitter,try\n"
|
|
|
|
"Test actors:\n"
|
|
|
|
" --hill Fill-up and empty-down\n"
|
|
|
|
" by CRUD-operation quads\n"
|
|
|
|
" --ttl Stochastic time-to-live simulation\n"
|
|
|
|
" --nested Nested transactionы\n"
|
|
|
|
" with stochastic-size bellows\n"
|
|
|
|
" --jitter Jitter/delays simulation\n"
|
|
|
|
" --try Try write-transaction, no more\n"
|
|
|
|
" --copy Online copy/backup\n"
|
|
|
|
" --append Append-mode insertions\n"
|
|
|
|
" --dead.reader Dead-reader simulator\n"
|
|
|
|
" --dead.writer Dead-writer simulator\n"
|
2023-11-09 00:58:18 +08:00
|
|
|
#if !defined(_WIN32) && !defined(_WIN64)
|
|
|
|
" --fork.reader After-fork reader\n"
|
|
|
|
" --fork.writer After-fork writer\n"
|
|
|
|
#endif /* Windows */
|
2019-10-31 19:45:21 +08:00
|
|
|
"Actor options:\n"
|
|
|
|
" --batch.read=N Read-operations batch size\n"
|
|
|
|
" --batch.write=N Write-operations batch size\n"
|
|
|
|
" --delay=N | --no-delay (no)Delay test-actor before start\n"
|
|
|
|
" --wait4ops=N | --no-wait4ops (no)Wait for previous test-actor\n"
|
|
|
|
" completes # ops before start\n"
|
|
|
|
" --duration=N[s|m|h|d] Define running duration\n"
|
|
|
|
" --nops=N[K|M|G|T] Define number of operations/steps\n"
|
|
|
|
" --inject-writefault[=yes|NO] TBD (see the source code)\n"
|
|
|
|
" --drop[=yes|NO] Drop key-value space/table on "
|
|
|
|
"completion\n"
|
|
|
|
" --ignore-dbfull[=yes|NO] Ignore MDBX_MAP_FULL error\n"
|
|
|
|
" --speculum[=yes|NO] Use internal `speculum` to check "
|
|
|
|
"dataset\n"
|
2022-01-21 04:38:27 +08:00
|
|
|
" --geometry-jitter[=YES|no] Use jitter for geometry upper-limit\n"
|
2019-10-31 19:45:21 +08:00
|
|
|
"Keys and Value:\n"
|
2020-01-04 22:25:51 +08:00
|
|
|
" --keylen.min=N Minimal keys length\n"
|
|
|
|
" --keylen.max=N Miximal keys length\n"
|
2021-03-15 19:20:07 +08:00
|
|
|
" --keylen=N Set both min/max for keys length\n"
|
2019-10-31 19:45:21 +08:00
|
|
|
" --datalen.min=N Minimal data length\n"
|
|
|
|
" --datalen.max=N Miximal data length\n"
|
2021-03-15 19:20:07 +08:00
|
|
|
" --datalen=N Set both min/max for data length\n"
|
2019-10-31 19:45:21 +08:00
|
|
|
" --keygen.width=N TBD (see the source code)\n"
|
|
|
|
" --keygen.mesh=N TBD (see the source code)\n"
|
|
|
|
" --keygen.seed=N TBD (see the source code)\n"
|
2020-05-25 07:25:24 +08:00
|
|
|
" --keygen.zerofill=yes|NO TBD (see the source code)\n"
|
2019-10-31 19:45:21 +08:00
|
|
|
" --keygen.split=N TBD (see the source code)\n"
|
|
|
|
" --keygen.rotate=N TBD (see the source code)\n"
|
|
|
|
" --keygen.offset=N TBD (see the source code)\n"
|
|
|
|
" --keygen.case=random Generator case (only `random` for now)\n"
|
|
|
|
"Database operation mode:\n"
|
|
|
|
" --mode={[+-]FLAG}[,[+-]FLAG]...\n"
|
2019-12-15 20:13:46 +08:00
|
|
|
" nosubdir == MDBX_NOSUBDIR\n"
|
|
|
|
" rdonly == MDBX_RDONLY\n"
|
2021-07-20 16:15:54 +08:00
|
|
|
" exclusive == MDBX_EXCLUSIVE\n"
|
|
|
|
" accede == MDBX_ACCEDE\n"
|
2019-12-15 20:13:46 +08:00
|
|
|
" nometasync == MDBX_NOMETASYNC\n"
|
|
|
|
" lifo == MDBX_LIFORECLAIM\n"
|
|
|
|
" nosync-safe == MDBX_SAFE_NOSYNC\n"
|
|
|
|
" writemap == MDBX_WRITEMAP\n"
|
|
|
|
" nosync-utterly == MDBX_UTTERLY_NOSYNC\n"
|
|
|
|
" perturb == MDBX_PAGEPERTURB\n"
|
|
|
|
" notls == MDBX_NOTLS\n"
|
|
|
|
" nordahead == MDBX_NORDAHEAD\n"
|
|
|
|
" nomeminit == MDBX_NOMEMINIT\n"
|
2020-07-05 07:25:52 +08:00
|
|
|
" --random-writemap[=YES|no] Toggle MDBX_WRITEMAP randomly\n"
|
2019-10-31 19:45:21 +08:00
|
|
|
"Key-value space/table options:\n"
|
|
|
|
" --table={[+-]FLAG}[,[+-]FLAG]...\n"
|
|
|
|
" key.reverse == MDBX_REVERSEKEY\n"
|
|
|
|
" key.integer == MDBX_INTEGERKEY\n"
|
|
|
|
" data.dups == MDBX_DUPSORT\n"
|
|
|
|
" data.integer == MDBX_INTEGERDUP | MDBX_DUPFIXED | MDBX_DUPSORT\n"
|
|
|
|
" data.fixed == MDBX_DUPFIXED | MDBX_DUPSORT\n"
|
|
|
|
" data.reverse == MDBX_REVERSEDUP | MDBX_DUPSORT\n");
|
2017-03-30 23:54:57 +08:00
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2018-03-20 01:41:08 +08:00
|
|
|
void actor_params::set_defaults(const std::string &tmpdir) {
|
2017-03-30 23:54:57 +08:00
|
|
|
pathname_log = "";
|
|
|
|
loglevel =
|
2019-10-02 17:07:02 +08:00
|
|
|
#if defined(NDEBUG) || defined(_WIN32) || defined(_WIN64)
|
2019-10-02 03:01:45 +08:00
|
|
|
logging::verbose;
|
2017-03-30 23:54:57 +08:00
|
|
|
#else
|
2017-04-11 17:55:16 +08:00
|
|
|
logging::trace;
|
2017-03-30 23:54:57 +08:00
|
|
|
#endif
|
|
|
|
|
2018-03-20 01:41:08 +08:00
|
|
|
pathname_db = tmpdir + "mdbx-test.db";
|
2023-02-24 15:43:00 +08:00
|
|
|
mode_flags = MDBX_NOSUBDIR | MDBX_WRITEMAP | MDBX_SYNC_DURABLE | MDBX_ACCEDE;
|
2017-05-24 06:42:10 +08:00
|
|
|
table_flags = MDBX_DUPSORT;
|
2018-08-22 05:55:21 +08:00
|
|
|
|
|
|
|
size_lower = -1;
|
2022-02-01 21:06:56 +08:00
|
|
|
size_now = intptr_t((table_flags & MDBX_DUPSORT) ? 256 : 1024) << 20;
|
|
|
|
size_now = std::min(size_now, mdbx_limits_dbsize_max(-1));
|
2018-08-22 05:55:21 +08:00
|
|
|
size_upper = -1;
|
|
|
|
shrink_threshold = -1;
|
|
|
|
growth_step = -1;
|
|
|
|
pagesize = -1;
|
2017-05-18 01:10:56 +08:00
|
|
|
|
|
|
|
keygen.seed = 1;
|
2020-05-25 07:25:24 +08:00
|
|
|
keygen.zero_fill = false;
|
2017-05-18 01:10:56 +08:00
|
|
|
keygen.keycase = kc_random;
|
2018-08-31 23:50:35 +08:00
|
|
|
keygen.width = (table_flags & MDBX_DUPSORT) ? 32 : 64;
|
|
|
|
keygen.mesh = keygen.width;
|
2017-05-18 01:10:56 +08:00
|
|
|
keygen.split = keygen.width / 2;
|
2018-09-01 00:17:41 +08:00
|
|
|
keygen.rotate = 3;
|
|
|
|
keygen.offset = 41;
|
2017-03-30 23:54:57 +08:00
|
|
|
|
|
|
|
test_duration = 0;
|
2017-04-21 23:41:11 +08:00
|
|
|
test_nops = 1000;
|
2017-03-30 23:54:57 +08:00
|
|
|
nrepeat = 1;
|
|
|
|
nthreads = 1;
|
|
|
|
|
2018-08-31 22:05:00 +08:00
|
|
|
keylen_min = mdbx_keylen_min();
|
|
|
|
keylen_max = mdbx_keylen_max();
|
|
|
|
datalen_min = mdbx_datalen_min();
|
|
|
|
datalen_max = std::min(mdbx_datalen_max(), 256u * 1024 + 42);
|
2017-03-30 23:54:57 +08:00
|
|
|
|
2019-06-22 07:00:52 +08:00
|
|
|
batch_read = 42;
|
|
|
|
batch_write = 42;
|
2017-03-30 23:54:57 +08:00
|
|
|
|
|
|
|
delaystart = 0;
|
|
|
|
waitfor_nops = 0;
|
2018-03-20 02:26:14 +08:00
|
|
|
inject_writefaultn = 0;
|
2017-03-30 23:54:57 +08:00
|
|
|
|
|
|
|
drop_table = false;
|
2019-06-23 20:55:13 +08:00
|
|
|
ignore_dbfull = false;
|
2019-10-09 22:56:59 +08:00
|
|
|
speculum = false;
|
2020-07-05 07:25:52 +08:00
|
|
|
random_writemap = true;
|
2017-03-30 23:54:57 +08:00
|
|
|
|
|
|
|
max_readers = 42;
|
|
|
|
max_tables = 42;
|
2017-04-21 23:41:11 +08:00
|
|
|
|
|
|
|
global::config::timeout_duration_seconds = 0 /* infinite */;
|
|
|
|
global::config::dump_config = true;
|
|
|
|
global::config::cleanup_before = true;
|
|
|
|
global::config::cleanup_after = true;
|
2017-04-23 17:54:37 +08:00
|
|
|
global::config::failfast = true;
|
2019-10-02 06:17:09 +08:00
|
|
|
global::config::progress_indicator = true;
|
|
|
|
global::config::console_mode = osal_istty(STDERR_FILENO);
|
2022-01-21 04:38:27 +08:00
|
|
|
global::config::geometry_jitter = true;
|
2017-03-30 23:54:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace global {
|
|
|
|
|
|
|
|
std::vector<actor_config> actors;
|
|
|
|
std::unordered_map<unsigned, actor_config *> events;
|
|
|
|
std::unordered_map<mdbx_pid_t, actor_config *> pid2actor;
|
|
|
|
std::set<std::string> databases;
|
|
|
|
unsigned nactors;
|
2020-09-22 11:51:47 +08:00
|
|
|
chrono::time start_monotonic;
|
|
|
|
chrono::time deadline_monotonic;
|
2017-04-21 23:41:11 +08:00
|
|
|
bool singlemode;
|
2017-03-30 23:54:57 +08:00
|
|
|
|
|
|
|
namespace config {
|
2017-04-21 23:41:11 +08:00
|
|
|
unsigned timeout_duration_seconds;
|
2017-03-30 23:54:57 +08:00
|
|
|
bool dump_config;
|
2017-04-21 23:41:11 +08:00
|
|
|
bool cleanup_before;
|
|
|
|
bool cleanup_after;
|
2017-04-23 17:54:37 +08:00
|
|
|
bool failfast;
|
2017-05-24 07:16:25 +08:00
|
|
|
bool progress_indicator;
|
2019-10-02 06:17:09 +08:00
|
|
|
bool console_mode;
|
2022-01-21 04:38:27 +08:00
|
|
|
bool geometry_jitter;
|
2017-03-30 23:54:57 +08:00
|
|
|
} /* namespace config */
|
|
|
|
|
|
|
|
} /* namespace global */
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
const char global::thunk_param_prefix[] = "--execute=";
|
|
|
|
|
|
|
|
std::string thunk_param(const actor_config &config) {
|
|
|
|
return config.serialize(global::thunk_param_prefix);
|
|
|
|
}
|
|
|
|
|
|
|
|
void cleanup() {
|
2017-04-11 05:21:53 +08:00
|
|
|
log_trace(">> cleanup");
|
2020-05-13 21:40:23 +08:00
|
|
|
for (const auto &db_path : global::databases) {
|
2020-10-10 05:59:12 +08:00
|
|
|
int err = mdbx_env_delete(db_path.c_str(), MDBX_ENV_JUST_DELETE);
|
|
|
|
if (err != MDBX_SUCCESS && err != MDBX_RESULT_TRUE)
|
2020-05-13 21:40:23 +08:00
|
|
|
failure_perror(db_path.c_str(), err);
|
|
|
|
}
|
2017-04-11 05:21:53 +08:00
|
|
|
log_trace("<< cleanup");
|
2017-03-30 23:54:57 +08:00
|
|
|
}
|
|
|
|
|
2021-07-13 17:38:58 +08:00
|
|
|
static void fixup4qemu(actor_params ¶ms) {
|
|
|
|
#ifdef MDBX_SAFE4QEMU
|
|
|
|
#if MDBX_WORDBITS == 32
|
|
|
|
intptr_t safe4qemu_limit = size_t(512) << 20 /* 512 megabytes */;
|
|
|
|
#if defined(__SANITIZE_ADDRESS__)
|
|
|
|
safe4qemu_limit >>= 1;
|
|
|
|
#else
|
|
|
|
if (RUNNING_ON_VALGRIND)
|
|
|
|
safe4qemu_limit >>= 1;
|
|
|
|
#endif /* __SANITIZE_ADDRESS__ */
|
|
|
|
|
|
|
|
if (params.size_lower > safe4qemu_limit ||
|
|
|
|
params.size_now > safe4qemu_limit ||
|
|
|
|
params.size_upper > safe4qemu_limit) {
|
|
|
|
params.size_upper = std::min(params.size_upper, safe4qemu_limit);
|
|
|
|
params.size_now = std::min(params.size_now, params.size_upper);
|
|
|
|
params.size_lower = std::min(params.size_lower, params.size_now);
|
|
|
|
log_notice("workaround: for conformance 32-bit build with "
|
|
|
|
"QEMU/ASAN/Valgrind database size reduced to %zu megabytes",
|
|
|
|
safe4qemu_limit >> 20);
|
|
|
|
}
|
|
|
|
#endif /* MDBX_WORDBITS == 32 */
|
|
|
|
|
|
|
|
#if defined(__alpha__) || defined(__alpha) || defined(__sparc__) || \
|
|
|
|
defined(__sparc) || defined(__sparc64__) || defined(__sparc64)
|
|
|
|
if (params.size_lower != params.size_upper) {
|
|
|
|
log_notice(
|
|
|
|
"workaround: for conformance Alpha/Sparc build with QEMU/ASAN/Valgrind "
|
|
|
|
"enforce fixed database size %zu megabytes",
|
|
|
|
params.size_upper >> 20);
|
|
|
|
params.size_lower = params.size_now = params.size_upper;
|
|
|
|
}
|
|
|
|
#endif /* Alpha || Sparc */
|
|
|
|
#endif /* MDBX_SAFE4QEMU */
|
|
|
|
(void)params;
|
|
|
|
}
|
|
|
|
|
2017-03-30 23:54:57 +08:00
|
|
|
int main(int argc, char *const argv[]) {
|
|
|
|
|
|
|
|
#ifdef _DEBUG
|
|
|
|
log_trace("#argc = %d", argc);
|
|
|
|
for (int i = 0; i < argc; ++i)
|
|
|
|
log_trace("#argv[%d] = %s", i, argv[i]);
|
|
|
|
#endif /* _DEBUG */
|
|
|
|
|
|
|
|
if (argc < 2)
|
2019-10-31 19:45:21 +08:00
|
|
|
failure("No parameters given. Try --help\n");
|
2017-03-30 23:54:57 +08:00
|
|
|
|
2018-06-19 02:29:12 +08:00
|
|
|
if (argc == 2 && strncmp(argv[1], global::thunk_param_prefix,
|
|
|
|
strlen(global::thunk_param_prefix)) == 0)
|
2017-03-30 23:54:57 +08:00
|
|
|
return test_execute(
|
|
|
|
actor_config(argv[1] + strlen(global::thunk_param_prefix)))
|
|
|
|
? EXIT_SUCCESS
|
|
|
|
: EXIT_FAILURE;
|
|
|
|
|
2019-10-31 19:45:21 +08:00
|
|
|
if (argc == 2 &&
|
|
|
|
(strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-h") == 0))
|
|
|
|
usage();
|
|
|
|
|
2017-03-30 23:54:57 +08:00
|
|
|
actor_params params;
|
2018-03-20 01:41:08 +08:00
|
|
|
params.set_defaults(osal_tempdir());
|
2017-03-30 23:54:57 +08:00
|
|
|
global::config::dump_config = true;
|
2017-04-11 17:55:16 +08:00
|
|
|
logging::setup((logging::loglevel)params.loglevel, "main");
|
2017-05-18 01:10:56 +08:00
|
|
|
unsigned last_space_id = 0;
|
2017-03-30 23:54:57 +08:00
|
|
|
|
2017-04-21 23:41:11 +08:00
|
|
|
for (int narg = 1; narg < argc; ++narg) {
|
2022-01-21 04:38:27 +08:00
|
|
|
if (config::parse_option(argc, argv, narg, "dump-config",
|
|
|
|
global::config::dump_config))
|
|
|
|
continue;
|
|
|
|
if (config::parse_option(argc, argv, narg, "cleanup-before",
|
|
|
|
global::config::cleanup_before))
|
|
|
|
continue;
|
|
|
|
if (config::parse_option(argc, argv, narg, "cleanup-after",
|
|
|
|
global::config::cleanup_after))
|
|
|
|
continue;
|
|
|
|
if (config::parse_option(argc, argv, narg, "failfast",
|
|
|
|
global::config::failfast))
|
|
|
|
continue;
|
|
|
|
if (config::parse_option(argc, argv, narg, "progress",
|
|
|
|
global::config::progress_indicator))
|
|
|
|
continue;
|
|
|
|
if (config::parse_option(argc, argv, narg, "console",
|
|
|
|
global::config::console_mode))
|
|
|
|
continue;
|
|
|
|
if (config::parse_option(argc, argv, narg, "geometry-jitter",
|
|
|
|
global::config::geometry_jitter))
|
|
|
|
continue;
|
|
|
|
if (config::parse_option(argc, argv, narg, "timeout",
|
|
|
|
global::config::timeout_duration_seconds,
|
|
|
|
config::duration, 1))
|
|
|
|
continue;
|
2017-04-21 23:41:11 +08:00
|
|
|
|
2022-04-22 00:42:57 +08:00
|
|
|
logging::loglevel loglevel;
|
|
|
|
if (config::parse_option(argc, argv, narg, "loglevel", loglevel)) {
|
|
|
|
logging::setup(loglevel, "main");
|
|
|
|
params.loglevel = static_cast<uint8_t>(loglevel);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2022-01-21 04:38:27 +08:00
|
|
|
const char *value = nullptr;
|
2017-04-21 23:41:11 +08:00
|
|
|
if (config::parse_option(argc, argv, narg, "case", &value)) {
|
2021-07-13 17:38:58 +08:00
|
|
|
fixup4qemu(params);
|
2017-05-18 01:10:56 +08:00
|
|
|
testcase_setup(value, params, last_space_id);
|
2017-04-21 23:41:11 +08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (config::parse_option(argc, argv, narg, "pathname", params.pathname_db))
|
|
|
|
continue;
|
|
|
|
if (config::parse_option(argc, argv, narg, "mode", params.mode_flags,
|
|
|
|
config::mode_bits))
|
|
|
|
continue;
|
2020-07-05 07:25:52 +08:00
|
|
|
if (config::parse_option(argc, argv, narg, "random-writemap",
|
|
|
|
params.random_writemap))
|
|
|
|
continue;
|
2017-04-21 23:41:11 +08:00
|
|
|
if (config::parse_option(argc, argv, narg, "table", params.table_flags,
|
2018-09-16 23:52:32 +08:00
|
|
|
config::table_bits)) {
|
|
|
|
if ((params.table_flags & MDBX_DUPFIXED) == 0)
|
|
|
|
params.table_flags &= ~MDBX_INTEGERDUP;
|
|
|
|
if ((params.table_flags & MDBX_DUPSORT) == 0)
|
|
|
|
params.table_flags &=
|
|
|
|
~(MDBX_DUPFIXED | MDBX_REVERSEDUP | MDBX_INTEGERDUP);
|
2020-10-24 04:21:51 +08:00
|
|
|
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;
|
2017-04-21 23:41:11 +08:00
|
|
|
continue;
|
2018-09-16 23:52:32 +08:00
|
|
|
}
|
2018-08-22 05:55:21 +08:00
|
|
|
|
|
|
|
if (config::parse_option(argc, argv, narg, "pagesize", params.pagesize,
|
2019-09-10 18:41:37 +08:00
|
|
|
int(mdbx_limits_pgsize_min()),
|
|
|
|
int(mdbx_limits_pgsize_max()))) {
|
2018-08-31 22:05:00 +08:00
|
|
|
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 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;
|
2018-08-22 05:55:21 +08:00
|
|
|
continue;
|
2018-08-31 22:05:00 +08:00
|
|
|
}
|
2019-10-31 19:45:21 +08:00
|
|
|
if (config::parse_option(argc, argv, narg, "repeat", params.nrepeat,
|
|
|
|
config::no_scale))
|
|
|
|
continue;
|
|
|
|
if (config::parse_option(argc, argv, narg, "threads", params.nthreads,
|
|
|
|
config::no_scale, 1, 64))
|
|
|
|
continue;
|
|
|
|
|
2019-08-13 07:12:13 +08:00
|
|
|
if (config::parse_option_intptr(argc, argv, narg, "size-lower",
|
|
|
|
params.size_lower,
|
|
|
|
mdbx_limits_dbsize_min(params.pagesize),
|
|
|
|
mdbx_limits_dbsize_max(params.pagesize)))
|
2018-08-22 05:55:21 +08:00
|
|
|
continue;
|
2021-07-12 05:08:34 +08:00
|
|
|
int64_t i64 = params.size_upper;
|
|
|
|
if (config::parse_option(argc, argv, narg, "size-upper-upto", i64,
|
|
|
|
int64_t(mdbx_limits_dbsize_min(params.pagesize)),
|
|
|
|
INT64_MAX, -1)) {
|
|
|
|
if (i64 > mdbx_limits_dbsize_max(params.pagesize))
|
|
|
|
i64 = mdbx_limits_dbsize_max(params.pagesize);
|
|
|
|
params.size_upper = intptr_t(i64);
|
|
|
|
continue;
|
|
|
|
}
|
2019-08-13 07:12:13 +08:00
|
|
|
if (config::parse_option_intptr(argc, argv, narg, "size-upper",
|
|
|
|
params.size_upper,
|
|
|
|
mdbx_limits_dbsize_min(params.pagesize),
|
|
|
|
mdbx_limits_dbsize_max(params.pagesize)))
|
2018-08-22 05:55:21 +08:00
|
|
|
continue;
|
2019-08-13 07:12:13 +08:00
|
|
|
if (config::parse_option_intptr(argc, argv, narg, "size", params.size_now,
|
|
|
|
mdbx_limits_dbsize_min(params.pagesize),
|
|
|
|
mdbx_limits_dbsize_max(params.pagesize)))
|
2018-08-22 05:55:21 +08:00
|
|
|
continue;
|
2018-08-22 12:22:01 +08:00
|
|
|
if (config::parse_option(
|
|
|
|
argc, argv, narg, "shrink-threshold", params.shrink_threshold, 0,
|
|
|
|
(int)std::min((intptr_t)INT_MAX,
|
|
|
|
mdbx_limits_dbsize_max(params.pagesize) -
|
|
|
|
mdbx_limits_dbsize_min(params.pagesize))))
|
2018-08-22 05:55:21 +08:00
|
|
|
continue;
|
2018-08-22 12:22:01 +08:00
|
|
|
if (config::parse_option(
|
|
|
|
argc, argv, narg, "growth-step", params.growth_step, 0,
|
|
|
|
(int)std::min((intptr_t)INT_MAX,
|
|
|
|
mdbx_limits_dbsize_max(params.pagesize) -
|
|
|
|
mdbx_limits_dbsize_min(params.pagesize))))
|
2017-04-21 23:41:11 +08:00
|
|
|
continue;
|
2017-05-18 01:10:56 +08:00
|
|
|
|
|
|
|
if (config::parse_option(argc, argv, narg, "keygen.width",
|
2020-05-26 23:39:36 +08:00
|
|
|
params.keygen.width, 8, 64))
|
2017-05-18 01:10:56 +08:00
|
|
|
continue;
|
|
|
|
if (config::parse_option(argc, argv, narg, "keygen.mesh",
|
2020-05-26 23:39:36 +08:00
|
|
|
params.keygen.mesh, 0, 64))
|
2017-05-18 01:10:56 +08:00
|
|
|
continue;
|
|
|
|
if (config::parse_option(argc, argv, narg, "keygen.seed",
|
|
|
|
params.keygen.seed, config::no_scale))
|
|
|
|
continue;
|
2020-05-25 07:25:24 +08:00
|
|
|
if (config::parse_option(argc, argv, narg, "keygen.zerofill",
|
|
|
|
params.keygen.zero_fill))
|
|
|
|
continue;
|
2017-05-18 01:10:56 +08:00
|
|
|
if (config::parse_option(argc, argv, narg, "keygen.split",
|
2020-05-26 23:39:36 +08:00
|
|
|
params.keygen.split, 0, 63))
|
2017-04-21 23:41:11 +08:00
|
|
|
continue;
|
2017-05-18 01:10:56 +08:00
|
|
|
if (config::parse_option(argc, argv, narg, "keygen.rotate",
|
2020-05-26 23:39:36 +08:00
|
|
|
params.keygen.rotate, 0, 63))
|
2017-05-18 01:10:56 +08:00
|
|
|
continue;
|
|
|
|
if (config::parse_option(argc, argv, narg, "keygen.offset",
|
|
|
|
params.keygen.offset, config::binary))
|
|
|
|
continue;
|
|
|
|
if (config::parse_option(argc, argv, narg, "keygen.case", &value)) {
|
|
|
|
keycase_setup(value, params);
|
|
|
|
continue;
|
|
|
|
}
|
2017-04-21 23:41:11 +08:00
|
|
|
if (config::parse_option(argc, argv, narg, "keylen.min", params.keylen_min,
|
2018-08-31 22:05:00 +08:00
|
|
|
config::no_scale, params.mdbx_keylen_min(),
|
|
|
|
params.mdbx_keylen_max())) {
|
|
|
|
if ((params.table_flags & MDBX_INTEGERKEY) ||
|
|
|
|
params.keylen_max < params.keylen_min)
|
2018-08-12 03:06:26 +08:00
|
|
|
params.keylen_max = params.keylen_min;
|
2017-04-21 23:41:11 +08:00
|
|
|
continue;
|
2018-08-12 03:06:26 +08:00
|
|
|
}
|
2018-08-20 17:30:09 +08:00
|
|
|
if (config::parse_option(argc, argv, narg, "keylen.max", params.keylen_max,
|
2018-08-31 22:05:00 +08:00
|
|
|
config::no_scale, params.mdbx_keylen_min(),
|
|
|
|
params.mdbx_keylen_max())) {
|
|
|
|
if ((params.table_flags & MDBX_INTEGERKEY) ||
|
|
|
|
params.keylen_min > params.keylen_max)
|
2018-08-12 03:06:26 +08:00
|
|
|
params.keylen_min = params.keylen_max;
|
2017-04-21 23:41:11 +08:00
|
|
|
continue;
|
2018-08-12 03:06:26 +08:00
|
|
|
}
|
2021-03-15 19:20:07 +08:00
|
|
|
if (config::parse_option(argc, argv, narg, "keylen", params.keylen_min,
|
|
|
|
config::no_scale, params.mdbx_keylen_min(),
|
|
|
|
params.mdbx_keylen_max())) {
|
|
|
|
params.keylen_max = params.keylen_min;
|
|
|
|
continue;
|
|
|
|
}
|
2017-04-21 23:41:11 +08:00
|
|
|
if (config::parse_option(argc, argv, narg, "datalen.min",
|
2018-08-31 22:05:00 +08:00
|
|
|
params.datalen_min, config::no_scale,
|
|
|
|
params.mdbx_datalen_min(),
|
|
|
|
params.mdbx_datalen_max())) {
|
2020-10-24 04:21:51 +08:00
|
|
|
if ((params.table_flags & (MDBX_INTEGERDUP | MDBX_DUPFIXED)) ||
|
2018-08-31 22:05:00 +08:00
|
|
|
params.datalen_max < params.datalen_min)
|
2018-08-12 03:06:26 +08:00
|
|
|
params.datalen_max = params.datalen_min;
|
2017-04-21 23:41:11 +08:00
|
|
|
continue;
|
2018-08-12 03:06:26 +08:00
|
|
|
}
|
2017-04-21 23:41:11 +08:00
|
|
|
if (config::parse_option(argc, argv, narg, "datalen.max",
|
2018-08-31 22:05:00 +08:00
|
|
|
params.datalen_max, config::no_scale,
|
|
|
|
params.mdbx_datalen_min(),
|
|
|
|
params.mdbx_datalen_max())) {
|
2020-10-24 04:21:51 +08:00
|
|
|
if ((params.table_flags & (MDBX_INTEGERDUP | MDBX_DUPFIXED)) ||
|
2018-08-31 22:05:00 +08:00
|
|
|
params.datalen_min > params.datalen_max)
|
2018-08-12 03:06:26 +08:00
|
|
|
params.datalen_min = params.datalen_max;
|
2017-04-21 23:41:11 +08:00
|
|
|
continue;
|
2018-08-12 03:06:26 +08:00
|
|
|
}
|
2021-03-15 19:20:07 +08:00
|
|
|
if (config::parse_option(argc, argv, narg, "datalen", params.datalen_min,
|
|
|
|
config::no_scale, params.mdbx_datalen_min(),
|
|
|
|
params.mdbx_datalen_max())) {
|
|
|
|
params.datalen_max = params.datalen_min;
|
|
|
|
continue;
|
|
|
|
}
|
2017-04-21 23:41:11 +08:00
|
|
|
if (config::parse_option(argc, argv, narg, "batch.read", params.batch_read,
|
|
|
|
config::no_scale, 1))
|
|
|
|
continue;
|
|
|
|
if (config::parse_option(argc, argv, narg, "batch.write",
|
|
|
|
params.batch_write, config::no_scale, 1))
|
|
|
|
continue;
|
|
|
|
if (config::parse_option(argc, argv, narg, "delay", params.delaystart,
|
|
|
|
config::duration))
|
|
|
|
continue;
|
|
|
|
if (config::parse_option(argc, argv, narg, "wait4ops", params.waitfor_nops,
|
|
|
|
config::decimal))
|
|
|
|
continue;
|
2018-03-19 21:51:44 +08:00
|
|
|
if (config::parse_option(argc, argv, narg, "inject-writefault",
|
|
|
|
params.inject_writefaultn, config::decimal))
|
|
|
|
continue;
|
2017-04-21 23:41:11 +08:00
|
|
|
if (config::parse_option(argc, argv, narg, "drop", params.drop_table))
|
|
|
|
continue;
|
2019-06-23 20:55:13 +08:00
|
|
|
if (config::parse_option(argc, argv, narg, "ignore-dbfull",
|
|
|
|
params.ignore_dbfull))
|
|
|
|
continue;
|
2019-10-09 22:56:59 +08:00
|
|
|
if (config::parse_option(argc, argv, narg, "speculum", params.speculum))
|
|
|
|
continue;
|
2017-04-21 23:41:11 +08:00
|
|
|
if (config::parse_option(argc, argv, narg, "max-readers",
|
|
|
|
params.max_readers, config::no_scale, 1, 255))
|
|
|
|
continue;
|
|
|
|
if (config::parse_option(argc, argv, narg, "max-tables", params.max_tables,
|
|
|
|
config::no_scale, 1, INT16_MAX))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (config::parse_option(argc, argv, narg, "no-delay", nullptr)) {
|
|
|
|
params.delaystart = 0;
|
|
|
|
continue;
|
|
|
|
}
|
2019-10-31 19:45:21 +08:00
|
|
|
if (config::parse_option(argc, argv, narg, "no-wait4ops", nullptr)) {
|
2017-04-21 23:41:11 +08:00
|
|
|
params.waitfor_nops = 0;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (config::parse_option(argc, argv, narg, "duration", params.test_duration,
|
|
|
|
config::duration, 1)) {
|
|
|
|
params.test_nops = 0;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (config::parse_option(argc, argv, narg, "nops", params.test_nops,
|
|
|
|
config::decimal, 1)) {
|
|
|
|
params.test_duration = 0;
|
|
|
|
continue;
|
|
|
|
}
|
2017-05-18 01:10:56 +08:00
|
|
|
if (config::parse_option(argc, argv, narg, "hill", &value, "auto")) {
|
2021-07-13 17:38:58 +08:00
|
|
|
fixup4qemu(params);
|
2017-05-18 01:10:56 +08:00
|
|
|
configure_actor(last_space_id, ac_hill, value, params);
|
2017-04-21 23:41:11 +08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (config::parse_option(argc, argv, narg, "jitter", nullptr)) {
|
2021-07-13 17:38:58 +08:00
|
|
|
fixup4qemu(params);
|
2017-05-18 01:10:56 +08:00
|
|
|
configure_actor(last_space_id, ac_jitter, value, params);
|
2017-04-21 23:41:11 +08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (config::parse_option(argc, argv, narg, "dead.reader", nullptr)) {
|
2021-07-13 17:38:58 +08:00
|
|
|
fixup4qemu(params);
|
2017-05-18 01:10:56 +08:00
|
|
|
configure_actor(last_space_id, ac_deadread, value, params);
|
2017-04-21 23:41:11 +08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (config::parse_option(argc, argv, narg, "dead.writer", nullptr)) {
|
2021-07-13 17:38:58 +08:00
|
|
|
fixup4qemu(params);
|
2017-05-18 01:10:56 +08:00
|
|
|
configure_actor(last_space_id, ac_deadwrite, value, params);
|
2017-04-21 23:41:11 +08:00
|
|
|
continue;
|
2017-03-30 23:54:57 +08:00
|
|
|
}
|
2019-10-31 19:45:21 +08:00
|
|
|
if (config::parse_option(argc, argv, narg, "try", nullptr)) {
|
2021-07-13 17:38:58 +08:00
|
|
|
fixup4qemu(params);
|
2019-10-31 19:45:21 +08:00
|
|
|
configure_actor(last_space_id, ac_try, value, params);
|
|
|
|
continue;
|
|
|
|
}
|
2018-11-04 23:57:36 +08:00
|
|
|
if (config::parse_option(argc, argv, narg, "copy", nullptr)) {
|
2021-07-13 17:38:58 +08:00
|
|
|
fixup4qemu(params);
|
2018-11-04 23:57:36 +08:00
|
|
|
configure_actor(last_space_id, ac_copy, value, params);
|
|
|
|
continue;
|
|
|
|
}
|
2019-02-04 03:37:57 +08:00
|
|
|
if (config::parse_option(argc, argv, narg, "append", nullptr)) {
|
2021-07-13 17:38:58 +08:00
|
|
|
fixup4qemu(params);
|
2019-02-04 03:37:57 +08:00
|
|
|
configure_actor(last_space_id, ac_append, value, params);
|
|
|
|
continue;
|
|
|
|
}
|
2019-06-22 07:00:52 +08:00
|
|
|
if (config::parse_option(argc, argv, narg, "ttl", nullptr)) {
|
2021-07-13 17:38:58 +08:00
|
|
|
fixup4qemu(params);
|
2019-06-22 07:00:52 +08:00
|
|
|
configure_actor(last_space_id, ac_ttl, value, params);
|
|
|
|
continue;
|
|
|
|
}
|
2019-10-10 04:38:44 +08:00
|
|
|
if (config::parse_option(argc, argv, narg, "nested", nullptr)) {
|
2021-07-13 17:38:58 +08:00
|
|
|
fixup4qemu(params);
|
2019-10-10 04:38:44 +08:00
|
|
|
configure_actor(last_space_id, ac_nested, value, params);
|
|
|
|
continue;
|
|
|
|
}
|
2023-11-09 00:58:18 +08:00
|
|
|
#if !defined(_WIN32) && !defined(_WIN64)
|
|
|
|
if (config::parse_option(argc, argv, narg, "fork.reader", nullptr)) {
|
|
|
|
fixup4qemu(params);
|
|
|
|
configure_actor(last_space_id, ac_forkread, value, params);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (config::parse_option(argc, argv, narg, "fork.writer", nullptr)) {
|
|
|
|
fixup4qemu(params);
|
|
|
|
configure_actor(last_space_id, ac_forkwrite, value, params);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
#endif /* Windows */
|
2017-04-21 23:41:11 +08:00
|
|
|
|
2021-07-13 17:38:58 +08:00
|
|
|
if (*argv[narg] != '-') {
|
|
|
|
fixup4qemu(params);
|
2017-05-18 01:10:56 +08:00
|
|
|
testcase_setup(argv[narg], params, last_space_id);
|
2021-07-13 17:38:58 +08:00
|
|
|
} else
|
2019-10-31 19:45:21 +08:00
|
|
|
failure("Unknown option '%s'. Try --help\n", argv[narg]);
|
2017-03-30 23:54:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (global::config::dump_config)
|
2017-04-11 17:55:16 +08:00
|
|
|
config::dump();
|
2017-03-30 23:54:57 +08:00
|
|
|
|
2017-04-21 23:41:11 +08:00
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
|
|
|
|
if (global::actors.empty()) {
|
|
|
|
log_notice("no testcase(s) configured, exiting");
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2017-03-30 23:54:57 +08:00
|
|
|
bool failed = false;
|
2020-09-22 11:51:47 +08:00
|
|
|
global::start_monotonic = chrono::now_monotonic();
|
|
|
|
global::deadline_monotonic.fixedpoint =
|
2017-04-21 23:41:11 +08:00
|
|
|
(global::config::timeout_duration_seconds == 0)
|
|
|
|
? chrono::infinite().fixedpoint
|
2020-09-22 11:51:47 +08:00
|
|
|
: global::start_monotonic.fixedpoint +
|
2017-04-21 23:41:11 +08:00
|
|
|
chrono::from_seconds(global::config::timeout_duration_seconds)
|
|
|
|
.fixedpoint;
|
|
|
|
|
|
|
|
if (global::config::cleanup_before)
|
|
|
|
cleanup();
|
|
|
|
|
|
|
|
if (global::actors.size() == 1) {
|
|
|
|
logging::setup("main");
|
|
|
|
global::singlemode = true;
|
|
|
|
if (!test_execute(global::actors.front()))
|
|
|
|
failed = true;
|
|
|
|
} else {
|
2017-04-11 17:55:16 +08:00
|
|
|
logging::setup("overlord");
|
2017-03-30 23:54:57 +08:00
|
|
|
|
2017-04-21 23:41:11 +08:00
|
|
|
log_trace("=== preparing...");
|
2017-03-30 23:54:57 +08:00
|
|
|
log_trace(">> osal_setup");
|
|
|
|
osal_setup(global::actors);
|
|
|
|
log_trace("<< osal_setup");
|
|
|
|
|
|
|
|
for (auto &a : global::actors) {
|
|
|
|
mdbx_pid_t pid;
|
|
|
|
log_trace(">> actor_start");
|
|
|
|
int rc = osal_actor_start(a, pid);
|
|
|
|
log_trace("<< actor_start");
|
|
|
|
if (rc) {
|
2017-04-23 17:54:37 +08:00
|
|
|
log_trace(">> killall_actors: (%s)", "start failed");
|
2017-03-30 23:54:57 +08:00
|
|
|
osal_killall_actors();
|
|
|
|
log_trace("<< killall_actors");
|
2017-04-21 23:41:11 +08:00
|
|
|
failure("Failed to start actor #%u (%s)\n", a.actor_id,
|
|
|
|
test_strerror(rc));
|
2017-03-30 23:54:57 +08:00
|
|
|
}
|
|
|
|
global::pid2actor[pid] = &a;
|
|
|
|
}
|
|
|
|
|
2017-04-21 23:41:11 +08:00
|
|
|
log_trace("=== ready to start...");
|
2017-03-30 23:54:57 +08:00
|
|
|
atexit(osal_killall_actors);
|
|
|
|
log_trace(">> wait4barrier");
|
|
|
|
osal_wait4barrier();
|
|
|
|
log_trace("<< wait4barrier");
|
|
|
|
|
2017-04-21 23:41:11 +08:00
|
|
|
size_t left = global::actors.size();
|
|
|
|
log_trace("=== polling...");
|
|
|
|
while (left > 0) {
|
|
|
|
unsigned timeout_seconds_left = INT_MAX;
|
2020-09-22 11:51:47 +08:00
|
|
|
chrono::time now_monotonic = chrono::now_monotonic();
|
|
|
|
if (now_monotonic.fixedpoint >= global::deadline_monotonic.fixedpoint)
|
2017-04-21 23:41:11 +08:00
|
|
|
timeout_seconds_left = 0;
|
|
|
|
else {
|
2020-09-22 11:51:47 +08:00
|
|
|
chrono::time left_monotonic;
|
|
|
|
left_monotonic.fixedpoint =
|
|
|
|
global::deadline_monotonic.fixedpoint - now_monotonic.fixedpoint;
|
|
|
|
timeout_seconds_left = left_monotonic.seconds();
|
2017-04-21 23:41:11 +08:00
|
|
|
}
|
2017-03-30 23:54:57 +08:00
|
|
|
|
2017-04-21 23:41:11 +08:00
|
|
|
mdbx_pid_t pid;
|
|
|
|
int rc = osal_actor_poll(pid, timeout_seconds_left);
|
|
|
|
if (rc)
|
|
|
|
failure("Poll error: %s (%d)\n", test_strerror(rc), rc);
|
|
|
|
|
|
|
|
if (pid) {
|
|
|
|
actor_status status = osal_actor_info(pid);
|
|
|
|
actor_config *actor = global::pid2actor.at(pid);
|
|
|
|
if (!actor)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (status > as_running) {
|
2022-10-06 18:52:05 +08:00
|
|
|
log_notice("actor #%u, id %d, pid %ld: %s\n", actor->actor_id,
|
|
|
|
actor->space_id, (long)pid, status2str(status));
|
2017-04-21 23:41:11 +08:00
|
|
|
left -= 1;
|
2017-04-23 17:54:37 +08:00
|
|
|
if (status != as_successful) {
|
|
|
|
if (global::config::failfast && !failed) {
|
|
|
|
log_trace(">> killall_actors: (%s)", "failfast");
|
|
|
|
osal_killall_actors();
|
|
|
|
log_trace("<< killall_actors");
|
|
|
|
}
|
2017-04-21 23:41:11 +08:00
|
|
|
failed = true;
|
2017-04-23 17:54:37 +08:00
|
|
|
}
|
2022-10-06 18:52:05 +08:00
|
|
|
} else {
|
|
|
|
log_verbose("actor #%u, id %d, pid %ld: %s\n", actor->actor_id,
|
|
|
|
actor->space_id, (long)pid, status2str(status));
|
2017-04-21 23:41:11 +08:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (timeout_seconds_left == 0)
|
|
|
|
failure("Timeout\n");
|
2017-03-30 23:54:57 +08:00
|
|
|
}
|
|
|
|
}
|
2017-04-21 23:41:11 +08:00
|
|
|
log_trace("=== done...");
|
2017-03-30 23:54:57 +08:00
|
|
|
}
|
|
|
|
|
2017-04-21 23:41:11 +08:00
|
|
|
log_notice("RESULT: %s\n", failed ? "Failed" : "Successful");
|
2020-05-13 21:40:23 +08:00
|
|
|
if (global::config::cleanup_after) {
|
2017-03-30 23:54:57 +08:00
|
|
|
if (failed)
|
2019-10-02 03:01:45 +08:00
|
|
|
log_verbose("skip cleanup");
|
2017-03-30 23:54:57 +08:00
|
|
|
else
|
|
|
|
cleanup();
|
|
|
|
}
|
2019-10-30 22:12:46 +08:00
|
|
|
|
|
|
|
#if !(defined(_WIN32) || defined(_WIN64))
|
|
|
|
struct rusage spent;
|
2019-11-20 16:16:45 +08:00
|
|
|
if (!getrusage(global::singlemode ? RUSAGE_SELF : RUSAGE_CHILDREN, &spent)) {
|
2019-10-30 22:12:46 +08:00
|
|
|
log_notice("%6s: user %f, system %f", "CPU",
|
|
|
|
spent.ru_utime.tv_sec + spent.ru_utime.tv_usec * 1e-6,
|
|
|
|
spent.ru_stime.tv_sec + spent.ru_stime.tv_usec * 1e-6);
|
|
|
|
#if defined(__linux__) || defined(__gnu_linux__) || defined(__FreeBSD__) || \
|
|
|
|
defined(__NetBSD__) || defined(__OpenBSD__) || defined(__BSD__) || \
|
2019-11-07 04:53:53 +08:00
|
|
|
defined(__bsdi__) || defined(__DragonFly__) || defined(__APPLE__) || \
|
2019-11-09 15:50:43 +08:00
|
|
|
defined(__MACH__) || defined(__sun)
|
2019-10-30 22:12:46 +08:00
|
|
|
log_notice("%6s: read %ld, write %ld", "IOPs", spent.ru_inblock,
|
|
|
|
spent.ru_oublock);
|
2019-11-09 15:50:43 +08:00
|
|
|
if (spent.ru_maxrss > 0)
|
|
|
|
log_notice("%6s: %ld Kb", "RAM",
|
|
|
|
spent.ru_maxrss
|
|
|
|
#if defined(__sun)
|
|
|
|
* getpagesize() / 1024u
|
|
|
|
#elif defined(__APPLE__)
|
|
|
|
/ 1024u
|
|
|
|
#endif
|
|
|
|
);
|
2019-10-30 22:12:46 +08:00
|
|
|
log_notice("%6s: reclaims %ld, faults %ld, swaps %ld", "Paging",
|
|
|
|
spent.ru_minflt, spent.ru_majflt, spent.ru_nswap);
|
|
|
|
#endif /* Linux */
|
|
|
|
}
|
|
|
|
#endif /* !Windows */
|
|
|
|
|
2017-03-30 23:54:57 +08:00
|
|
|
return failed ? EXIT_FAILURE : EXIT_SUCCESS;
|
|
|
|
}
|