# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2018-2021, Intel Corporation

include(ctest_helpers.cmake)

# ----------------------------------------------------------------- #
## Setup
# ----------------------------------------------------------------- #
add_custom_target(tests)

# Add checks when DEVELOPER_MODE is ON
set(common_files ${CMAKE_CURRENT_SOURCE_DIR}/common/*.*pp
				 ${CMAKE_CURRENT_SOURCE_DIR}/*.c
				 ${CMAKE_CURRENT_SOURCE_DIR}/*.h
				 ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp
				 ${CMAKE_CURRENT_SOURCE_DIR}/*.hpp
				 ${CMAKE_CURRENT_SOURCE_DIR}/check_is_pmem/*.*pp
				 ${CMAKE_CURRENT_SOURCE_DIR}/container_generic/*.*pp
				 ${CMAKE_CURRENT_SOURCE_DIR}/radix_tree/*.*pp
				 ${CMAKE_CURRENT_SOURCE_DIR}/mpsc_queue/*.*pp)

add_cppstyle(tests-common ${common_files})
add_check_whitespace(tests-common ${common_files})
add_check_whitespace(tests-cmake ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt)

# Set up compilation flags
if(MSVC_VERSION)
	add_flag(-W2)

	# disable warning C4996 - disable checking iterators
	add_flag(-D_SCL_SECURE_NO_WARNINGS)

	# disable warning C4996 - disable deprecation of getenv and strcpy functions
	add_flag(-D_CRT_SECURE_NO_WARNINGS)

	# fix C1128 raised for some test binaries
	add_flag(-bigobj)

	add_flag("-D_FORTIFY_SOURCE=2" RELEASE)

	# omit function name ambiguity under MSVC++ compiler
	if(MSVC_VERSION GREATER 1919)
		# Each CXX_FLAGS_* variable has its own /Ob setting. By default CMake
		# may set it up with some value, so we replace it (or add, if not found)
		# in the current build to avoid warning D9025.
		replace_or_add_flag("/Ob3" "/Ob[0-9]" ${CMAKE_BUILD_TYPE})
	endif()
else()
	add_flag(-Wall)
	add_flag("-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2" RELEASE)
endif()

add_flag(-Wpointer-arith)
add_flag(-Wunused-macros)
add_flag(-Wsign-conversion)
add_flag(-Wsign-compare)
add_flag(-Wunreachable-code-return)
add_flag(-Wmissing-variable-declarations)
add_flag(-fno-common)
add_flag(-Wno-maybe-uninitialized)

add_flag(-ggdb DEBUG)
add_flag(-DDEBUG DEBUG)

if(USE_ASAN)
	add_sanitizer_flag(address)
endif()
if(USE_UBSAN)
	add_sanitizer_flag(undefined)
endif()

if(COVERAGE)
	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -coverage")
endif()

# Prepare additional libraries/executables and find packages required for tests
find_packages()

# Try to find it for some tests using TBB
include(tbb)

add_library(test_backtrace STATIC test_backtrace.c)
if(LIBUNWIND_FOUND)
	target_compile_definitions(test_backtrace PUBLIC USE_LIBUNWIND=1)
endif()

add_library(valgrind_internal STATIC valgrind_internal.cpp)

add_executable(check_is_pmem check_is_pmem/check_is_pmem.cpp)
target_link_libraries(check_is_pmem ${LIBPMEM_LIBRARIES})

# Set variable to know if debug tests can be run
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
	set(DEBUG_BUILD_TESTS 1)
endif()

# Set variable if currently used compiler is GNU (gcc)
if("${CMAKE_C_COMPILER_ID}" MATCHES "GNU" AND "${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
	set(GCC_COMPILER_IN_USE 1)
endif()

# Produce general warnings, e.g. when a command/tool is missing
if(NOT GDB_FOUND)
	message(WARNING "GDB was not found - skipping some tests. To fix, make sure `gdb` command is OS-wide accessible.")
endif()

if(NOT PMREORDER_SUPPORTED)
	message(WARNING "Skipping pmreorder tests because of no pmreorder support")
endif()

# ----------------------------------------------------------------- #
## Tests
# ----------------------------------------------------------------- #
# tests using examples
function(build_example_queue)
	add_executable(ex-queue ../examples/queue/queue.cpp)
	target_include_directories(ex-queue PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../examples)
	target_link_libraries(ex-queue ${LIBPMEMOBJ_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
	add_dependencies(tests ex-queue)
endfunction()

function(build_example_pman)
	add_executable(ex-pman ../examples/pman/pman.cpp)
	target_include_directories(ex-pman PUBLIC ${CURSES_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../examples)
	target_link_libraries(ex-pman ${LIBPMEMOBJ_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${CURSES_LIBRARIES})
	add_dependencies(tests ex-pman)
endfunction()

if(BUILD_EXAMPLES AND NO_GCC_VARIADIC_TEMPLATE_BUG)
	build_example_queue()
	add_test_generic(NAME ex-queue CASE 0 TRACERS none SCRIPT ex-queue/ex-queue_0.cmake)

	if(CURSES_FOUND AND NOT WIN32)
		build_example_pman()
		add_test_generic(NAME ex-pman CASE 0 TRACERS none SCRIPT ex-pman/ex-pman_0.cmake)
	endif()
elseif(BUILD_EXAMPLES)
	skip_test("examples_tests" "SKIPPED_BECAUSE_OF_GCC_VARIADIC_TEMPLATE_BUG")
endif()

# common tests
if(AGGREGATE_INITIALIZATION_AVAILABLE)
	build_test(aggregate_initialization aggregate_initialization/aggregate_initialization.cpp)
	add_test_generic(NAME aggregate_initialization TRACERS none pmemcheck)
else()
	message(WARNING "Skipping aggregate initialization test because of no compiler support")
	skip_test("aggregate_initialization" "SKIPPED_BECAUSE_OF_NO_COMPILER_SUPPORT")
endif()

build_test(helpers_test common/helpers_test.cpp)
add_test_generic(NAME helpers_test TRACERS none memcheck)

build_test(allocator allocator/allocator.cpp)
add_test_generic(NAME allocator TRACERS none memcheck pmemcheck)

build_test(detail_common detail_common/detail_common.cpp)
add_test_generic(NAME detail_common TRACERS none)

build_test(make_persistent make_persistent/make_persistent.cpp)
add_test_generic(NAME make_persistent TRACERS none pmemcheck)

build_test(make_persistent_atomic make_persistent/make_persistent_atomic.cpp)
add_test_generic(NAME make_persistent_atomic TRACERS none pmemcheck)

if(NOT WIN32)
	build_test(mutex_posix mutex/mutex_posix.cpp)
	add_test_generic(NAME mutex_posix TRACERS drd helgrind pmemcheck)
endif()

build_test(pair pair/pair.cpp)
add_test_generic(NAME pair TRACERS none memcheck)

build_test(pool pool/pool.cpp)
add_test_generic(NAME pool CASE 0 TRACERS none)
add_test_generic(NAME pool CASE 1 TRACERS none)
add_test_generic(NAME pool CASE 2 TRACERS none)
add_test_generic(NAME pool CASE 3 TRACERS none)
add_test_generic(NAME pool CASE 4 TRACERS none)
add_test_generic(NAME pool CASE 5 TRACERS none)
add_test_generic(NAME pool CASE 6 TRACERS none)
add_test_generic(NAME pool CASE 7 TRACERS none)
if (NOT WIN32)
	add_test_generic(NAME pool CASE 8 TRACERS none)
endif()
add_test_generic(NAME pool CASE 9 TRACERS none)

if(WIN32)
	build_test(pool_win pool/pool_win.cpp)
	add_test_generic(NAME pool_win CASE 0 TRACERS none SCRIPT pool/pool_win_0.cmake)
	add_test_generic(NAME pool_win CASE 1 TRACERS none SCRIPT pool/pool_win_1.cmake)
	add_test_generic(NAME pool_win CASE 2 TRACERS none SCRIPT pool/pool_win_2.cmake)
	add_test_generic(NAME pool_win CASE 3 TRACERS none SCRIPT pool/pool_win_3.cmake)
endif()

build_test(pool_cleanup pool/pool_cleanup.cpp)
add_test_generic(NAME pool_cleanup TRACERS none pmemcheck memcheck drd helgrind CASE 0
		SCRIPT pool/pool_cleanup_0.cmake)

build_test(pool_primitives pool/pool_primitives.cpp)
add_test_generic(NAME pool_primitives CASE 0 TRACERS none pmemcheck
		SCRIPT cmake/common_0.cmake)

build_test(ptr ptr/ptr.cpp)
add_test_generic(NAME ptr CASE 0 TRACERS none pmemcheck
		SCRIPT cmake/common_0.cmake)

build_test(ptr_arith ptr/ptr_arith.cpp)
add_test_generic(NAME ptr_arith TRACERS memcheck pmemcheck)
# XXX Bug: incompatibility between asan and custom library
if(NOT USE_ASAN)
	add_test_generic(NAME ptr_arith TRACERS none)
endif()

if(NOT USE_UBSAN)
	# We want to test overflow which is reported by UBSAN
	build_test(p_ext p_ext/p_ext.cpp)
	add_test_generic(NAME p_ext TRACERS none pmemcheck)
endif()

if(NOT WIN32)
	build_test(shared_mutex_posix mutex/shared_mutex_posix.cpp)
	add_test_generic(NAME shared_mutex_posix TRACERS drd helgrind pmemcheck)
endif()

build_test_ext(NAME transaction_common_flat SRC_FILES transaction/transaction.cpp BUILD_OPTIONS -DLIBPMEMOBJ_CPP_USE_FLAT_TRANSACTION)
add_test_generic(NAME transaction_common_flat TRACERS none pmemcheck memcheck)

build_test_ext(NAME transaction_common_basic SRC_FILES transaction/transaction.cpp)
add_test_generic(NAME transaction_common_basic TRACERS none pmemcheck memcheck)

build_test_ext(NAME transaction_flat SRC_FILES transaction/transaction_flat.cpp BUILD_OPTIONS -DLIBPMEMOBJ_CPP_USE_FLAT_TRANSACTION)
add_test_generic(NAME transaction_flat TRACERS none pmemcheck memcheck)

build_test_ext(NAME transaction_basic SRC_FILES transaction/transaction_basic.cpp)
add_test_generic(NAME transaction_basic TRACERS none pmemcheck memcheck)

if(VOLATILE_STATE_PRESENT)
	build_test(volatile_state volatile_state/volatile_state.cpp)
	add_test_generic(NAME volatile_state TRACERS none pmemcheck memcheck drd helgrind)
endif()

build_test(v v/v.cpp)
add_test_generic(NAME v CASE 0 TRACERS none memcheck SCRIPT cmake/common_0.cmake)

if(NO_CHRONO_BUG)
	build_test(cond_var cond_var/cond_var.cpp)
	add_test_generic(NAME cond_var TRACERS none)

	if(NOT WIN32)
		build_test(cond_var_posix cond_var/cond_var_posix.cpp)
		add_test_generic(NAME cond_var_posix TRACERS drd helgrind pmemcheck)
	endif()

	build_test(mutex mutex/mutex.cpp)
	add_test_generic(NAME mutex TRACERS none)

	build_test(shared_mutex mutex/shared_mutex.cpp)
	add_test_generic(NAME shared_mutex TRACERS none)

	if(NOT WIN32)
		build_test(timed_mtx_posix mutex/timed_mtx_posix.cpp)
		add_test_generic(NAME timed_mtx_posix TRACERS drd helgrind pmemcheck)
	endif()

	build_test(timed_mtx mutex/timed_mtx.cpp)
	add_test_generic(NAME timed_mtx TRACERS none)
else()
	message(WARNING "Skipping chrono tests because of compiler/stdc++ issues")
	skip_test("chrono_tests" "SKIPPED_BECAUSE_OF_COMPILER_CHRONO_BUG")
endif()

if(NO_CLANG_TEMPLATE_BUG)
	build_test(make_persistent_array make_persistent/make_persistent_array.cpp)
	add_test_generic(NAME make_persistent_array TRACERS none pmemcheck)

	build_test(make_persistent_array_atomic make_persistent/make_persistent_array_atomic.cpp)
	add_test_generic(NAME make_persistent_array_atomic TRACERS none pmemcheck)
else()
	message(WARNING "Skipping array tests because of clang template bug")
	skip_test("make_persistent_array" "SKIPPED_BECAUSE_OF_CLANG_TEMPLATE_BUG")
	skip_test("make_persistent_array_atomic" "SKIPPED_BECAUSE_OF_CLANG_TEMPLATE_BUG")
endif()

build_test(iterator_traits iterator_traits/iterator_traits.cpp)
add_test_generic(NAME iterator_traits TRACERS none)

build_test(ctl ctl/ctl.cpp)
add_test_generic(NAME ctl CASE 0 TRACERS none)

if(WIN32)
	build_test(ctl_win ctl_win/ctl_win.cpp)
	add_test_generic(NAME ctl_win CASE 0 TRACERS none SCRIPT ctl/ctl_0.cmake)
endif()

build_test(defrag defrag/defrag.cpp)
add_test_generic(NAME defrag TRACERS none pmemcheck memcheck)

build_test(string_view string_view/string_view.cpp)
add_test_generic(NAME string_view TRACERS none memcheck)

build_test(inline_string inline_string/inline_string.cpp)
add_test_generic(NAME inline_string TRACERS none memcheck pmemcheck)

build_test(ebr ebr/ebr.cpp)
add_test_generic(NAME ebr TRACERS none memcheck pmemcheck drd) # XXX: helgrind - ebr.hpp needs helgrind's annotations.

if(TEST_SELF_RELATIVE_POINTER)
	build_test(self_relative_ptr ptr/self_relative_ptr.cpp)
	add_test_generic(NAME self_relative_ptr TRACERS none memcheck pmemcheck)

	build_test(self_relative_ptr_arith ptr/self_relative_ptr_arith.cpp)
	add_test_generic(NAME self_relative_ptr_arith TRACERS none memcheck pmemcheck)

	build_test(self_relative_ptr_atomic ptr/self_relative_ptr_atomic.cpp)
	add_test_generic(NAME self_relative_ptr_atomic TRACERS none memcheck drd helgrind)

	build_test(self_relative_ptr_atomic_pmem ptr/self_relative_ptr_atomic_pmem.cpp)
	add_test_generic(NAME self_relative_ptr_atomic_pmem TRACERS none memcheck pmemcheck drd helgrind)
endif()

add_subdirectory(external)

if(TESTS_COMPATIBILITY)
	add_subdirectory(compatibility)
endif()

# Containers tests
###################################### ARRAY ###################################
if(TEST_ARRAY)
	build_test(array_algorithms array/array_algorithms.cpp)
	add_test_generic(NAME array_algorithms TRACERS none pmemcheck)

	build_test(array_slice array/array_slice.cpp)
	add_test_generic(NAME array_slice CASE 0 TRACERS none pmemcheck memcheck SCRIPT array/array_slice_0.cmake)

	build_test(array_iterator array/array_iterator.cpp)
	add_test_generic(NAME array_iterator TRACERS none pmemcheck)

	build_test(array_iterator_noconv array/array_iterator_noconv.cpp)
	check_cxx_compiler_flag(-Wno-sign-conversion NO_SIGN_CONVERSION_FLAG)
	if(NO_SIGN_CONVERSION_FLAG)
		target_compile_options(array_iterator_noconv PUBLIC -Wno-sign-conversion)
	endif()
	add_test_generic(NAME array_iterator_noconv TRACERS none)

	if(NOT CLANG_DESTRUCTOR_REFERENCE_BUG_PRESENT)
		build_test(array_modifiers array/array_modifiers.cpp)
		add_test_generic(NAME array_modifiers TRACERS none pmemcheck memcheck)
	else()
		message(WARNING "skipping array_modifiers test - it requires clang >= ${CLANG_REQUIRED_BY_DESTRUCTOR_REFERENCE_BUG}")
	endif()

	if(PMREORDER_SUPPORTED)
		build_test(array_slice_pmreorder array/array_slice_pmreorder.cpp)
		add_test_generic(NAME array_slice_pmreorder CASE 0 TRACERS none SCRIPT array/array_slice_pmreorder_0.cmake)
		add_test_generic(NAME array_slice_pmreorder CASE 1 TRACERS none SCRIPT array/array_slice_pmreorder_1.cmake)
	endif()
	if(CXX_STANDARD GREATER 14)
		build_test(array_is_aggregate array/array_is_aggregate.cpp)
		add_test_generic(NAME array_is_aggregate TRACERS none)
	endif()
endif()
################################################################################
###################################### VECTOR ##################################
if(TEST_VECTOR)
	build_test_ext(NAME vector_temp_value SRC_FILES temp_value/temp_value.cpp BUILD_OPTIONS -DVECTOR)
	add_test_generic(NAME vector_temp_value TRACERS none pmemcheck memcheck)

	build_test_ext(NAME vector_assign_exceptions_length SRC_FILES vector/vector_assign_exceptions_length.cpp BUILD_OPTIONS -DVECTOR)

	# array-bounds warning is expected
	check_cxx_compiler_flag(-Wno-array-bounds wno_array_bounds_flag)
	if(wno_array_bounds_flag)
		target_compile_options(vector_assign_exceptions_length PUBLIC -Wno-array-bounds)
	endif()

	add_test_generic(NAME vector_assign_exceptions_length TRACERS none memcheck pmemcheck)

	build_test_ext(NAME vector_assign_exceptions_oom SRC_FILES vector/vector_assign_exceptions_oom.cpp BUILD_OPTIONS -DVECTOR)
	add_test_generic(NAME vector_assign_exceptions_oom TRACERS none memcheck pmemcheck)

	build_test_ext(NAME vector_assign_txabort SRC_FILES vector/vector_assign_txabort.cpp BUILD_OPTIONS -DVECTOR)
	add_test_generic(NAME vector_assign_txabort TRACERS none memcheck pmemcheck)

	build_test_ext(NAME vector_comp_operators SRC_FILES vector/vector_comp_operators.cpp BUILD_OPTIONS -DVECTOR)
	add_test_generic(NAME vector_comp_operators TRACERS none memcheck pmemcheck)

	build_test_ext(NAME vector_capacity_exceptions_length SRC_FILES vector/vector_capacity_exceptions_length.cpp BUILD_OPTIONS -DVECTOR)
	add_test_generic(NAME vector_capacity_exceptions_length TRACERS none memcheck pmemcheck)

	build_test_ext(NAME vector_capacity_exceptions_oom SRC_FILES vector/vector_capacity_exceptions_oom.cpp BUILD_OPTIONS -DVECTOR)
	add_test_generic(NAME vector_capacity_exceptions_oom TRACERS none memcheck pmemcheck)

	build_test_ext(NAME vector_capacity_txabort SRC_FILES vector/vector_capacity_txabort.cpp BUILD_OPTIONS -DVECTOR)
	add_test_generic(NAME vector_capacity_txabort TRACERS none memcheck pmemcheck)

	build_test_ext(NAME vector_ctor_exceptions_nopmem SRC_FILES vector/vector_ctor_exceptions_nopmem.cpp BUILD_OPTIONS -DVECTOR)
	add_test_generic(NAME vector_ctor_exceptions_nopmem TRACERS none memcheck )

	build_test_ext(NAME vector_ctor_exceptions_notx SRC_FILES vector/vector_ctor_exceptions_notx.cpp BUILD_OPTIONS -DVECTOR)
	add_test_generic(NAME vector_ctor_exceptions_notx TRACERS none memcheck)

	build_test_ext(NAME vector_ctor_exceptions_oom SRC_FILES vector/vector_ctor_exceptions_oom.cpp BUILD_OPTIONS -DVECTOR)
	add_test_generic(NAME vector_ctor_exceptions_oom TRACERS none memcheck pmemcheck)

	build_test_ext(NAME vector_ctor_move SRC_FILES vector/vector_ctor_move.cpp BUILD_OPTIONS -DVECTOR)
	add_test_generic(NAME vector_ctor_move TRACERS none memcheck pmemcheck)

	build_test_ext(NAME vector_ctor_capacity SRC_FILES vector/vector_ctor_capacity.cpp BUILD_OPTIONS -DVECTOR)
	add_test_generic(NAME vector_ctor_capacity TRACERS none memcheck pmemcheck)

	build_test_ext(NAME vector_dtor SRC_FILES vector/vector_dtor.cpp BUILD_OPTIONS -DVECTOR)
	add_test_generic(NAME vector_dtor TRACERS none memcheck pmemcheck)

	build_test_ext(NAME vector_iterators_access SRC_FILES vector/vector_iterators_access.cpp BUILD_OPTIONS -DVECTOR)
	add_test_generic(NAME vector_iterators_access TRACERS none memcheck pmemcheck)

	build_test_ext(NAME vector_data_access SRC_FILES vector/vector_data_access.cpp BUILD_OPTIONS -DVECTOR)
	add_test_generic(NAME vector_data_access TRACERS none memcheck pmemcheck)

	build_test_ext(NAME vector_ctor_check_copy SRC_FILES vector/vector_ctor_check_copy.cpp BUILD_OPTIONS -DVECTOR)
	add_test_generic(NAME vector_ctor_check_copy TRACERS none memcheck pmemcheck)

	build_test_ext(NAME vector_modifiers_exceptions_oom SRC_FILES vector/vector_modifiers_exceptions_oom.cpp BUILD_OPTIONS -DVECTOR)
	add_test_generic(NAME vector_modifiers_exceptions_oom TRACERS none memcheck pmemcheck)

	build_test_ext(NAME vector_modifiers_txabort SRC_FILES vector/vector_modifiers_txabort.cpp BUILD_OPTIONS -DVECTOR)
	add_test_generic(NAME vector_modifiers_txabort TRACERS none memcheck pmemcheck)

	build_test_ext(NAME vector_modifiers_type_requirements SRC_FILES vector/vector_modifiers_type_requirements.cpp BUILD_OPTIONS -DVECTOR)
	add_test_generic(NAME vector_modifiers_type_requirements TRACERS none memcheck pmemcheck)

	build_test_ext(NAME vector_std_arg SRC_FILES vector/vector_std_arg.cpp BUILD_OPTIONS -DVECTOR)
	add_test_generic(NAME vector_std_arg TRACERS none memcheck pmemcheck)

	build_test_ext(NAME vector_range SRC_FILES vector/vector_range.cpp BUILD_OPTIONS -DVECTOR)
	add_test_generic(NAME vector_range TRACERS none memcheck pmemcheck)

	build_test_ext(NAME vector_parameters SRC_FILES vector/vector_parameters.cpp BUILD_OPTIONS -DVECTOR)
	add_test_generic(NAME vector_parameters TRACERS none memcheck pmemcheck)

	build_test_ext(NAME vector_layout SRC_FILES vector/vector_layout.cpp BUILD_OPTIONS -DVECTOR)
	add_test_generic(NAME vector_layout TRACERS none)

	build_test(defrag_vector defrag/defrag_vector.cpp)
	add_test_generic(NAME defrag_vector TRACERS none pmemcheck memcheck)
endif()
################################################################################
###################################### STRING ##################################
if(TEST_STRING)
	build_test(string_access string/string_access.cpp)
	add_test_generic(NAME string_access TRACERS none memcheck pmemcheck)

	build_test(string_capacity string/string_capacity.cpp)
	add_test_generic(NAME string_capacity TRACERS none memcheck pmemcheck)

	build_test(string_exceptions string/string_exceptions.cpp)
	add_test_generic(NAME string_exceptions TRACERS none memcheck pmemcheck)

	build_test(string_modifiers string/string_modifiers.cpp)
	add_test_generic(NAME string_modifiers TRACERS none memcheck pmemcheck)

	build_test(string_swap string/string_swap.cpp)
	add_test_generic(NAME string_swap TRACERS none memcheck pmemcheck)

	build_test(string_snapshot string/string_snapshot.cpp)
	add_test_generic(NAME string_snapshot TRACERS none memcheck pmemcheck)

	build_test(string_assign_tx_abort string/string_assign_tx_abort.cpp)
	add_test_generic(NAME string_assign_tx_abort TRACERS none memcheck pmemcheck)

	build_test(string_layout string/string_layout.cpp)
	add_test_generic(NAME string_layout TRACERS none)

	build_test(string_range string/string_range.cpp)
	add_test_generic(NAME string_range TRACERS none memcheck pmemcheck)
endif()
################################################################################
############################### CONCURRENT_HASHMAP #############################
if(TEST_CONCURRENT_HASHMAP)
	build_test(concurrent_hash_map_tx concurrent_hash_map/concurrent_hash_map_tx.cpp)
	add_test_generic(NAME concurrent_hash_map_tx TRACERS none memcheck pmemcheck)

	build_test(concurrent_hash_map_insert_or_assign concurrent_hash_map/concurrent_hash_map_insert_or_assign.cpp)
	add_test_generic(NAME concurrent_hash_map_insert_or_assign TRACERS none memcheck pmemcheck helgrind drd)

	build_test(concurrent_hash_map_insert_lookup concurrent_hash_map/concurrent_hash_map_insert_lookup.cpp)
	add_test_generic(NAME concurrent_hash_map_insert_lookup CASE 0 TRACERS none
			SCRIPT concurrent_hash_map/check_is_pmem.cmake)

	build_test_defrag(concurrent_hash_map_insert_lookup_mock concurrent_hash_map/concurrent_hash_map_insert_lookup.cpp)
	add_test_generic(NAME concurrent_hash_map_insert_lookup_mock CASE 0 TRACERS memcheck pmemcheck
			SCRIPT concurrent_hash_map/check_is_pmem.cmake)

	if(TESTS_CONCURRENT_HASH_MAP_DRD_HELGRIND AND TESTS_LONG)
		add_test_generic(NAME concurrent_hash_map_insert_lookup_mock CASE 0 TRACERS helgrind drd
				SCRIPT concurrent_hash_map/check_is_pmem.cmake)
	endif()

	build_test(concurrent_hash_map_insert_erase concurrent_hash_map/concurrent_hash_map_insert_erase.cpp)
	add_test_generic(NAME concurrent_hash_map_insert_erase CASE 0 TRACERS none
			SCRIPT concurrent_hash_map/check_is_pmem.cmake)
	add_test_generic(NAME concurrent_hash_map_insert_erase CASE 1 TRACERS none
			SCRIPT concurrent_hash_map/check_is_pmem.cmake)

	build_test_defrag(concurrent_hash_map_insert_erase_mock concurrent_hash_map/concurrent_hash_map_insert_erase.cpp)
	add_test_generic(NAME concurrent_hash_map_insert_erase_mock CASE 0 TRACERS memcheck pmemcheck
			SCRIPT concurrent_hash_map/check_is_pmem.cmake)
	add_test_generic(NAME concurrent_hash_map_insert_erase_mock CASE 1 TRACERS memcheck pmemcheck
			SCRIPT concurrent_hash_map/check_is_pmem_defrag.cmake)

	if(TESTS_CONCURRENT_HASH_MAP_DRD_HELGRIND)
		add_test_generic(NAME concurrent_hash_map_insert_erase_mock CASE 0 TRACERS helgrind drd
			SCRIPT concurrent_hash_map/check_is_pmem.cmake)
		add_test_generic(NAME concurrent_hash_map_insert_erase_mock CASE 1 TRACERS helgrind drd
			SCRIPT concurrent_hash_map/check_is_pmem_defrag.cmake)
	endif()

	# This test should not be run under helgrind due to intermittent failures (most probably false-positive, ref. issue #469)
	build_test(concurrent_hash_map_rehash concurrent_hash_map/concurrent_hash_map_rehash.cpp)
	add_test_generic(NAME concurrent_hash_map_rehash CASE 0 TRACERS none
			SCRIPT concurrent_hash_map/check_is_pmem.cmake)
	add_test_generic(NAME concurrent_hash_map_rehash CASE 1 TRACERS none
			SCRIPT concurrent_hash_map/check_is_pmem_defrag.cmake)

	build_test_defrag(concurrent_hash_map_rehash_mock concurrent_hash_map/concurrent_hash_map_rehash.cpp)
	add_test_generic(NAME concurrent_hash_map_rehash_mock CASE 0 TRACERS memcheck pmemcheck
			SCRIPT concurrent_hash_map/check_is_pmem.cmake)
	add_test_generic(NAME concurrent_hash_map_rehash_mock CASE 1 TRACERS memcheck pmemcheck
			SCRIPT concurrent_hash_map/check_is_pmem_defrag.cmake)

	if(TESTS_CONCURRENT_HASH_MAP_DRD_HELGRIND)
		# This test should not be run under helgrind due to intermittent failures (most probably false-positive, ref. issue #469)
		if(TESTS_LONG)
			add_test_generic(NAME concurrent_hash_map_rehash_mock CASE 0 TRACERS drd
					SCRIPT concurrent_hash_map/check_is_pmem.cmake)
			add_test_generic(NAME concurrent_hash_map_rehash_mock CASE 1 TRACERS drd
					SCRIPT concurrent_hash_map/check_is_pmem_defrag.cmake)
		endif()
	endif()

	build_test(concurrent_hash_map_rehash_recursive concurrent_hash_map/concurrent_hash_map_rehash_recursive.cpp)
	add_test_generic(NAME concurrent_hash_map_rehash_recursive CASE 0 TRACERS none
			SCRIPT concurrent_hash_map/check_is_pmem.cmake)

	build_test_defrag(concurrent_hash_map_rehash_recursive_mock concurrent_hash_map/concurrent_hash_map_rehash_recursive.cpp)
	add_test_generic(NAME concurrent_hash_map_rehash_recursive_mock CASE 0 TRACERS memcheck pmemcheck
			SCRIPT concurrent_hash_map/check_is_pmem.cmake)

	if(TESTS_CONCURRENT_HASH_MAP_DRD_HELGRIND AND TESTS_LONG)
		add_test_generic(NAME concurrent_hash_map_rehash_recursive_mock CASE 0 TRACERS helgrind drd
				SCRIPT concurrent_hash_map/check_is_pmem.cmake)
	endif()

	build_test(concurrent_hash_map_rehash_deadlock concurrent_hash_map/concurrent_hash_map_rehash_deadlock.cpp)
	add_test_generic(NAME concurrent_hash_map_rehash_deadlock CASE 0 TRACERS none
			SCRIPT concurrent_hash_map/check_is_pmem.cmake)

	# this single-threaded test should not be run under helgrind/drd, because a false-positive deadlock can be detected
	build_test_defrag(concurrent_hash_map_rehash_deadlock_mock concurrent_hash_map/concurrent_hash_map_rehash_deadlock.cpp)
	add_test_generic(NAME concurrent_hash_map_rehash_deadlock_mock CASE 0 TRACERS memcheck pmemcheck
			SCRIPT concurrent_hash_map/check_is_pmem.cmake)

	build_test(concurrent_hash_map_defrag concurrent_hash_map/concurrent_hash_map_defrag.cpp)
	add_test_generic(NAME concurrent_hash_map_defrag TRACERS none)

	# This test can NOT be run under helgrind as it will report wrong lock ordering. Helgrind is right about
	# possible deadlock situation, but that could only happen in case of wrong API usage.
	build_test(concurrent_hash_map_deadlock concurrent_hash_map/concurrent_hash_map_deadlock.cpp)
	add_test_generic(NAME concurrent_hash_map_deadlock CASE 0 TRACERS none drd memcheck pmemcheck
			SCRIPT concurrent_hash_map/check_is_pmem.cmake)

	build_test(concurrent_hash_map_insert_reopen concurrent_hash_map/concurrent_hash_map_insert_reopen.cpp)
	add_test_generic(NAME concurrent_hash_map_insert_reopen CASE 0 TRACERS none memcheck pmemcheck
			SCRIPT concurrent_hash_map/check_is_pmem.cmake)

	if(TESTS_CONCURRENT_HASH_MAP_DRD_HELGRIND)
		add_test_generic(NAME concurrent_hash_map_insert_reopen CASE 0 TRACERS drd helgrind
				SCRIPT concurrent_hash_map/check_is_pmem.cmake)
	endif()

	build_test_ext(NAME concurrent_hash_map_insert_reopen_deprecated SRC_FILES concurrent_hash_map/concurrent_hash_map_insert_reopen.cpp
			BUILD_OPTIONS -DUSE_DEPRECATED_RUNTIME_INITIALIZE)
	check_cxx_compiler_flag(-Wdeprecated-declarations deprecated_declarations)
	if(deprecated_declarations)
		target_compile_options(concurrent_hash_map_insert_reopen_deprecated PUBLIC -Wno-deprecated-declarations)
	endif()
	add_test_generic(NAME concurrent_hash_map_insert_reopen_deprecated TRACERS none)

	build_test(concurrent_hash_map_rehash_check concurrent_hash_map/concurrent_hash_map_rehash_check.cpp)
	add_test_generic(NAME concurrent_hash_map_rehash_check TRACERS none memcheck pmemcheck)

	build_test(concurrent_hash_map_singlethread concurrent_hash_map/concurrent_hash_map_singlethread.cpp)
	add_test_generic(NAME concurrent_hash_map_singlethread TRACERS none memcheck pmemcheck)

	if(NOT USE_UBSAN)
		# ASSERT_ALIGNED_FIELD is not compatible with UBSAN
		build_test(concurrent_hash_map_layout concurrent_hash_map/concurrent_hash_map_layout.cpp)
		add_test_generic(NAME concurrent_hash_map_layout TRACERS none)
	endif()

	if(GDB_FOUND)
		build_test(concurrent_hash_map_rehash_break concurrent_hash_map_rehash_break/concurrent_hash_map_rehash_break.cpp)

		if(NOT WIN32)
			# add 2 concurrent_hash_map_rehash_break tests
			set(CURRENT_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/concurrent_hash_map_rehash_break)
			set(CMAKE_SCRIPT ${CURRENT_TEST_DIR}/concurrent_hash_map_rehash_break)
			foreach(TESTCASE RANGE 1)
				configure_file("${CMAKE_SCRIPT}.cmake.in" "${CMAKE_SCRIPT}_${TESTCASE}.cmake" @ONLY)
				add_test_generic(NAME concurrent_hash_map_rehash_break CASE ${TESTCASE} TRACERS none)
			endforeach()
		endif()
	endif()

	if(NOT TESTS_TBB)
		message(WARNING "Skipping concurrent_hash_map_tbb tests - disabled by cmake TESTS_TBB option")
	else()
		build_test_tbb(concurrent_hash_map_tbb_insert_lookup concurrent_hash_map/concurrent_hash_map_tbb_insert_lookup.cpp)
		add_test_generic(NAME concurrent_hash_map_tbb_insert_lookup TRACERS none
				SCRIPT concurrent_hash_map/check_is_pmem.cmake)

		build_test_tbb_defrag(concurrent_hash_map_tbb_insert_lookup_mock concurrent_hash_map/concurrent_hash_map_tbb_insert_lookup.cpp)
		add_test_generic(NAME concurrent_hash_map_tbb_insert_lookup_mock TRACERS pmemcheck
				SCRIPT concurrent_hash_map/check_is_pmem.cmake)

		build_test_tbb(concurrent_hash_map_tbb_insert_erase concurrent_hash_map/concurrent_hash_map_tbb_insert_erase.cpp)
		add_test_generic(NAME concurrent_hash_map_tbb_insert_erase TRACERS none
				SCRIPT concurrent_hash_map/check_is_pmem.cmake)

		build_test_tbb_defrag(concurrent_hash_map_tbb_insert_erase_mock concurrent_hash_map/concurrent_hash_map_tbb_insert_erase.cpp)
		add_test_generic(NAME concurrent_hash_map_tbb_insert_erase_mock TRACERS pmemcheck
				SCRIPT concurrent_hash_map/check_is_pmem.cmake)
	endif()

	if(PMREORDER_SUPPORTED)
		build_test(concurrent_hash_map_pmreorder_simple concurrent_hash_map/concurrent_hash_map_pmreorder_simple.cpp)
		add_test_generic(NAME concurrent_hash_map_pmreorder_simple CASE 0 TRACERS none
				SCRIPT cmake/pmreorder.cmake)

		build_test(concurrent_hash_map_pmreorder_multiple_buckets concurrent_hash_map_pmreorder_multiple_buckets/concurrent_hash_map_pmreorder_multiple_buckets.cpp)
		add_test_generic(NAME concurrent_hash_map_pmreorder_multiple_buckets CASE 0 TRACERS none
				SCRIPT cmake/pmreorder.cmake)

		build_test(concurrent_hash_map_pmreorder_erase concurrent_hash_map_pmreorder_erase/concurrent_hash_map_pmreorder_erase.cpp)
		add_test_generic(NAME concurrent_hash_map_pmreorder_erase CASE 0 TRACERS none)

		if(GDB_FOUND)
			set(TEST concurrent_hash_map_pmreorder_break_insert)
			build_test(${TEST} ${TEST}/${TEST}.cpp)

			# add 5 concurrent_hash_map_pmreorder_break_insert test cases
			set(CURRENT_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/${TEST})
			set(CMAKE_SCRIPT ${CURRENT_TEST_DIR}/${TEST})
			set(GDB_SCRIPT ${CURRENT_TEST_DIR}/break_before_persist)
			foreach(case RANGE 4)
				math(EXPR IGNORE "${case} + 1")
				math(EXPR PERSIST "${case} + 2")
				configure_file("${GDB_SCRIPT}.gdb.in" "${GDB_SCRIPT}_${PERSIST}.gdb" @ONLY)
				configure_file("${CMAKE_SCRIPT}.cmake.in" "${CMAKE_SCRIPT}_${case}.cmake" @ONLY)
				add_test_generic(NAME ${TEST} CASE ${case} TRACERS none)
			endforeach()
		endif()
	endif()
endif()
################################################################################
################################# SEGMENT_VECTOR ###############################
if(TEST_SEGMENT_VECTOR_ARRAY_EXPSIZE)
	build_test_ext(NAME segment_vector_array_expsize_temp_value SRC_FILES temp_value/temp_value.cpp BUILD_OPTIONS -DSEGMENT_VECTOR_ARRAY_EXPSIZE)
	add_test_generic(NAME segment_vector_array_expsize_temp_value TRACERS none pmemcheck memcheck)

	build_test_ext(NAME segment_vector_array_expsize_assign_exceptions_length SRC_FILES vector/vector_assign_exceptions_length.cpp BUILD_OPTIONS -DSEGMENT_VECTOR_ARRAY_EXPSIZE)
	add_test_generic(NAME segment_vector_array_expsize_assign_exceptions_length TRACERS none memcheck pmemcheck)

	build_test_ext(NAME segment_vector_array_expsize_assign_exceptions_oom SRC_FILES vector/vector_assign_exceptions_oom.cpp BUILD_OPTIONS -DSEGMENT_VECTOR_ARRAY_EXPSIZE)
	add_test_generic(NAME segment_vector_array_expsize_assign_exceptions_oom TRACERS none memcheck pmemcheck)

	build_test_ext(NAME segment_vector_array_expsize_assign_txabort SRC_FILES vector/vector_assign_txabort.cpp BUILD_OPTIONS -DSEGMENT_VECTOR_ARRAY_EXPSIZE)
	add_test_generic(NAME segment_vector_array_expsize_assign_txabort TRACERS none memcheck pmemcheck)

	build_test_ext(NAME segment_vector_array_expsize_comp_operators SRC_FILES vector/vector_comp_operators.cpp BUILD_OPTIONS -DSEGMENT_VECTOR_ARRAY_EXPSIZE)
	add_test_generic(NAME segment_vector_array_expsize_comp_operators TRACERS none memcheck pmemcheck)

	build_test_ext(NAME segment_vector_array_expsize_capacity_exceptions_length SRC_FILES vector/vector_capacity_exceptions_length.cpp BUILD_OPTIONS -DSEGMENT_VECTOR_ARRAY_EXPSIZE)
	add_test_generic(NAME segment_vector_array_expsize_capacity_exceptions_length TRACERS none memcheck pmemcheck)

	build_test_ext(NAME segment_vector_array_expsize_capacity_exceptions_oom SRC_FILES vector/vector_capacity_exceptions_oom.cpp BUILD_OPTIONS -DSEGMENT_VECTOR_ARRAY_EXPSIZE)
	add_test_generic(NAME segment_vector_array_expsize_capacity_exceptions_oom TRACERS none memcheck pmemcheck)

	build_test_ext(NAME segment_vector_array_expsize_capacity_txabort SRC_FILES vector/vector_capacity_txabort.cpp BUILD_OPTIONS -DSEGMENT_VECTOR_ARRAY_EXPSIZE)
	add_test_generic(NAME segment_vector_array_expsize_capacity_txabort TRACERS none memcheck pmemcheck)

	build_test_ext(NAME segment_vector_array_expsize_ctor_exceptions_nopmem SRC_FILES vector/vector_ctor_exceptions_nopmem.cpp BUILD_OPTIONS -DSEGMENT_VECTOR_ARRAY_EXPSIZE)
	add_test_generic(NAME segment_vector_array_expsize_ctor_exceptions_nopmem TRACERS none memcheck )

	build_test_ext(NAME segment_vector_array_expsize_ctor_exceptions_notx SRC_FILES vector/vector_ctor_exceptions_notx.cpp BUILD_OPTIONS -DSEGMENT_VECTOR_ARRAY_EXPSIZE)
	add_test_generic(NAME segment_vector_array_expsize_ctor_exceptions_notx TRACERS none memcheck)

	build_test_ext(NAME segment_vector_array_expsize_ctor_exceptions_oom SRC_FILES vector/vector_ctor_exceptions_oom.cpp BUILD_OPTIONS -DSEGMENT_VECTOR_ARRAY_EXPSIZE)
	add_test_generic(NAME segment_vector_array_expsize_ctor_exceptions_oom TRACERS none memcheck pmemcheck)

	build_test_ext(NAME segment_vector_array_expsize_ctor_move SRC_FILES vector/vector_ctor_move.cpp BUILD_OPTIONS -DSEGMENT_VECTOR_ARRAY_EXPSIZE)
	add_test_generic(NAME segment_vector_array_expsize_ctor_move TRACERS none memcheck pmemcheck)

	build_test_ext(NAME segment_vector_array_expsize_ctor_capacity SRC_FILES vector/vector_ctor_capacity.cpp BUILD_OPTIONS -DSEGMENT_VECTOR_ARRAY_EXPSIZE)
	add_test_generic(NAME segment_vector_array_expsize_ctor_capacity TRACERS none memcheck pmemcheck)

	build_test_ext(NAME segment_vector_array_expsize_dtor SRC_FILES vector/vector_dtor.cpp BUILD_OPTIONS -DSEGMENT_VECTOR_ARRAY_EXPSIZE)
	add_test_generic(NAME segment_vector_array_expsize_dtor TRACERS none memcheck pmemcheck)

	build_test_ext(NAME segment_vector_array_expsize_iterators_access SRC_FILES vector/vector_iterators_access.cpp BUILD_OPTIONS -DSEGMENT_VECTOR_ARRAY_EXPSIZE)
	add_test_generic(NAME segment_vector_array_expsize_iterators_access TRACERS none memcheck pmemcheck)

	build_test_ext(NAME segment_vector_array_expsize_ctor_check_copy SRC_FILES vector/vector_ctor_check_copy.cpp BUILD_OPTIONS -DSEGMENT_VECTOR_ARRAY_EXPSIZE)
	add_test_generic(NAME segment_vector_array_expsize_ctor_check_copy TRACERS none memcheck pmemcheck)

	build_test_ext(NAME segment_vector_array_expsize_modifiers_exceptions_oom SRC_FILES vector/vector_modifiers_exceptions_oom.cpp BUILD_OPTIONS -DSEGMENT_VECTOR_ARRAY_EXPSIZE)
	add_test_generic(NAME segment_vector_array_expsize_modifiers_exceptions_oom TRACERS none memcheck pmemcheck)

	build_test_ext(NAME segment_vector_array_expsize_modifiers_txabort SRC_FILES vector/vector_modifiers_txabort.cpp BUILD_OPTIONS -DSEGMENT_VECTOR_ARRAY_EXPSIZE)
	add_test_generic(NAME segment_vector_array_expsize_modifiers_txabort TRACERS none memcheck pmemcheck)

	build_test_ext(NAME segment_vector_array_expsize_modifiers_type_requirements SRC_FILES vector/vector_modifiers_type_requirements.cpp BUILD_OPTIONS -DSEGMENT_VECTOR_ARRAY_EXPSIZE)
	add_test_generic(NAME segment_vector_array_expsize_modifiers_type_requirements TRACERS none memcheck pmemcheck)

	build_test_ext(NAME segment_vector_array_expsize_std_arg SRC_FILES vector/vector_std_arg.cpp BUILD_OPTIONS -DSEGMENT_VECTOR_ARRAY_EXPSIZE)
	add_test_generic(NAME segment_vector_array_expsize_std_arg TRACERS none memcheck pmemcheck)

	build_test_ext(NAME segment_vector_array_expsize_parameters SRC_FILES vector/vector_parameters.cpp BUILD_OPTIONS -DSEGMENT_VECTOR_ARRAY_EXPSIZE)
	add_test_generic(NAME segment_vector_array_expsize_parameters TRACERS none memcheck pmemcheck)

	build_test_ext(NAME segment_vector_array_expsize_layout SRC_FILES vector/vector_layout.cpp BUILD_OPTIONS -DSEGMENT_VECTOR_ARRAY_EXPSIZE)
	add_test_generic(NAME segment_vector_array_expsize_layout TRACERS none)
endif()

if(TEST_SEGMENT_VECTOR_VECTOR_EXPSIZE)
	build_test_ext(NAME segment_vector_vector_expsize_temp_value SRC_FILES temp_value/temp_value.cpp BUILD_OPTIONS -DSEGMENT_VECTOR_VECTOR_EXPSIZE)
	add_test_generic(NAME segment_vector_vector_expsize_temp_value TRACERS none pmemcheck memcheck)

	build_test_ext(NAME segment_vector_vector_expsize_assign_exceptions_length SRC_FILES vector/vector_assign_exceptions_length.cpp BUILD_OPTIONS -DSEGMENT_VECTOR_VECTOR_EXPSIZE)
	add_test_generic(NAME segment_vector_vector_expsize_assign_exceptions_length TRACERS none memcheck pmemcheck)

	build_test_ext(NAME segment_vector_vector_expsize_assign_exceptions_oom SRC_FILES vector/vector_assign_exceptions_oom.cpp BUILD_OPTIONS -DSEGMENT_VECTOR_VECTOR_EXPSIZE)
	add_test_generic(NAME segment_vector_vector_expsize_assign_exceptions_oom TRACERS none memcheck pmemcheck)

	build_test_ext(NAME segment_vector_vector_expsize_assign_txabort SRC_FILES vector/vector_assign_txabort.cpp BUILD_OPTIONS -DSEGMENT_VECTOR_VECTOR_EXPSIZE)
	add_test_generic(NAME segment_vector_vector_expsize_assign_txabort TRACERS none memcheck pmemcheck)

	build_test_ext(NAME segment_vector_vector_expsize_comp_operators SRC_FILES vector/vector_comp_operators.cpp BUILD_OPTIONS -DSEGMENT_VECTOR_VECTOR_EXPSIZE)
	add_test_generic(NAME segment_vector_vector_expsize_comp_operators TRACERS none memcheck pmemcheck)

	build_test_ext(NAME segment_vector_vector_expsize_capacity_exceptions_length SRC_FILES vector/vector_capacity_exceptions_length.cpp BUILD_OPTIONS -DSEGMENT_VECTOR_VECTOR_EXPSIZE)
	add_test_generic(NAME segment_vector_vector_expsize_capacity_exceptions_length TRACERS none memcheck pmemcheck)

	build_test_ext(NAME segment_vector_vector_expsize_capacity_exceptions_oom SRC_FILES vector/vector_capacity_exceptions_oom.cpp BUILD_OPTIONS -DSEGMENT_VECTOR_VECTOR_EXPSIZE)
	add_test_generic(NAME segment_vector_vector_expsize_capacity_exceptions_oom TRACERS none memcheck pmemcheck)

	build_test_ext(NAME segment_vector_vector_expsize_capacity_txabort SRC_FILES vector/vector_capacity_txabort.cpp BUILD_OPTIONS -DSEGMENT_VECTOR_VECTOR_EXPSIZE)
	add_test_generic(NAME segment_vector_vector_expsize_capacity_txabort TRACERS none memcheck pmemcheck)

	build_test_ext(NAME segment_vector_vector_expsize_ctor_exceptions_nopmem SRC_FILES vector/vector_ctor_exceptions_nopmem.cpp BUILD_OPTIONS -DSEGMENT_VECTOR_VECTOR_EXPSIZE)
	add_test_generic(NAME segment_vector_vector_expsize_ctor_exceptions_nopmem TRACERS none memcheck )

	build_test_ext(NAME segment_vector_vector_expsize_ctor_exceptions_notx SRC_FILES vector/vector_ctor_exceptions_notx.cpp BUILD_OPTIONS -DSEGMENT_VECTOR_VECTOR_EXPSIZE)
	add_test_generic(NAME segment_vector_vector_expsize_ctor_exceptions_notx TRACERS none memcheck)

	build_test_ext(NAME segment_vector_vector_expsize_ctor_exceptions_oom SRC_FILES vector/vector_ctor_exceptions_oom.cpp BUILD_OPTIONS -DSEGMENT_VECTOR_VECTOR_EXPSIZE)
	add_test_generic(NAME segment_vector_vector_expsize_ctor_exceptions_oom TRACERS none memcheck pmemcheck)

	build_test_ext(NAME segment_vector_vector_expsize_ctor_move SRC_FILES vector/vector_ctor_move.cpp BUILD_OPTIONS -DSEGMENT_VECTOR_VECTOR_EXPSIZE)
	add_test_generic(NAME segment_vector_vector_expsize_ctor_move TRACERS none memcheck pmemcheck)

	build_test_ext(NAME segment_vector_vector_expsize_ctor_capacity SRC_FILES vector/vector_ctor_capacity.cpp BUILD_OPTIONS -DSEGMENT_VECTOR_VECTOR_EXPSIZE)
	add_test_generic(NAME segment_vector_vector_expsize_ctor_capacity TRACERS none memcheck pmemcheck)

	build_test_ext(NAME segment_vector_vector_expsize_dtor SRC_FILES vector/vector_dtor.cpp BUILD_OPTIONS -DSEGMENT_VECTOR_VECTOR_EXPSIZE)
	add_test_generic(NAME segment_vector_vector_expsize_dtor TRACERS none memcheck pmemcheck)

	build_test_ext(NAME segment_vector_vector_expsize_iterators_access SRC_FILES vector/vector_iterators_access.cpp BUILD_OPTIONS -DSEGMENT_VECTOR_VECTOR_EXPSIZE)
	add_test_generic(NAME segment_vector_vector_expsize_iterators_access TRACERS none memcheck pmemcheck)

	build_test_ext(NAME segment_vector_vector_expsize_ctor_check_copy SRC_FILES vector/vector_ctor_check_copy.cpp BUILD_OPTIONS -DSEGMENT_VECTOR_VECTOR_EXPSIZE)
	add_test_generic(NAME segment_vector_vector_expsize_ctor_check_copy TRACERS none memcheck pmemcheck)

	build_test_ext(NAME segment_vector_vector_expsize_modifiers_exceptions_oom SRC_FILES vector/vector_modifiers_exceptions_oom.cpp BUILD_OPTIONS -DSEGMENT_VECTOR_VECTOR_EXPSIZE)
	add_test_generic(NAME segment_vector_vector_expsize_modifiers_exceptions_oom TRACERS none memcheck pmemcheck)

	build_test_ext(NAME segment_vector_vector_expsize_modifiers_txabort SRC_FILES vector/vector_modifiers_txabort.cpp BUILD_OPTIONS -DSEGMENT_VECTOR_VECTOR_EXPSIZE)
	add_test_generic(NAME segment_vector_vector_expsize_modifiers_txabort TRACERS none memcheck pmemcheck)

	build_test_ext(NAME segment_vector_vector_expsize_modifiers_type_requirements SRC_FILES vector/vector_modifiers_type_requirements.cpp BUILD_OPTIONS -DSEGMENT_VECTOR_VECTOR_EXPSIZE)
	add_test_generic(NAME segment_vector_vector_expsize_modifiers_type_requirements TRACERS none memcheck pmemcheck)

	build_test_ext(NAME segment_vector_vector_expsize_std_arg SRC_FILES vector/vector_std_arg.cpp BUILD_OPTIONS -DSEGMENT_VECTOR_VECTOR_EXPSIZE)
	add_test_generic(NAME segment_vector_vector_expsize_std_arg TRACERS none memcheck pmemcheck)

	build_test_ext(NAME segment_vector_vector_expsize_parameters SRC_FILES vector/vector_parameters.cpp BUILD_OPTIONS -DSEGMENT_VECTOR_VECTOR_EXPSIZE)
	add_test_generic(NAME segment_vector_vector_expsize_parameters TRACERS none memcheck pmemcheck)

	build_test_ext(NAME segment_vector_vector_expsize_layout SRC_FILES vector/vector_layout.cpp BUILD_OPTIONS -DSEGMENT_VECTOR_VECTOR_EXPSIZE)
	add_test_generic(NAME segment_vector_vector_expsize_layout TRACERS none)
endif()

if(TEST_SEGMENT_VECTOR_VECTOR_FIXEDSIZE)
	build_test_ext(NAME segment_vector_vector_fixedsize_temp_value SRC_FILES temp_value/temp_value.cpp BUILD_OPTIONS -DSEGMENT_VECTOR_VECTOR_FIXEDSIZE)
	add_test_generic(NAME segment_vector_vector_fixedsize_temp_value TRACERS none pmemcheck memcheck)

	build_test_ext(NAME segment_vector_vector_fixedsize_assign_exceptions_length SRC_FILES vector/vector_assign_exceptions_length.cpp BUILD_OPTIONS -DSEGMENT_VECTOR_VECTOR_FIXEDSIZE)
	add_test_generic(NAME segment_vector_vector_fixedsize_assign_exceptions_length TRACERS none memcheck pmemcheck)

	build_test_ext(NAME segment_vector_vector_fixedsize_assign_exceptions_oom SRC_FILES vector/vector_assign_exceptions_oom.cpp BUILD_OPTIONS -DSEGMENT_VECTOR_VECTOR_FIXEDSIZE_EXT)
	add_test_generic(NAME segment_vector_vector_fixedsize_assign_exceptions_oom TRACERS none memcheck pmemcheck)

	build_test_ext(NAME segment_vector_vector_fixedsize_assign_txabort SRC_FILES vector/vector_assign_txabort.cpp BUILD_OPTIONS -DSEGMENT_VECTOR_VECTOR_FIXEDSIZE)
	add_test_generic(NAME segment_vector_vector_fixedsize_assign_txabort TRACERS none memcheck pmemcheck)

	build_test_ext(NAME segment_vector_vector_fixedsize_comp_operators SRC_FILES vector/vector_comp_operators.cpp BUILD_OPTIONS -DSEGMENT_VECTOR_VECTOR_FIXEDSIZE)
	add_test_generic(NAME segment_vector_vector_fixedsize_comp_operators TRACERS none memcheck pmemcheck)

	build_test_ext(NAME segment_vector_vector_fixedsize_capacity_exceptions_length SRC_FILES vector/vector_capacity_exceptions_length.cpp BUILD_OPTIONS -DSEGMENT_VECTOR_VECTOR_FIXEDSIZE)
	add_test_generic(NAME segment_vector_vector_fixedsize_capacity_exceptions_length TRACERS none memcheck pmemcheck)

	build_test_ext(NAME segment_vector_vector_fixedsize_capacity_exceptions_oom SRC_FILES vector/vector_capacity_exceptions_oom.cpp BUILD_OPTIONS -DSEGMENT_VECTOR_VECTOR_FIXEDSIZE_EXT)
	add_test_generic(NAME segment_vector_vector_fixedsize_capacity_exceptions_oom TRACERS none memcheck pmemcheck)

	build_test_ext(NAME segment_vector_vector_fixedsize_capacity_txabort SRC_FILES vector/vector_capacity_txabort.cpp BUILD_OPTIONS -DSEGMENT_VECTOR_VECTOR_FIXEDSIZE)
	add_test_generic(NAME segment_vector_vector_fixedsize_capacity_txabort TRACERS none memcheck pmemcheck)

	build_test_ext(NAME segment_vector_vector_fixedsize_ctor_exceptions_nopmem SRC_FILES vector/vector_ctor_exceptions_nopmem.cpp BUILD_OPTIONS -DSEGMENT_VECTOR_VECTOR_FIXEDSIZE)
	add_test_generic(NAME segment_vector_vector_fixedsize_ctor_exceptions_nopmem TRACERS none memcheck )

	build_test_ext(NAME segment_vector_vector_fixedsize_ctor_exceptions_notx SRC_FILES vector/vector_ctor_exceptions_notx.cpp BUILD_OPTIONS -DSEGMENT_VECTOR_VECTOR_FIXEDSIZE)
	add_test_generic(NAME segment_vector_vector_fixedsize_ctor_exceptions_notx TRACERS none memcheck)

	build_test_ext(NAME segment_vector_vector_fixedsize_ctor_exceptions_oom SRC_FILES vector/vector_ctor_exceptions_oom.cpp BUILD_OPTIONS -DSEGMENT_VECTOR_VECTOR_FIXEDSIZE)
	add_test_generic(NAME segment_vector_vector_fixedsize_ctor_exceptions_oom TRACERS none memcheck) # XXX: pmemcheck timeouts

	build_test_ext(NAME segment_vector_vector_fixedsize_ctor_move SRC_FILES vector/vector_ctor_move.cpp BUILD_OPTIONS -DSEGMENT_VECTOR_VECTOR_FIXEDSIZE)
	add_test_generic(NAME segment_vector_vector_fixedsize_ctor_move TRACERS none memcheck pmemcheck)

	build_test_ext(NAME segment_vector_vector_fixedsize_ctor_capacity SRC_FILES vector/vector_ctor_capacity.cpp BUILD_OPTIONS -DSEGMENT_VECTOR_VECTOR_FIXEDSIZE)
	add_test_generic(NAME segment_vector_vector_fixedsize_ctor_capacity TRACERS none memcheck pmemcheck)

	build_test_ext(NAME segment_vector_vector_fixedsize_dtor SRC_FILES vector/vector_dtor.cpp BUILD_OPTIONS -DSEGMENT_VECTOR_VECTOR_FIXEDSIZE)
	add_test_generic(NAME segment_vector_vector_fixedsize_dtor TRACERS none memcheck pmemcheck)

	build_test_ext(NAME segment_vector_vector_fixedsize_iterators_access SRC_FILES vector/vector_iterators_access.cpp BUILD_OPTIONS -DSEGMENT_VECTOR_VECTOR_FIXEDSIZE)
	add_test_generic(NAME segment_vector_vector_fixedsize_iterators_access TRACERS none memcheck pmemcheck)

	build_test_ext(NAME segment_vector_vector_fixedsize_ctor_check_copy SRC_FILES vector/vector_ctor_check_copy.cpp BUILD_OPTIONS -DSEGMENT_VECTOR_VECTOR_FIXEDSIZE)
	add_test_generic(NAME segment_vector_vector_fixedsize_ctor_check_copy TRACERS none memcheck pmemcheck)

	build_test_ext(NAME segment_vector_vector_fixedsize_modifiers_exceptions_oom SRC_FILES vector/vector_modifiers_exceptions_oom.cpp BUILD_OPTIONS -DSEGMENT_VECTOR_VECTOR_FIXEDSIZE_EXT)
	add_test_generic(NAME segment_vector_vector_fixedsize_modifiers_exceptions_oom TRACERS none memcheck pmemcheck)

	build_test_ext(NAME segment_vector_vector_fixedsize_modifiers_txabort SRC_FILES vector/vector_modifiers_txabort.cpp BUILD_OPTIONS -DSEGMENT_VECTOR_VECTOR_FIXEDSIZE)
	add_test_generic(NAME segment_vector_vector_fixedsize_modifiers_txabort TRACERS none memcheck pmemcheck)

	build_test_ext(NAME segment_vector_vector_fixedsize_modifiers_type_requirements SRC_FILES vector/vector_modifiers_type_requirements.cpp BUILD_OPTIONS -DSEGMENT_VECTOR_VECTOR_FIXEDSIZE)
	add_test_generic(NAME segment_vector_vector_fixedsize_modifiers_type_requirements TRACERS none memcheck pmemcheck)

	build_test_ext(NAME segment_vector_vector_fixedsize_std_arg SRC_FILES vector/vector_std_arg.cpp BUILD_OPTIONS -DSEGMENT_VECTOR_VECTOR_FIXEDSIZE)
	add_test_generic(NAME segment_vector_vector_fixedsize_std_arg TRACERS none memcheck pmemcheck)

	build_test_ext(NAME segment_vector_vector_fixedsize_parameters SRC_FILES vector/vector_parameters.cpp BUILD_OPTIONS -DSEGMENT_VECTOR_VECTOR_FIXEDSIZE)
	add_test_generic(NAME segment_vector_vector_fixedsize_parameters TRACERS none memcheck pmemcheck)

	build_test_ext(NAME segment_vector_vector_fixedsize_layout SRC_FILES vector/vector_layout.cpp BUILD_OPTIONS -DSEGMENT_VECTOR_VECTOR_FIXEDSIZE)
	add_test_generic(NAME segment_vector_vector_fixedsize_layout TRACERS none)
endif()
################################################################################
########################### ENUMERABLE_THREAD_SPECIFIC #########################
if(TEST_ENUMERABLE_THREAD_SPECIFIC)
	build_test(enumerable_thread_specific_access enumerable_thread_specific/enumerable_thread_specific_access.cpp)
	add_test_generic(NAME enumerable_thread_specific_access CASE 0 TRACERS none memcheck pmemcheck drd helgrind
			SCRIPT concurrent_hash_map/check_is_pmem.cmake)

	build_test(enumerable_thread_specific_size enumerable_thread_specific/enumerable_thread_specific_size.cpp)
	add_test_generic(NAME enumerable_thread_specific_size CASE 0 TRACERS none memcheck pmemcheck drd helgrind
			SCRIPT concurrent_hash_map/check_is_pmem.cmake)

	build_test(enumerable_thread_specific_iterators enumerable_thread_specific/enumerable_thread_specific_iterators.cpp)
	add_test_generic(NAME enumerable_thread_specific_iterators CASE 0 TRACERS none memcheck pmemcheck drd helgrind
			SCRIPT concurrent_hash_map/check_is_pmem.cmake)

	build_test(enumerable_thread_specific_layout enumerable_thread_specific/enumerable_thread_specific_layout.cpp)
	add_test_generic(NAME enumerable_thread_specific_layout TRACERS none)

	build_test(enumerable_thread_specific_initialize enumerable_thread_specific/enumerable_thread_specific_initialize.cpp)
	add_test_generic(NAME enumerable_thread_specific_initialize CASE 0 TRACERS none memcheck pmemcheck
			SCRIPT concurrent_hash_map/check_is_pmem.cmake)

	build_test(enumerable_thread_specific_ctor enumerable_thread_specific/enumerable_thread_specific_ctor.cpp)
	add_test_generic(NAME enumerable_thread_specific_ctor CASE 0 TRACERS none memcheck pmemcheck
			SCRIPT concurrent_hash_map/check_is_pmem.cmake)
endif()
################################################################################
################################## CONCURRENT_MAP ##############################
if(TEST_CONCURRENT_MAP)
	build_test(concurrent_map concurrent_map/concurrent_map.cpp)
	# XXX: Add helgrind tracer for this test when we will fix false-positive with lock order
	add_test_generic(NAME concurrent_map TRACERS none memcheck pmemcheck drd)

	build_test(concurrent_map_singlethread concurrent_map/concurrent_map_singlethread.cpp)
	add_test_generic(NAME concurrent_map_singlethread TRACERS none memcheck pmemcheck)

	build_test(concurrent_map_tx concurrent_map/concurrent_map_tx.cpp)
	add_test_generic(NAME concurrent_map_tx TRACERS none memcheck pmemcheck)

	# XXX: Fix concurrent_map exceptions
	# build_test_ext(NAME concurrent_map_ctor_exceptions_nopmem SRC_FILES map/map_ctor_exception_nopmem.cpp BUILD_OPTIONS -DLIBPMEMOBJ_CPP_TESTS_CONCURRENT_MAP)
	# add_test_generic(NAME concurrent_map_ctor_exceptions_nopmem TRACERS none memcheck pmemcheck)

	build_test_ext(NAME concurrent_map_ctor_exceptions_notx SRC_FILES map/map_ctor_exception_notx.cpp BUILD_OPTIONS -DLIBPMEMOBJ_CPP_TESTS_CONCURRENT_MAP)
	add_test_generic(NAME concurrent_map_ctor_exceptions_notx TRACERS none memcheck)

	build_test_ext(NAME concurrent_map_txabort SRC_FILES map/map_txabort.cpp BUILD_OPTIONS -DLIBPMEMOBJ_CPP_TESTS_CONCURRENT_MAP)
	add_test_generic(NAME concurrent_map_txabort TRACERS none memcheck pmemcheck)

	build_test_ext(NAME concurrent_map_ctor_and_assignment SRC_FILES map/map_ctor_and_assignment.cpp BUILD_OPTIONS -DLIBPMEMOBJ_CPP_TESTS_CONCURRENT_MAP)
	add_test_generic(NAME concurrent_map_ctor_and_assignment TRACERS none memcheck pmemcheck)

	build_test_ext(NAME concurrent_map_find_lower_lower_eq SRC_FILES map/map_find_lower_lower_eq.cpp BUILD_OPTIONS -DLIBPMEMOBJ_CPP_TESTS_CONCURRENT_MAP)
	add_test_generic(NAME concurrent_map_find_lower_lower_eq TRACERS none memcheck pmemcheck)

	if(TESTS_CONCURRENT_GDB AND GDB_FOUND)
		# This test is confirmed to run on gcc (and not on clang)
		if(DEBUG_BUILD_TESTS AND GCC_COMPILER_IN_USE)
			build_test(concurrent_map_mt_gdb concurrent_map_mt_gdb/concurrent_map_mt_gdb.cpp)
			add_test_generic(NAME concurrent_map_mt_gdb TRACERS none CASE 0 SCRIPT concurrent_map_mt_gdb/concurrent_map_mt_gdb_0.cmake)
			add_test_generic(NAME concurrent_map_mt_gdb TRACERS none CASE 1 SCRIPT concurrent_map_mt_gdb/concurrent_map_mt_gdb_1.cmake)
			add_test_generic(NAME concurrent_map_mt_gdb TRACERS none CASE 2 SCRIPT concurrent_map_mt_gdb/concurrent_map_mt_gdb_2.cmake)
		elseif(NOT DEBUG_BUILD_TESTS)
			message(WARNING "TESTS_CONCURRENT_GDB is set, but it's a non-debug build - concurrent_map_mt_gdb test will be skipped.")
		else()
			message(WARNING "TESTS_CONCURRENT_GDB is set, but current compiler is not gcc (concurrent_map_mt_gdb seems to work only with it). Skipping.")
		endif()
	endif()

	build_test(concurrent_map_insert_reopen concurrent_map/concurrent_map_insert_reopen.cpp)
	# XXX: Add helgrind tracer for this test when we will fix false-positive with lock order
	# XXX: Add drd tracer after issue https://github.com/pmem/libpmemobj-cpp/issues/770 will be resolved
	add_test_generic(NAME concurrent_map_insert_reopen CASE 0 TRACERS none memcheck pmemcheck
			SCRIPT concurrent_hash_map/check_is_pmem.cmake)

	if(PMREORDER_SUPPORTED)
		build_test(concurrent_map_pmreorder_simple concurrent_map/concurrent_map_pmreorder_simple.cpp)
		add_test_generic(NAME concurrent_map_pmreorder_simple CASE 0 TRACERS none
				SCRIPT cmake/pmreorder.cmake)
		build_test(concurrent_map_pmreorder_erase concurrent_map_pmreorder_erase/concurrent_map_pmreorder_erase.cpp)
		add_test_generic(NAME concurrent_map_pmreorder_erase CASE 0 TRACERS none)

		if(GDB_FOUND)
			set(TEST concurrent_map_pmreorder_break_insert)
			build_test(${TEST} concurrent_map/concurrent_map_pmreorder_simple.cpp)

			# add 5 concurrent_map_pmreorder_break_insert test cases
			set(CURRENT_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/${TEST})
			set(CMAKE_SCRIPT ${CURRENT_TEST_DIR}/${TEST})
			set(GDB_SCRIPT ${CURRENT_TEST_DIR}/break_before_set_next)
			foreach(case RANGE 4)
				math(EXPR IGNORE "${case} + 1")
				math(EXPR PERSIST "${case} + 2")
				configure_file("${GDB_SCRIPT}.gdb.in" "${GDB_SCRIPT}_${PERSIST}.gdb" @ONLY)
				configure_file("${CMAKE_SCRIPT}.cmake.in" "${CMAKE_SCRIPT}_${case}.cmake" @ONLY)
				add_test_generic(NAME ${TEST} CASE ${case} TRACERS none)
			endforeach()
		endif()
	endif()
endif()

################################################################################
#################################### MPSC_QUEUE ################################
if(TEST_MPSC_QUEUE)
	# Test for internal implementation of ringbuffer
	build_test(ringbuf mpsc_queue/ringbuf.cpp)
	add_test_generic(NAME ringbuf TRACERS none memcheck drd helgrind)

	# XXX: debug this test
	# build_test(mpsc_queue_mt mpsc_queue/mt.cpp)
	# add_test_generic(NAME mpsc_queue_mt TRACERS none drd helgrind memcheck pmemcheck)

	build_test(mpsc_queue_consume_multipass mpsc_queue/consume_multipass.cpp)
	add_test_generic(NAME mpsc_queue_consume_multipass TRACERS none memcheck pmemcheck)

	build_test(mpsc_queue_consume_interrupt mpsc_queue/consume_interrupt.cpp)
	add_test_generic(NAME mpsc_queue_consume_interrupt SCRIPT mpsc_queue/mpsc_queue_consume_interrupt.cmake TRACERS none memcheck pmemcheck)

	build_test(mpsc_queue_basic mpsc_queue/basic.cpp)
	add_test_generic(NAME mpsc_queue_basic SCRIPT mpsc_queue/basic.cmake TRACERS none memcheck pmemcheck)

	build_test(mpsc_queue_empty mpsc_queue/empty.cpp)
	add_test_generic(NAME mpsc_queue_empty TRACERS none memcheck pmemcheck)

	build_test(mpsc_queue_recovery_order mpsc_queue/recovery_order.cpp)
	add_test_generic(NAME mpsc_queue_recovery_order SCRIPT mpsc_queue/recovery_order.cmake TRACERS none memcheck pmemcheck)

	if(PMREORDER_SUPPORTED)
		build_test(mpsc_queue_recovery_pmreorder mpsc_queue/pmreorder/recovery.cpp)
		add_test_generic(NAME mpsc_queue_recovery_pmreorder CASE 0 SCRIPT mpsc_queue/pmreorder/recovery_0.cmake TRACERS none)
		add_test_generic(NAME mpsc_queue_recovery_pmreorder CASE 1 SCRIPT mpsc_queue/pmreorder/recovery_1.cmake TRACERS none)
		add_test_generic(NAME mpsc_queue_recovery_pmreorder CASE 2 SCRIPT mpsc_queue/pmreorder/recovery_2.cmake TRACERS none)
		add_test_generic(NAME mpsc_queue_recovery_pmreorder CASE 3 SCRIPT mpsc_queue/pmreorder/recovery_3.cmake TRACERS none)

		build_test(mpsc_queue_recovery_after_consume_pmreorder mpsc_queue/pmreorder/recovery_after_consume.cpp)
		add_test_generic(NAME mpsc_queue_recovery_after_consume_pmreorder SCRIPT mpsc_queue/pmreorder/recovery_after_consume.cmake TRACERS none)
	endif()
endif()
################################################################################
#################################### RADIX_TREE ################################
if(TEST_RADIX_TREE)
	build_test(radix_tx_abort radix_tree/radix_tx_abort.cpp)
	add_test_generic(NAME radix_tx_abort TRACERS none memcheck pmemcheck)

	build_test(radix_basic radix_tree/radix_basic.cpp)
	add_test_generic(NAME radix_basic TRACERS none memcheck pmemcheck)

	build_test_ext(NAME radix_concurrent SRC_FILES radix_tree/radix_concurrent.cpp)
	add_test_generic(NAME radix_concurrent TRACERS none memcheck pmemcheck drd helgrind)

	build_test_ext(NAME radix_concurrent_iterate SRC_FILES radix_tree/radix_concurrent_iterate.cpp)
	add_test_generic(NAME radix_concurrent_iterate TRACERS none memcheck pmemcheck drd helgrind)

	build_test_ext(NAME radix_concurrent_overwrite SRC_FILES radix_tree/radix_concurrent_overwrite.cpp)
	add_test_generic(NAME radix_concurrent_overwrite TRACERS none memcheck pmemcheck drd helgrind)

	build_test_ext(NAME radix_concurrent_erase SRC_FILES radix_tree/radix_concurrent_erase.cpp)
	add_test_generic(NAME radix_concurrent_erase TRACERS none memcheck pmemcheck drd helgrind)

	build_test_ext(NAME radix_ctor_exceptions_nopmem SRC_FILES map/map_ctor_exception_nopmem.cpp BUILD_OPTIONS -DLIBPMEMOBJ_CPP_TESTS_RADIX)
	add_test_generic(NAME radix_ctor_exceptions_nopmem TRACERS none memcheck pmemcheck)

	build_test_ext(NAME radix_ctor_exceptions_notx SRC_FILES map/map_ctor_exception_notx.cpp BUILD_OPTIONS -DLIBPMEMOBJ_CPP_TESTS_RADIX)
	add_test_generic(NAME radix_ctor_exceptions_notx TRACERS none memcheck)

	build_test_ext(NAME radix_garbage_collection SRC_FILES radix_tree/radix_garbage_collection.cpp)
	add_test_generic(NAME radix_garbage_collection TRACERS none memcheck)

	build_test_ext(NAME radix_txabort SRC_FILES map/map_txabort.cpp BUILD_OPTIONS -DLIBPMEMOBJ_CPP_TESTS_RADIX)
	add_test_generic(NAME radix_txabort TRACERS none memcheck pmemcheck)

	build_test_ext(NAME radix_ctor_and_assignment SRC_FILES map/map_ctor_and_assignment.cpp BUILD_OPTIONS -DLIBPMEMOBJ_CPP_TESTS_RADIX)
	add_test_generic(NAME radix_ctor_and_assignment TRACERS none memcheck pmemcheck)

	if(TESTS_LONG)
		build_test(radix_large radix_tree/radix_large.cpp)
		add_test_generic(NAME radix_large TRACERS none)
	endif()
endif()
################################################################################
