2016-01-26 20:45:15 +00:00
|
|
|
#AddCephTest is a module for adding tests to the "make check" target which runs CTest
|
|
|
|
|
|
|
|
#adds makes target/script into a test, test to check target, sets necessary environment variables
|
|
|
|
function(add_ceph_test test_name test_path)
|
2021-08-19 09:24:32 +00:00
|
|
|
add_test(NAME ${test_name} COMMAND ${test_path} ${ARGN}
|
|
|
|
COMMAND_EXPAND_LISTS)
|
2018-04-26 08:44:07 +00:00
|
|
|
if(TARGET ${test_name})
|
|
|
|
add_dependencies(tests ${test_name})
|
2020-12-10 06:54:10 +00:00
|
|
|
set_property(TARGET ${test_name}
|
|
|
|
PROPERTY EXCLUDE_FROM_ALL TRUE)
|
2018-04-26 08:44:07 +00:00
|
|
|
endif()
|
2020-12-10 06:54:10 +00:00
|
|
|
set_property(TEST ${test_name}
|
2016-01-26 20:45:15 +00:00
|
|
|
PROPERTY ENVIRONMENT
|
|
|
|
CEPH_ROOT=${CMAKE_SOURCE_DIR}
|
|
|
|
CEPH_BIN=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
|
|
|
|
CEPH_LIB=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
|
2016-01-26 20:32:05 +00:00
|
|
|
CEPH_BUILD_DIR=${CMAKE_BINARY_DIR}
|
2016-01-26 20:45:15 +00:00
|
|
|
LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib
|
|
|
|
PATH=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}:${CMAKE_SOURCE_DIR}/src:$ENV{PATH}
|
2019-12-18 09:12:52 +00:00
|
|
|
PYTHONPATH=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cython_modules/lib.3:${CMAKE_SOURCE_DIR}/src/pybind
|
2016-05-10 13:50:17 +00:00
|
|
|
CEPH_BUILD_VIRTUALENV=${CEPH_BUILD_VIRTUALENV})
|
2016-07-14 07:59:14 +00:00
|
|
|
# none of the tests should take more than 1 hour to complete
|
2020-12-10 06:54:10 +00:00
|
|
|
set_property(TEST ${test_name}
|
2018-07-02 20:40:38 +00:00
|
|
|
PROPERTY TIMEOUT ${CEPH_TEST_TIMEOUT})
|
2016-01-26 20:45:15 +00:00
|
|
|
endfunction()
|
|
|
|
|
2018-06-15 05:54:31 +00:00
|
|
|
option(WITH_GTEST_PARALLEL "Enable running gtest based tests in parallel" OFF)
|
|
|
|
if(WITH_GTEST_PARALLEL)
|
2019-08-05 01:41:28 +00:00
|
|
|
if(NOT TARGET gtest-parallel_ext)
|
|
|
|
set(gtest_parallel_source_dir ${CMAKE_CURRENT_BINARY_DIR}/gtest-parallel)
|
|
|
|
include(ExternalProject)
|
|
|
|
ExternalProject_Add(gtest-parallel_ext
|
|
|
|
SOURCE_DIR "${gtest_parallel_source_dir}"
|
|
|
|
GIT_REPOSITORY "https://github.com/google/gtest-parallel.git"
|
|
|
|
GIT_TAG "master"
|
2020-11-05 16:16:45 +00:00
|
|
|
GIT_SHALLOW TRUE
|
2019-08-05 01:41:28 +00:00
|
|
|
CONFIGURE_COMMAND ""
|
|
|
|
BUILD_COMMAND ""
|
|
|
|
INSTALL_COMMAND "")
|
|
|
|
add_dependencies(tests gtest-parallel_ext)
|
|
|
|
set(GTEST_PARALLEL_COMMAND
|
2019-12-18 09:08:21 +00:00
|
|
|
${Python3_EXECUTABLE} ${gtest_parallel_source_dir}/gtest-parallel)
|
2019-08-05 01:41:28 +00:00
|
|
|
endif()
|
2018-06-15 05:54:31 +00:00
|
|
|
endif()
|
|
|
|
|
2016-01-26 20:45:15 +00:00
|
|
|
#sets uniform compiler flags and link libraries
|
2017-10-03 13:15:50 +00:00
|
|
|
function(add_ceph_unittest unittest_name)
|
2018-06-14 13:24:07 +00:00
|
|
|
set(UNITTEST "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${unittest_name}")
|
2021-03-30 08:17:14 +00:00
|
|
|
cmake_parse_arguments(UT "PARALLEL" "" "" ${ARGN})
|
|
|
|
if(WITH_GTEST_PARALLEL AND UT_PARALLEL)
|
2018-07-07 09:10:23 +00:00
|
|
|
set(UNITTEST ${GTEST_PARALLEL_COMMAND} ${UNITTEST})
|
2018-06-14 13:24:07 +00:00
|
|
|
endif()
|
2021-03-30 08:18:48 +00:00
|
|
|
add_ceph_test(${unittest_name} "${UNITTEST}" ${UT_UNPARSED_ARGUMENTS})
|
2016-01-26 20:45:15 +00:00
|
|
|
target_link_libraries(${unittest_name} ${UNITTEST_LIBS})
|
|
|
|
endfunction()
|
2019-08-01 11:40:36 +00:00
|
|
|
|
2019-08-05 15:37:52 +00:00
|
|
|
function(add_tox_test name)
|
2019-08-01 11:40:36 +00:00
|
|
|
set(test_name run-tox-${name})
|
2019-08-04 06:31:03 +00:00
|
|
|
set(venv_path ${CEPH_BUILD_VIRTUALENV}/${name}-virtualenv)
|
2019-08-05 15:37:52 +00:00
|
|
|
cmake_parse_arguments(TOXTEST "" "TOX_PATH" "TOX_ENVS" ${ARGN})
|
|
|
|
if(DEFINED TOXTEST_TOX_PATH)
|
|
|
|
set(tox_path ${TOXTEST_TOX_PATH})
|
|
|
|
else()
|
|
|
|
set(tox_path ${CMAKE_CURRENT_SOURCE_DIR})
|
|
|
|
endif()
|
|
|
|
if(DEFINED TOXTEST_TOX_ENVS)
|
2019-07-19 16:10:49 +00:00
|
|
|
list(APPEND tox_envs ${TOXTEST_TOX_ENVS})
|
2020-10-09 05:55:39 +00:00
|
|
|
else()
|
|
|
|
list(APPEND tox_envs py3)
|
2019-08-05 15:37:52 +00:00
|
|
|
endif()
|
|
|
|
string(REPLACE ";" "," tox_envs "${tox_envs}")
|
2021-03-19 09:26:37 +00:00
|
|
|
add_test(
|
|
|
|
NAME setup-venv-for-${name}
|
|
|
|
COMMAND ${CMAKE_SOURCE_DIR}/src/tools/setup-virtualenv.sh --python=${Python3_EXECUTABLE} ${venv_path}
|
|
|
|
WORKING_DIRECTORY ${tox_path})
|
|
|
|
set_tests_properties(setup-venv-for-${name} PROPERTIES
|
|
|
|
FIXTURES_SETUP venv-for-${name})
|
|
|
|
add_test(
|
|
|
|
NAME teardown-venv-for-${name}
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E remove_directory ${venv_path})
|
|
|
|
set_tests_properties(teardown-venv-for-${name} PROPERTIES
|
|
|
|
FIXTURES_CLEANUP venv-for-${name})
|
2019-08-01 11:40:36 +00:00
|
|
|
add_test(
|
|
|
|
NAME ${test_name}
|
|
|
|
COMMAND ${CMAKE_SOURCE_DIR}/src/script/run_tox.sh
|
|
|
|
--source-dir ${CMAKE_SOURCE_DIR}
|
|
|
|
--build-dir ${CMAKE_BINARY_DIR}
|
|
|
|
--tox-path ${tox_path}
|
2019-08-05 15:37:52 +00:00
|
|
|
--tox-envs ${tox_envs}
|
2019-08-04 06:31:03 +00:00
|
|
|
--venv-path ${venv_path})
|
2021-03-19 09:26:37 +00:00
|
|
|
set_tests_properties(${test_name} PROPERTIES
|
|
|
|
FIXTURES_REQUIRED venv-for-${name})
|
2019-08-01 11:40:36 +00:00
|
|
|
set_property(
|
|
|
|
TEST ${test_name}
|
|
|
|
PROPERTY ENVIRONMENT
|
|
|
|
CEPH_ROOT=${CMAKE_SOURCE_DIR}
|
|
|
|
CEPH_BIN=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
|
|
|
|
CEPH_LIB=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
|
|
|
|
CEPH_BUILD_VIRTUALENV=${CEPH_BUILD_VIRTUALENV}
|
|
|
|
LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib
|
2022-08-18 11:37:31 +00:00
|
|
|
PATH=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}:${CMAKE_SOURCE_DIR}/src:${CMAKE_CURRENT_BINARY_DIR}:$ENV{PATH}
|
2019-08-01 11:40:36 +00:00
|
|
|
PYTHONPATH=${CMAKE_SOURCE_DIR}/src/pybind)
|
|
|
|
list(APPEND tox_test run-tox-${name})
|
|
|
|
endfunction()
|