2024-05-20 03:07:58 +08:00
|
|
|
## Copyright (c) 2020-2024 Леонид Юрьев aka Leonid Yuriev <leo@yuriev.ru>
|
|
|
|
## SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
2020-09-27 21:49:55 +08:00
|
|
|
enable_language(CXX)
|
|
|
|
include(../cmake/compiler.cmake)
|
|
|
|
|
2021-04-19 22:44:04 +08:00
|
|
|
set(LIBMDBX_TEST_SOURCES
|
2022-11-08 21:17:14 +08:00
|
|
|
base.h++
|
|
|
|
cases.c++
|
|
|
|
chrono.c++
|
|
|
|
chrono.h++
|
|
|
|
config.c++
|
|
|
|
config.h++
|
|
|
|
copy.c++
|
|
|
|
dead.c++
|
|
|
|
hill.c++
|
|
|
|
jitter.c++
|
|
|
|
keygen.c++
|
|
|
|
keygen.h++
|
|
|
|
log.c++
|
|
|
|
log.h++
|
|
|
|
main.c++
|
|
|
|
osal.h++
|
|
|
|
osal-unix.c++
|
|
|
|
osal-windows.c++
|
|
|
|
test.c++
|
|
|
|
test.h++
|
|
|
|
try.c++
|
|
|
|
utils.c++
|
|
|
|
utils.h++
|
|
|
|
append.c++
|
|
|
|
ttl.c++
|
|
|
|
nested.c++
|
2023-11-09 00:58:18 +08:00
|
|
|
fork.c++
|
2018-11-04 23:57:36 +08:00
|
|
|
)
|
2018-01-04 14:27:09 +08:00
|
|
|
|
2021-04-19 22:44:04 +08:00
|
|
|
if(NOT MDBX_BUILD_CXX)
|
2022-04-08 02:57:49 +08:00
|
|
|
probe_libcxx_filesystem()
|
2021-04-19 22:44:04 +08:00
|
|
|
list(APPEND LIBMDBX_TEST_SOURCES "${MDBX_SOURCE_DIR}/mdbx.c++" ../mdbx.h++)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
add_executable(mdbx_test ${LIBMDBX_TEST_SOURCES})
|
2024-05-20 03:07:58 +08:00
|
|
|
target_compile_definitions(mdbx_test PRIVATE MDBX_BUILD_TEST=1 MDBX_BUILD_CXX=1)
|
2021-04-19 22:44:04 +08:00
|
|
|
|
2020-06-26 07:57:46 +08:00
|
|
|
if(MDBX_CXX_STANDARD)
|
|
|
|
set_target_properties(mdbx_test PROPERTIES
|
|
|
|
CXX_STANDARD ${MDBX_CXX_STANDARD} CXX_STANDARD_REQUIRED ON)
|
|
|
|
endif()
|
|
|
|
|
2019-08-31 22:13:02 +08:00
|
|
|
set_target_properties(mdbx_test PROPERTIES
|
2020-06-26 07:57:46 +08:00
|
|
|
INTERPROCEDURAL_OPTIMIZATION $<BOOL:${INTERPROCEDURAL_OPTIMIZATION}>)
|
2020-04-15 22:09:37 +08:00
|
|
|
target_setup_options(mdbx_test)
|
2018-01-04 14:27:09 +08:00
|
|
|
|
2024-05-20 03:07:58 +08:00
|
|
|
if(NOT MDBX_BUILD_CXX)
|
|
|
|
target_compile_definitions(mdbx_test PRIVATE MDBX_BUILD_CXX=1)
|
2024-09-18 12:59:24 +08:00
|
|
|
if(WIN32)
|
2024-05-20 03:07:58 +08:00
|
|
|
target_compile_definitions(mdbx_test PRIVATE MDBX_WITHOUT_MSVC_CRT=0)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2022-04-05 22:02:39 +08:00
|
|
|
if(NOT MDBX_BUILD_CXX AND LIBCXX_FILESYSTEM)
|
2022-04-23 04:03:58 +08:00
|
|
|
if(CMAKE_COMPILER_IS_ELBRUSCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 1.25.23
|
2022-04-05 23:34:37 +08:00
|
|
|
AND NOT CMAKE_VERSION VERSION_LESS 3.13)
|
|
|
|
target_link_options(mdbx_test PRIVATE "-Wl,--allow-multiple-definition")
|
|
|
|
endif()
|
2022-04-05 22:02:39 +08:00
|
|
|
target_link_libraries(mdbx_test ${LIBCXX_FILESYSTEM})
|
|
|
|
endif()
|
|
|
|
|
2022-11-08 04:37:27 +08:00
|
|
|
if(CMAKE_VERSION VERSION_LESS 3.1)
|
|
|
|
target_link_libraries(mdbx_test ${TOOL_MDBX_LIB} ${LIB_MATH} ${CMAKE_THREAD_LIBS_INIT})
|
|
|
|
else()
|
|
|
|
target_link_libraries(mdbx_test ${TOOL_MDBX_LIB} ${LIB_MATH} Threads::Threads)
|
|
|
|
endif()
|
2024-09-18 12:59:24 +08:00
|
|
|
if(WIN32)
|
2019-08-31 22:13:02 +08:00
|
|
|
target_link_libraries(mdbx_test winmm.lib)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(UNIX AND NOT SUBPROJECT)
|
2023-03-04 19:39:21 +08:00
|
|
|
add_executable(test_extra_pcrf extra/pcrf/pcrf_test.c)
|
|
|
|
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)
|
|
|
|
target_include_directories(test_extra_upsert_alldups PRIVATE "${PROJECT_SOURCE_DIR}")
|
|
|
|
target_link_libraries(test_extra_upsert_alldups ${TOOL_MDBX_LIB})
|
2023-03-30 18:08:52 +08:00
|
|
|
|
2024-05-20 03:07:58 +08:00
|
|
|
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})
|
2024-02-20 16:20:09 +08:00
|
|
|
|
2023-03-30 18:08:52 +08:00
|
|
|
if(MDBX_BUILD_CXX)
|
|
|
|
add_executable(test_extra_maindb_ordinal extra/maindb_ordinal.c++)
|
|
|
|
target_include_directories(test_extra_maindb_ordinal PRIVATE "${PROJECT_SOURCE_DIR}")
|
|
|
|
target_link_libraries(test_extra_maindb_ordinal ${TOOL_MDBX_LIB})
|
|
|
|
if(MDBX_CXX_STANDARD)
|
|
|
|
set_target_properties(test_extra_maindb_ordinal PROPERTIES
|
|
|
|
CXX_STANDARD ${MDBX_CXX_STANDARD} CXX_STANDARD_REQUIRED ON)
|
|
|
|
endif()
|
2024-05-20 03:07:58 +08:00
|
|
|
add_executable(test_extra_dupfix_multiple extra/dupfix_multiple.c++)
|
|
|
|
target_include_directories(test_extra_dupfix_multiple PRIVATE "${PROJECT_SOURCE_DIR}")
|
|
|
|
target_link_libraries(test_extra_dupfix_multiple ${TOOL_MDBX_LIB})
|
2023-10-07 03:11:21 +08:00
|
|
|
if(MDBX_CXX_STANDARD)
|
2024-05-20 03:07:58 +08:00
|
|
|
set_target_properties(test_extra_dupfix_multiple PROPERTIES
|
2023-10-07 03:11:21 +08:00
|
|
|
CXX_STANDARD ${MDBX_CXX_STANDARD} CXX_STANDARD_REQUIRED ON)
|
|
|
|
endif()
|
2023-11-24 19:11:41 +08:00
|
|
|
add_executable(test_extra_hex_base64_base58 extra/hex_base64_base58.c++)
|
|
|
|
target_include_directories(test_extra_hex_base64_base58 PRIVATE "${PROJECT_SOURCE_DIR}")
|
|
|
|
target_link_libraries(test_extra_hex_base64_base58 ${TOOL_MDBX_LIB})
|
|
|
|
if(MDBX_CXX_STANDARD)
|
|
|
|
set_target_properties(test_extra_hex_base64_base58 PROPERTIES
|
|
|
|
CXX_STANDARD ${MDBX_CXX_STANDARD} CXX_STANDARD_REQUIRED ON)
|
|
|
|
endif()
|
2023-11-16 04:38:31 +08:00
|
|
|
add_executable(test_extra_doubtless_positioning extra/doubtless_positioning.c++)
|
|
|
|
target_include_directories(test_extra_doubtless_positioning PRIVATE "${PROJECT_SOURCE_DIR}")
|
|
|
|
target_link_libraries(test_extra_doubtless_positioning ${TOOL_MDBX_LIB})
|
|
|
|
if(MDBX_CXX_STANDARD)
|
|
|
|
set_target_properties(test_extra_doubtless_positioning PROPERTIES
|
|
|
|
CXX_STANDARD ${MDBX_CXX_STANDARD} CXX_STANDARD_REQUIRED ON)
|
|
|
|
endif()
|
2024-05-26 04:20:34 +08:00
|
|
|
add_executable(test_extra_crunched_delete extra/crunched_delete.c++)
|
|
|
|
target_include_directories(test_extra_crunched_delete PRIVATE "${PROJECT_SOURCE_DIR}")
|
|
|
|
target_link_libraries(test_extra_crunched_delete ${TOOL_MDBX_LIB})
|
|
|
|
if(MDBX_CXX_STANDARD)
|
|
|
|
set_target_properties(test_extra_crunched_delete PROPERTIES
|
|
|
|
CXX_STANDARD ${MDBX_CXX_STANDARD} CXX_STANDARD_REQUIRED ON)
|
|
|
|
endif()
|
2024-08-22 05:04:56 +08:00
|
|
|
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()
|
2023-03-30 18:08:52 +08:00
|
|
|
endif()
|
2019-08-31 22:13:02 +08:00
|
|
|
endif()
|
2022-04-22 00:49:57 +08:00
|
|
|
|
|
|
|
################################################################################
|
|
|
|
|
2022-04-22 01:25:04 +08:00
|
|
|
if (CMAKE_CROSSCOMPILING AND NOT CMAKE_CROSSCOMPILING_EMULATOR)
|
|
|
|
message(WARNING "No emulator to run cross-compiled tests")
|
|
|
|
add_test(NAME fake_since_no_crosscompiling_emulator COMMAND ${CMAKE_COMMAND} -E
|
|
|
|
echo "No emulator to run cross-compiled tests")
|
|
|
|
else()
|
2022-04-22 00:49:57 +08:00
|
|
|
|
2022-04-23 03:07:42 +08:00
|
|
|
string(RANDOM LENGTH 9 ALPHABET "1234567890" test_seed)
|
|
|
|
message(STATUS "The ${test_seed} will be used for seeding tests. Re-run cmake to re-seed it.")
|
|
|
|
|
2022-04-22 01:25:04 +08:00
|
|
|
add_test(NAME smoke COMMAND ${MDBX_OUTPUT_DIR}/mdbx_test
|
2022-04-22 14:32:47 +08:00
|
|
|
--loglevel=verbose
|
2024-03-03 22:38:23 +08:00
|
|
|
--prng-seed=${test_seed}
|
2022-04-22 01:25:04 +08:00
|
|
|
--progress --console=no --pathname=smoke.db --dont-cleanup-after basic)
|
|
|
|
set_tests_properties(smoke PROPERTIES
|
|
|
|
TIMEOUT 600
|
|
|
|
RUN_SERIAL OFF)
|
2022-04-22 23:07:51 +08:00
|
|
|
if(MDBX_BUILD_TOOLS)
|
|
|
|
add_test(NAME smoke_chk COMMAND ${MDBX_OUTPUT_DIR}/mdbx_chk -nvv smoke.db)
|
|
|
|
set_tests_properties(smoke_chk PROPERTIES
|
|
|
|
DEPENDS smoke
|
|
|
|
TIMEOUT 60
|
2023-01-12 06:42:14 +08:00
|
|
|
FAIL_REGULAR_EXPRESSION "cooperative mode"
|
2022-04-22 23:07:51 +08:00
|
|
|
REQUIRED_FILES smoke.db)
|
|
|
|
add_test(NAME smoke_chk_copy COMMAND ${MDBX_OUTPUT_DIR}/mdbx_chk -nvv smoke.db-copy)
|
|
|
|
set_tests_properties(smoke_chk_copy PROPERTIES
|
|
|
|
DEPENDS smoke
|
|
|
|
TIMEOUT 60
|
2023-01-12 06:42:14 +08:00
|
|
|
FAIL_REGULAR_EXPRESSION "cooperative mode"
|
2022-04-22 23:07:51 +08:00
|
|
|
REQUIRED_FILES smoke.db-copy)
|
|
|
|
endif()
|
2022-04-22 00:49:57 +08:00
|
|
|
|
2022-04-22 01:25:04 +08:00
|
|
|
add_test(NAME dupsort_writemap COMMAND ${MDBX_OUTPUT_DIR}/mdbx_test
|
|
|
|
--loglevel=notice
|
2024-03-03 22:38:23 +08:00
|
|
|
--prng-seed=${test_seed}
|
2024-03-06 16:27:22 +08:00
|
|
|
--table=+data.fixed --keygen.split=29 --datalen=rnd --progress --console=no
|
2022-04-22 01:25:04 +08:00
|
|
|
--repeat=2 --pathname=dupsort_writemap.db --dont-cleanup-after basic)
|
|
|
|
set_tests_properties(dupsort_writemap PROPERTIES
|
2023-11-27 18:23:06 +08:00
|
|
|
TIMEOUT 3600
|
2022-04-22 01:25:04 +08:00
|
|
|
RUN_SERIAL OFF)
|
2022-04-22 23:07:51 +08:00
|
|
|
if(MDBX_BUILD_TOOLS)
|
2023-01-12 06:42:14 +08:00
|
|
|
add_test(NAME dupsort_writemap_chk COMMAND ${MDBX_OUTPUT_DIR}/mdbx_chk -nvvwc dupsort_writemap.db)
|
2022-04-22 23:07:51 +08:00
|
|
|
set_tests_properties(dupsort_writemap_chk PROPERTIES
|
|
|
|
DEPENDS dupsort_writemap
|
|
|
|
TIMEOUT 60
|
|
|
|
REQUIRED_FILES dupsort_writemap.db)
|
2023-01-12 06:42:14 +08:00
|
|
|
add_test(NAME dupsort_writemap_chk_copy COMMAND ${MDBX_OUTPUT_DIR}/mdbx_chk -nvvc dupsort_writemap.db-copy)
|
2022-04-22 23:07:51 +08:00
|
|
|
set_tests_properties(dupsort_writemap_chk_copy PROPERTIES
|
|
|
|
DEPENDS dupsort_writemap
|
|
|
|
TIMEOUT 60
|
2023-01-12 06:42:14 +08:00
|
|
|
FAIL_REGULAR_EXPRESSION "monopolistic mode"
|
2022-04-22 23:07:51 +08:00
|
|
|
REQUIRED_FILES dupsort_writemap.db-copy)
|
|
|
|
endif()
|
2022-04-22 01:25:04 +08:00
|
|
|
|
|
|
|
add_test(NAME uniq_nested COMMAND ${MDBX_OUTPUT_DIR}/mdbx_test
|
|
|
|
--loglevel=notice
|
|
|
|
--mode=-writemap,-nosync-safe,-lifo --progress --console=no --repeat=2 --pathname=uniq_nested.db --dont-cleanup-after basic)
|
|
|
|
set_tests_properties(uniq_nested PROPERTIES
|
|
|
|
TIMEOUT 1800
|
|
|
|
RUN_SERIAL OFF)
|
2022-04-22 23:07:51 +08:00
|
|
|
if(MDBX_BUILD_TOOLS)
|
2023-01-12 06:42:14 +08:00
|
|
|
add_test(NAME uniq_nested_chk COMMAND ${MDBX_OUTPUT_DIR}/mdbx_chk -nvvw uniq_nested.db)
|
2022-04-22 23:07:51 +08:00
|
|
|
set_tests_properties(uniq_nested_chk PROPERTIES
|
|
|
|
DEPENDS uniq_nested
|
|
|
|
TIMEOUT 60
|
2023-01-12 06:42:14 +08:00
|
|
|
FAIL_REGULAR_EXPRESSION "cooperative mode"
|
2022-04-22 23:07:51 +08:00
|
|
|
REQUIRED_FILES uniq_nested.db)
|
|
|
|
add_test(NAME uniq_nested_chk_copy COMMAND ${MDBX_OUTPUT_DIR}/mdbx_chk -nvv uniq_nested.db-copy)
|
|
|
|
set_tests_properties(uniq_nested_chk_copy PROPERTIES
|
|
|
|
DEPENDS uniq_nested
|
|
|
|
TIMEOUT 60
|
2023-01-12 06:42:14 +08:00
|
|
|
FAIL_REGULAR_EXPRESSION "cooperative mode"
|
2022-04-22 23:07:51 +08:00
|
|
|
REQUIRED_FILES uniq_nested.db-copy)
|
|
|
|
endif()
|
2022-04-22 01:25:04 +08:00
|
|
|
|
2023-10-07 14:08:34 +08:00
|
|
|
if(UNIX AND NOT SUBPROJECT)
|
|
|
|
add_test(NAME extra_upsert_alldups COMMAND test_extra_upsert_alldups)
|
2024-05-20 03:07:58 +08:00
|
|
|
add_test(NAME extra_dupfix_addodd COMMAND test_extra_dupfix_addodd)
|
2023-10-07 14:08:34 +08:00
|
|
|
if(MDBX_BUILD_CXX)
|
|
|
|
add_test(NAME extra_maindb_ordinal COMMAND test_extra_maindb_ordinal)
|
2024-05-20 03:07:58 +08:00
|
|
|
add_test(NAME extra_dupfix_multiple COMMAND test_extra_dupfix_multiple)
|
2023-11-24 19:11:41 +08:00
|
|
|
add_test(NAME extra_hex_base64_base58 COMMAND test_extra_hex_base64_base58)
|
2023-11-16 04:38:31 +08:00
|
|
|
add_test(NAME extra_doubtless_positioning COMMAND test_extra_doubtless_positioning)
|
2023-11-27 17:52:40 +08:00
|
|
|
if (ENABLE_MEMCHECK)
|
|
|
|
set_tests_properties(extra_doubtless_positioning PROPERTIES TIMEOUT 10800)
|
|
|
|
endif()
|
2024-05-26 04:20:34 +08:00
|
|
|
add_test(NAME extra_crunched_delete COMMAND test_extra_crunched_delete)
|
2023-10-07 14:08:34 +08:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2022-04-22 01:25:04 +08:00
|
|
|
endif()
|