mdbx-testing: унификация extra-тестов и интеграция в ctest.

This commit is contained in:
Леонид Юрьев (Leonid Yuriev) 2024-09-18 08:01:14 +03:00
parent 0178d5b5c8
commit 54dfc1f16d
7 changed files with 36 additions and 38 deletions

View File

@ -75,19 +75,20 @@ if(WIN32)
target_link_libraries(mdbx_test winmm.lib) target_link_libraries(mdbx_test winmm.lib)
endif() endif()
if(UNIX AND NOT SUBPROJECT) if(NOT SUBPROJECT)
add_executable(test_extra_pcrf extra/pcrf/pcrf_test.c) if(UNIX)
target_include_directories(test_extra_pcrf PRIVATE "${PROJECT_SOURCE_DIR}") add_executable(test_extra_pcrf extra/pcrf/pcrf_test.c)
target_link_libraries(test_extra_pcrf ${TOOL_MDBX_LIB}) target_include_directories(test_extra_pcrf PRIVATE "${PROJECT_SOURCE_DIR}")
target_link_libraries(test_extra_pcrf ${TOOL_MDBX_LIB})
add_executable(test_extra_upsert_alldups extra/upsert_alldups.c) add_executable(test_extra_upsert_alldups extra/upsert_alldups.c)
target_include_directories(test_extra_upsert_alldups PRIVATE "${PROJECT_SOURCE_DIR}") target_include_directories(test_extra_upsert_alldups PRIVATE "${PROJECT_SOURCE_DIR}")
target_link_libraries(test_extra_upsert_alldups ${TOOL_MDBX_LIB}) target_link_libraries(test_extra_upsert_alldups ${TOOL_MDBX_LIB})
add_executable(test_extra_dupfix_addodd extra/dupfix_addodd.c)
target_include_directories(test_extra_dupfix_addodd PRIVATE "${PROJECT_SOURCE_DIR}")
target_link_libraries(test_extra_dupfix_addodd ${TOOL_MDBX_LIB})
add_executable(test_extra_dupfix_addodd extra/dupfix_addodd.c)
target_include_directories(test_extra_dupfix_addodd PRIVATE "${PROJECT_SOURCE_DIR}")
target_link_libraries(test_extra_dupfix_addodd ${TOOL_MDBX_LIB})
endif()
if(MDBX_BUILD_CXX) if(MDBX_BUILD_CXX)
add_executable(test_extra_maindb_ordinal extra/maindb_ordinal.c++) add_executable(test_extra_maindb_ordinal extra/maindb_ordinal.c++)
target_include_directories(test_extra_maindb_ordinal PRIVATE "${PROJECT_SOURCE_DIR}") target_include_directories(test_extra_maindb_ordinal PRIVATE "${PROJECT_SOURCE_DIR}")
@ -210,10 +211,12 @@ else()
REQUIRED_FILES uniq_nested.db-copy) REQUIRED_FILES uniq_nested.db-copy)
endif() endif()
if(UNIX AND NOT SUBPROJECT) if(NOT SUBPROJECT)
add_test(NAME extra_upsert_alldups COMMAND test_extra_upsert_alldups) if(UNIX)
add_test(NAME extra_dupfix_addodd COMMAND test_extra_dupfix_addodd) add_test(NAME extra_upsert_alldups COMMAND test_extra_upsert_alldups)
if(MDBX_BUILD_CXX) add_test(NAME extra_dupfix_addodd COMMAND test_extra_dupfix_addodd)
endif()
if(MDBX_BUILD_CXX AND NOT (WIN32 AND MDBX_BUILD_SHARED_LIBRARY))
add_test(NAME extra_maindb_ordinal COMMAND test_extra_maindb_ordinal) add_test(NAME extra_maindb_ordinal COMMAND test_extra_maindb_ordinal)
add_test(NAME extra_dupfix_multiple COMMAND test_extra_dupfix_multiple) add_test(NAME extra_dupfix_multiple COMMAND test_extra_dupfix_multiple)
add_test(NAME extra_hex_base64_base58 COMMAND test_extra_hex_base64_base58) add_test(NAME extra_hex_base64_base58 COMMAND test_extra_hex_base64_base58)
@ -222,6 +225,7 @@ else()
set_tests_properties(extra_doubtless_positioning PROPERTIES TIMEOUT 10800) set_tests_properties(extra_doubtless_positioning PROPERTIES TIMEOUT 10800)
endif() endif()
add_test(NAME extra_crunched_delete COMMAND test_extra_crunched_delete) add_test(NAME extra_crunched_delete COMMAND test_extra_crunched_delete)
add_test(NAME extra_dbi COMMAND test_extra_dbi)
endif() endif()
endif() endif()

