From 222150bb289d1aebeac36ff6a3d28c076b0ae29b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9B=D0=B5=D0=BE=D0=BD=D0=B8=D0=B4=20=D0=AE=D1=80=D1=8C?= =?UTF-8?q?=D0=B5=D0=B2=20=28Leonid=20Yuriev=29?= Date: Sun, 29 Sep 2024 20:09:53 +0300 Subject: [PATCH] =?UTF-8?q?mdbx-testing:=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D1=82=D0=B5=D1=81=D1=82=D0=B0?= =?UTF-8?q?=20=D0=BF=D0=B5=D1=80=D0=B5=D1=81=D0=BE=D0=B7=D0=B4=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D1=8F=20=D1=82=D0=B0=D0=B1=D0=BB=D0=B8=D1=86=D1=8B=20?= =?UTF-8?q?=D1=81=20=D0=B4=D1=80=D1=83=D0=B3=D0=B8=D0=BC=D0=B8=20=D1=84?= =?UTF-8?q?=D0=BB=D0=B0=D0=B3=D0=B0=D0=BC=D0=B8/=D0=BE=D0=BF=D1=86=D0=B8?= =?UTF-8?q?=D1=8F=D0=BC=D0=B8=20(backport).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/CMakeLists.txt | 8 ++++++++ test/extra/dbi.c++ | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 test/extra/dbi.c++ diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 4cef005c..5da6a391 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -91,6 +91,13 @@ if(UNIX AND NOT SUBPROJECT) set_target_properties(test_extra_dupfixed_multiple PROPERTIES CXX_STANDARD ${MDBX_CXX_STANDARD} CXX_STANDARD_REQUIRED ON) endif() + add_executable(test_extra_dbi extra/dbi.c++) + target_include_directories(test_extra_dbi PRIVATE "${PROJECT_SOURCE_DIR}") + target_link_libraries(test_extra_dbi ${TOOL_MDBX_LIB}) + if(MDBX_CXX_STANDARD) + set_target_properties(test_extra_dbi PROPERTIES + CXX_STANDARD ${MDBX_CXX_STANDARD} CXX_STANDARD_REQUIRED ON) + endif() endif() endif() @@ -176,6 +183,7 @@ else() if(MDBX_BUILD_CXX) add_test(NAME extra_maindb_ordinal COMMAND test_extra_maindb_ordinal) add_test(NAME extra_dupfixed_multiple COMMAND test_extra_dupfixed_multiple) + add_test(NAME extra_dbi COMMAND test_extra_dbi) endif() endif() diff --git a/test/extra/dbi.c++ b/test/extra/dbi.c++ new file mode 100644 index 00000000..e61803ec --- /dev/null +++ b/test/extra/dbi.c++ @@ -0,0 +1,38 @@ +#include "mdbx.h++" + +#include + +static void logger(MDBX_log_level_t loglevel, const char *function, int line, + const char *fmt, va_list args) noexcept { + (void)loglevel; + fprintf(stdout, "%s:%u ", function, line); + vfprintf(stdout, fmt, args); +} + +int main(int argc, const char *argv[]) { + (void)argc; + (void)argv; + + mdbx_setup_debug(MDBX_LOG_NOTICE, MDBX_DBG_ASSERT, logger); + + mdbx::path path = "test-dbi"; + mdbx::env::remove(path); + + mdbx::env::operate_parameters operateParameters(100, 10); + mdbx::env_managed::create_parameters createParameters; + { + mdbx::env_managed env2(path, createParameters, operateParameters); + mdbx::txn_managed txn2 = env2.start_write(false); + /* mdbx::map_handle testHandle2 = */ txn2.create_map( + "fap1", mdbx::key_mode::reverse, mdbx::value_mode::single); + txn2.commit(); + } + mdbx::env_managed env(path, createParameters, operateParameters); + mdbx::txn_managed txn = env.start_write(false); + /* mdbx::map_handle testHandle = */ txn.create_map( + "fap1", mdbx::key_mode::usual, mdbx::value_mode::single); + txn.commit(); + + std::cout << "OK\n"; + return EXIT_SUCCESS; +}