summaryrefslogtreecommitdiff
path: root/libs/libmdbx/src/test
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2020-07-08 17:05:52 +0300
committerGeorge Hazan <ghazan@miranda.im>2020-07-08 17:05:52 +0300
commitf365c11384642f6674ff5019ff97eda6f89ba378 (patch)
treecd5940e703567e2d0dcc5f20d8a6d9afee6bfbe8 /libs/libmdbx/src/test
parente5ee9bdc7089073f7b3fe6bfdb1cec594e912ca8 (diff)
fixes #2475 (Update libmdbx to 0.8.2)
Diffstat (limited to 'libs/libmdbx/src/test')
-rw-r--r--libs/libmdbx/src/test/CMakeLists.txt32
-rw-r--r--libs/libmdbx/src/test/config.cc2
-rw-r--r--libs/libmdbx/src/test/config.h7
-rw-r--r--libs/libmdbx/src/test/long_stochastic.sh8
-rw-r--r--libs/libmdbx/src/test/main.cc5
-rw-r--r--libs/libmdbx/src/test/osal-unix.cc12
-rw-r--r--libs/libmdbx/src/test/test.cc8
-rw-r--r--libs/libmdbx/src/test/test.h3
8 files changed, 61 insertions, 16 deletions
diff --git a/libs/libmdbx/src/test/CMakeLists.txt b/libs/libmdbx/src/test/CMakeLists.txt
index 2014cb57fa..3e0a929b76 100644
--- a/libs/libmdbx/src/test/CMakeLists.txt
+++ b/libs/libmdbx/src/test/CMakeLists.txt
@@ -27,9 +27,37 @@ add_executable(mdbx_test
nested.cc
)
+list(FIND CMAKE_CXX_COMPILE_FEATURES cxx_std_20 HAS_CXX20)
+list(FIND CMAKE_CXX_COMPILE_FEATURES cxx_std_17 HAS_CXX17)
+list(FIND CMAKE_CXX_COMPILE_FEATURES cxx_std_14 HAS_CXX14)
+list(FIND CMAKE_CXX_COMPILE_FEATURES cxx_std_11 HAS_CXX11)
+if(NOT DEFINED MDBX_CXX_STANDARD)
+ if(DEFINED CMAKE_CXX_STANDARD)
+ set(MDBX_CXX_STANDARD ${CMAKE_CXX_STANDARD})
+ elseif(NOT HAS_CXX20 LESS 0)
+ set(MDBX_CXX_STANDARD 20)
+ elseif(NOT HAS_CXX17 LESS 0)
+ set(MDBX_CXX_STANDARD 17)
+ elseif(NOT HAS_CXX14 LESS 0)
+ set(MDBX_CXX_STANDARD 14)
+ elseif(NOT HAS_CXX11 LESS 0)
+ set(MDBX_CXX_STANDARD 11)
+ endif()
+endif()
+if(MDBX_CXX_STANDARD)
+ message(STATUS "Use C++${MDBX_CXX_STANDARD} for libmdbx")
+ if(NOT SUBPROJECT OR NOT DEFINED CMAKE_CXX_STANDARD)
+ set(CMAKE_CXX_STANDARD ${MDBX_CXX_STANDARD})
+ endif()
+endif()
+
+if(MDBX_CXX_STANDARD)
+ set_target_properties(mdbx_test PROPERTIES
+ CXX_STANDARD ${MDBX_CXX_STANDARD} CXX_STANDARD_REQUIRED ON)
+endif()
+
set_target_properties(mdbx_test PROPERTIES
- INTERPROCEDURAL_OPTIMIZATION $<BOOL:${INTERPROCEDURAL_OPTIMIZATION}>
- CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON)
+ INTERPROCEDURAL_OPTIMIZATION $<BOOL:${INTERPROCEDURAL_OPTIMIZATION}>)
target_setup_options(mdbx_test)
target_link_libraries(mdbx_test ${TOOL_MDBX_LIB} ${LIB_MATH} ${CMAKE_THREAD_LIBS_INIT})
diff --git a/libs/libmdbx/src/test/config.cc b/libs/libmdbx/src/test/config.cc
index 5e1979718a..f8e6866f94 100644
--- a/libs/libmdbx/src/test/config.cc
+++ b/libs/libmdbx/src/test/config.cc
@@ -373,6 +373,8 @@ void dump(const char *title) {
i->params.pagesize);
dump_verbs("mode", i->params.mode_flags, mode_bits);
+ log_verbose("random-writemap: %s\n",
+ i->params.random_writemap ? "Yes" : "No");
dump_verbs("table", i->params.table_flags, table_bits);
if (i->params.test_nops)
diff --git a/libs/libmdbx/src/test/config.h b/libs/libmdbx/src/test/config.h
index 2ab4742a2e..5f0331291b 100644
--- a/libs/libmdbx/src/test/config.h
+++ b/libs/libmdbx/src/test/config.h
@@ -265,9 +265,10 @@ struct actor_params_pod {
keygen_params_pod keygen;
uint8_t loglevel{0};
- bool drop_table{0};
- bool ignore_dbfull{0};
- bool speculum{0};
+ bool drop_table{false};
+ bool ignore_dbfull{false};
+ bool speculum{false};
+ bool random_writemap{true};
};
struct actor_config_pod {
diff --git a/libs/libmdbx/src/test/long_stochastic.sh b/libs/libmdbx/src/test/long_stochastic.sh
index 7141ee62c5..45d1247af7 100644
--- a/libs/libmdbx/src/test/long_stochastic.sh
+++ b/libs/libmdbx/src/test/long_stochastic.sh
@@ -1,12 +1,12 @@
#!/usr/bin/env bash
-if ! which make cc c++ tee lz4 banner >/dev/null; then
+if ! which make cc c++ tee lz4 >/dev/null; then
echo "Please install the following prerequisites: make cc c++ tee lz4 banner" >&2
exit 1
fi
-set -euo pipefail
-
+BANNER="$(which banner 2>/dev/null | echo echo)"
UNAME="$(uname -s 2>/dev/null || echo Unknown)"
+set -euo pipefail
## NOTE: Valgrind could produce some false-positive warnings
## in multi-process environment with shared memory.
@@ -193,7 +193,7 @@ for nops in 10 100 1000 10000 100000 1000000 10000000 100000000 1000000000; do
speculum=$([ $nops -le 1000 ] && echo '--speculum' || true)
while true; do
echo "======================================================================="
- banner "$nops / $wbatch"
+ ${BANNER} "$nops / $wbatch"
subcase=0
for ((bits=2**${#options[@]}; --bits >= 0; )); do
seed=$(($(date +%s) + RANDOM))
diff --git a/libs/libmdbx/src/test/main.cc b/libs/libmdbx/src/test/main.cc
index c6b15ea29b..10016ab3d5 100644
--- a/libs/libmdbx/src/test/main.cc
+++ b/libs/libmdbx/src/test/main.cc
@@ -101,6 +101,7 @@ void __noreturn usage(void) {
" notls == MDBX_NOTLS\n"
" nordahead == MDBX_NORDAHEAD\n"
" nomeminit == MDBX_NOMEMINIT\n"
+ " --random-writemap[=YES|no] Toggle MDBX_WRITEMAP randomly\n"
"Key-value space/table options:\n"
" --table={[+-]FLAG}[,[+-]FLAG]...\n"
" key.reverse == MDBX_REVERSEKEY\n"
@@ -165,6 +166,7 @@ void actor_params::set_defaults(const std::string &tmpdir) {
drop_table = false;
ignore_dbfull = false;
speculum = false;
+ random_writemap = true;
max_readers = 42;
max_tables = 42;
@@ -259,6 +261,9 @@ int main(int argc, char *const argv[]) {
if (config::parse_option(argc, argv, narg, "mode", params.mode_flags,
config::mode_bits))
continue;
+ if (config::parse_option(argc, argv, narg, "random-writemap",
+ params.random_writemap))
+ continue;
if (config::parse_option(argc, argv, narg, "table", params.table_flags,
config::table_bits)) {
if ((params.table_flags & MDBX_DUPFIXED) == 0)
diff --git a/libs/libmdbx/src/test/osal-unix.cc b/libs/libmdbx/src/test/osal-unix.cc
index 757c8583c0..a85ce32a11 100644
--- a/libs/libmdbx/src/test/osal-unix.cc
+++ b/libs/libmdbx/src/test/osal-unix.cc
@@ -23,6 +23,8 @@
#include <sys/wait.h>
#include <unistd.h>
+#include <atomic>
+
#ifndef MDBX_LOCKING
#error "Opps, MDBX_LOCKING is undefined!"
#endif
@@ -307,14 +309,14 @@ bool actor_config::osal_deserialize(const char *str, const char *end,
static pid_t overlord_pid;
-static volatile sig_atomic_t sigusr1_head, sigusr2_head;
+static std::atomic<int> sigusr1_head, sigusr2_head;
static void handler_SIGUSR(int signum) {
switch (signum) {
case SIGUSR1:
- sigusr1_head += 1;
+ ++sigusr1_head;
return;
case SIGUSR2:
- sigusr2_head += 1;
+ ++sigusr2_head;
return;
default:
abort();
@@ -335,10 +337,10 @@ bool osal_progress_push(bool active) {
static std::unordered_map<pid_t, actor_status> childs;
-static volatile sig_atomic_t sigalarm_head;
+static std::atomic<int> sigalarm_head;
static void handler_SIGCHLD(int signum) {
if (signum == SIGALRM)
- sigalarm_head += 1;
+ ++sigalarm_head;
}
mdbx_pid_t osal_getpid(void) { return getpid(); }
diff --git a/libs/libmdbx/src/test/test.cc b/libs/libmdbx/src/test/test.cc
index beeba7abab..9af04ac9b0 100644
--- a/libs/libmdbx/src/test/test.cc
+++ b/libs/libmdbx/src/test/test.cc
@@ -144,8 +144,14 @@ void testcase::db_open() {
db_prepare();
jitter_delay(true);
+
+ unsigned mode = (unsigned)config.params.mode_flags;
+ if (config.params.random_writemap && flipcoin())
+ mode ^= MDBX_WRITEMAP;
+
+ actual_db_mode = mode;
int rc = mdbx_env_open(db_guard.get(), config.params.pathname_db.c_str(),
- (unsigned)config.params.mode_flags, 0640);
+ mode, 0640);
if (unlikely(rc != MDBX_SUCCESS))
failure_perror("mdbx_env_open()", rc);
diff --git a/libs/libmdbx/src/test/test.h b/libs/libmdbx/src/test/test.h
index 8ecf5c46fe..43c6c03848 100644
--- a/libs/libmdbx/src/test/test.h
+++ b/libs/libmdbx/src/test/test.h
@@ -169,8 +169,9 @@ protected:
static int oom_callback(MDBX_env *env, mdbx_pid_t pid, mdbx_tid_t tid,
uint64_t txn, unsigned gap, size_t space, int retry);
+ unsigned actual_db_mode{0};
bool is_nested_txn_available() const {
- return (config.params.mode_flags & MDBX_WRITEMAP) == 0;
+ return (actual_db_mode & MDBX_WRITEMAP) == 0;
}
void kick_progress(bool active) const;
void db_prepare();