View File

@ -377,8 +377,8 @@ int main(int argc, const char *argv[]) {
mdbx_setup_debug_nofmt(MDBX_LOG_NOTICE, MDBX_DBG_ASSERT, logger_nofmt, mdbx_setup_debug_nofmt(MDBX_LOG_NOTICE, MDBX_DBG_ASSERT, logger_nofmt,
log_buffer, sizeof(log_buffer)); log_buffer, sizeof(log_buffer));
const char *filename = "test-crunched-del"; mdbx::path db_filename = "test-crunched-del";
mdbx::env::remove(filename); mdbx::env::remove(db_filename);
std::vector<acase> testset; std::vector<acase> testset;
// Там ключи разной длины - от 1 до 64 байт. // Там ключи разной длины - от 1 до 64 байт.
@ -394,7 +394,7 @@ int main(int argc, const char *argv[]) {
testset.emplace_back(8, 8, 1, 5, 10); testset.emplace_back(8, 8, 1, 5, 10);
testset.emplace_back(8, 8, 32, 36, 9); testset.emplace_back(8, 8, 32, 36, 9);
mdbx::env_managed env(filename, mdbx::env_managed::create_parameters(), mdbx::env_managed env(db_filename, mdbx::env_managed::create_parameters(),
mdbx::env::operate_parameters(42)); mdbx::env::operate_parameters(42));
if (!simple(env) || !next_prev_current(env) || !outofrange_prev(env)) if (!simple(env) || !next_prev_current(env) || !outofrange_prev(env))
return EXIT_FAILURE; return EXIT_FAILURE;

View File

@ -18,19 +18,19 @@ int main(int argc, const char *argv[]) {
mdbx_setup_debug_nofmt(MDBX_LOG_NOTICE, MDBX_DBG_ASSERT, logger_nofmt, mdbx_setup_debug_nofmt(MDBX_LOG_NOTICE, MDBX_DBG_ASSERT, logger_nofmt,
log_buffer, sizeof(log_buffer)); log_buffer, sizeof(log_buffer));
mdbx::path path = "test-dbi"; mdbx::path db_filename = "test-dbi";
mdbx::env::remove(path); mdbx::env::remove(db_filename);
mdbx::env::operate_parameters operateParameters(100, 10); mdbx::env::operate_parameters operateParameters(100, 10);
mdbx::env_managed::create_parameters createParameters; mdbx::env_managed::create_parameters createParameters;
{ {
mdbx::env_managed env2(path, createParameters, operateParameters); mdbx::env_managed env2(db_filename, createParameters, operateParameters);
mdbx::txn_managed txn2 = env2.start_write(false); mdbx::txn_managed txn2 = env2.start_write(false);
/* mdbx::map_handle testHandle2 = */ txn2.create_map( /* mdbx::map_handle testHandle2 = */ txn2.create_map(
"fap1", mdbx::key_mode::reverse, mdbx::value_mode::single); "fap1", mdbx::key_mode::reverse, mdbx::value_mode::single);
txn2.commit(); txn2.commit();
} }
mdbx::env_managed env(path, createParameters, operateParameters); mdbx::env_managed env(db_filename, createParameters, operateParameters);
mdbx::txn_managed txn = env.start_write(false); mdbx::txn_managed txn = env.start_write(false);
/* mdbx::map_handle testHandle = */ txn.create_map( /* mdbx::map_handle testHandle = */ txn.create_map(
"fap1", mdbx::key_mode::usual, mdbx::value_mode::single); "fap1", mdbx::key_mode::usual, mdbx::value_mode::single);

View File

@ -6,7 +6,6 @@
#include <functional> #include <functional>
#include <iostream> #include <iostream>
#include <random> #include <random>
#include <unistd.h>
static ::std::ostream &operator<<(::std::ostream &out, static ::std::ostream &operator<<(::std::ostream &out,
const mdbx::cursor::move_operation op) { const mdbx::cursor::move_operation op) {
@ -233,9 +232,9 @@ int main(int argc, const char *argv[]) {
(void)argc; (void)argc;
(void)argv; (void)argv;
unlink("." MDBX_DATANAME); mdbx::path db_filename = "test-posi";
unlink("." MDBX_LOCKNAME); mdbx::env_managed::remove(db_filename);
mdbx::env_managed env(".", mdbx::env_managed::create_parameters(), mdbx::env_managed env(db_filename, mdbx::env_managed::create_parameters(),
mdbx::env::operate_parameters(3)); mdbx::env::operate_parameters(3));
auto txn = env.start_write(); auto txn = env.start_write();

View File

@ -4,16 +4,14 @@
#include "mdbx.h++" #include "mdbx.h++"
#include <array> #include <array>
#include <iostream> #include <iostream>
#include <unistd.h>
int main(int argc, const char *argv[]) { int main(int argc, const char *argv[]) {
(void)argc; (void)argc;
(void)argv; (void)argv;
unlink("." MDBX_DATANAME); mdbx::path db_filename = "test-dupfix-multiple";
unlink("." MDBX_LOCKNAME); mdbx::env_managed::remove(db_filename);
mdbx::env_managed env(db_filename, mdbx::env_managed::create_parameters(),
mdbx::env_managed env(".", mdbx::env_managed::create_parameters(),
mdbx::env::operate_parameters()); mdbx::env::operate_parameters());
using buffer = using buffer =

View File

@ -4,7 +4,6 @@
#include "mdbx.h++" #include "mdbx.h++"
#include <array> #include <array>
#include <iostream> #include <iostream>
#include <unistd.h>
#include <functional> #include <functional>
#include <random> #include <random>

View File

@ -3,16 +3,14 @@
#include "mdbx.h++" #include "mdbx.h++"
#include <iostream> #include <iostream>
#include <unistd.h>
int main(int argc, const char *argv[]) { int main(int argc, const char *argv[]) {
(void)argc; (void)argc;
(void)argv; (void)argv;
unlink("." MDBX_DATANAME); mdbx::path db_filename = "test-dupfix-multiple";
unlink("." MDBX_LOCKNAME); mdbx::env_managed::remove(db_filename);
mdbx::env_managed env(db_filename, mdbx::env_managed::create_parameters(),
mdbx::env_managed env(".", mdbx::env_managed::create_parameters(),
mdbx::env::operate_parameters()); mdbx::env::operate_parameters());
using buffer = using buffer =
@ -23,7 +21,7 @@ int main(int argc, const char *argv[]) {
#if 0 /* workaround */ #if 0 /* workaround */
txn.commit(); txn.commit();
env.close(); env.close();
env = mdbx::env_managed(".", mdbx::env_managed::create_parameters(), env = mdbx::env_managed(db_filename, mdbx::env_managed::create_parameters(),
mdbx::env::operate_parameters()); mdbx::env::operate_parameters());
txn = env.start_write(); txn = env.start_write();
#endif #endif