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)
|
2016-07-26 20:23:52 +00:00
|
|
|
add_test(NAME ${test_name} COMMAND ${test_path} ${ARGN})
|
2018-04-26 08:44:07 +00:00
|
|
|
if(TARGET ${test_name})
|
|
|
|
add_dependencies(tests ${test_name})
|
|
|
|
endif()
|
2016-07-13 13:14:30 +00:00
|
|
|
set_property(TEST
|
2016-01-26 20:45:15 +00:00
|
|
|
${test_name}
|
|
|
|
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}
|
2016-07-13 12:57:30 +00:00
|
|
|
PYTHONPATH=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cython_modules/lib.${PYTHON${PYTHON_VERSION}_VERSION_MAJOR}:${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
|
|
|
|
set_property(TEST
|
|
|
|
${test_name}
|
|
|
|
PROPERTY TIMEOUT 3600)
|
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)
|
2018-07-07 09:10:23 +00:00
|
|
|
set(gtest_parallel_source_dir ${CMAKE_CURRENT_BINARY_DIR}/gtest-parallel)
|
2018-06-15 05:54:31 +00:00
|
|
|
include(ExternalProject)
|
|
|
|
ExternalProject_Add(gtest-parallel_ext
|
2018-07-07 09:10:23 +00:00
|
|
|
SOURCE_DIR "${gtest_parallel_source_dir}"
|
2018-06-15 05:54:31 +00:00
|
|
|
GIT_REPOSITORY "https://github.com/google/gtest-parallel.git"
|
|
|
|
GIT_TAG "master"
|
|
|
|
CONFIGURE_COMMAND ""
|
|
|
|
BUILD_COMMAND ""
|
|
|
|
INSTALL_COMMAND "")
|
|
|
|
add_dependencies(tests gtest-parallel_ext)
|
2018-07-07 09:10:23 +00:00
|
|
|
find_package(PythonInterp 2.7 REQUIRED)
|
|
|
|
set(GTEST_PARALLEL_COMMAND
|
|
|
|
${PYTHON_EXECUTABLE} ${gtest_parallel_source_dir}/gtest-parallel)
|
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}")
|
|
|
|
# If the second argument is "parallel", it means we want a parallel run
|
2018-06-15 05:54:31 +00:00
|
|
|
if(WITH_GTEST_PARALLEL AND "${ARGV1}" STREQUAL "parallel")
|
2018-07-07 09:10:23 +00:00
|
|
|
set(UNITTEST ${GTEST_PARALLEL_COMMAND} ${UNITTEST})
|
2018-06-14 13:24:07 +00:00
|
|
|
endif()
|
|
|
|
add_ceph_test(${unittest_name} "${UNITTEST}")
|
2016-01-26 20:45:15 +00:00
|
|
|
target_link_libraries(${unittest_name} ${UNITTEST_LIBS})
|
|
|
|
set_target_properties(${unittest_name} PROPERTIES COMPILE_FLAGS ${UNITTEST_CXX_FLAGS})
|
|
|
|
endfunction()
|