11#AddCephTest is a module for adding tests to the "make check" target which runs CTest
22
3+ macro (set_test_props labels cost cost_default timeout )
4+ if (DEFINED timeout )
5+ set_property (TEST ${test_name} PROPERTY TIMEOUT ${timeout} )
6+ else ()
7+ set_property (TEST ${test_name} PROPERTY TIMEOUT ${CEPH_TEST_TIMEOUT} )
8+ endif ()
9+ if (DEFINED cost )
10+ set_property (TEST ${test_name} PROPERTY COST ${cost} )
11+ else ()
12+ set_property (TEST ${test_name} PROPERTY COST ${cost_default} )
13+ endif ()
14+ if (DEFINED labels )
15+ set_property (TEST ${test_name} PROPERTY LABELS ${labels} )
16+ endif ()
17+ endmacro ()
18+
319#adds makes target/script into a test, test to check target, sets necessary environment variables
420function (add_ceph_test test_name test_path)
5- add_test (NAME ${test_name} COMMAND ${test_path} ${ARGN} )
21+ set (options "" )
22+ set (oneValueArgs COST TIMEOUT )
23+ set (multiValueArgs LABELS )
24+ cmake_parse_arguments (PROPS "${options} " "${oneValueArgs} "
25+ "${multiValueArgs} " ${ARGN} )
26+
27+ add_test (NAME ${test_name} COMMAND ${test_path} ${PROPS_UNPARSED_ARGUMENTS} )
628 if (TARGET ${test_name} )
729 add_dependencies (tests ${test_name} )
830 endif ()
@@ -17,10 +39,7 @@ function(add_ceph_test test_name test_path)
1739 PATH =${CMAKE_RUNTIME_OUTPUT_DIRECTORY} :${CMAKE_SOURCE_DIR} /src:$ENV{PATH}
1840 PYTHONPATH=${CMAKE_LIBRARY_OUTPUT_DIRECTORY} /cython_modules/lib.${Python${PYTHON_VERSION} _VERSION_MAJOR}:${CMAKE_SOURCE_DIR} /src/pybind
1941 CEPH_BUILD_VIRTUALENV=${CEPH_BUILD_VIRTUALENV} )
20- # none of the tests should take more than 1 hour to complete
21- set_property (TEST
22- ${test_name}
23- PROPERTY TIMEOUT ${CEPH_TEST_TIMEOUT} )
42+ set_test_props("${PROPS_LABELS} " "${PROPS_COST} " 5.0 "${PROPS_TIMEOUT} " )
2443endfunction ()
2544
2645option (WITH_GTEST_PARALLEL "Enable running gtest based tests in parallel" OFF )
@@ -44,19 +63,21 @@ endif()
4463
4564#sets uniform compiler flags and link libraries
4665function (add_ceph_unittest unittest_name)
66+ cmake_parse_arguments (PROPS "" "COST;TIMEOUT" "LABELS" ${ARGN} )
4767 set (UNITTEST "${CMAKE_RUNTIME_OUTPUT_DIRECTORY} /${unittest_name} " )
4868 # If the second argument is "parallel", it means we want a parallel run
4969 if (WITH_GTEST_PARALLEL AND "${ARGV1} " STREQUAL "parallel" )
5070 set (UNITTEST ${GTEST_PARALLEL_COMMAND} ${UNITTEST} )
5171 endif ()
52- add_ceph_test(${unittest_name} "${UNITTEST} " )
72+ add_ceph_test(${unittest_name} "${UNITTEST} " "unittest" LABELS "unittest" )
5373 target_link_libraries (${unittest_name} ${UNITTEST_LIBS} )
74+ set_test_props("${PROPS_LABELS} " "${PROPS_COST} " 1.0 "${PROPS_TIMEOUT} " )
5475endfunction ()
5576
5677function (add_tox_test name )
5778 set (test_name run-tox-${name} )
5879 set (venv_path ${CEPH_BUILD_VIRTUALENV} /${name} -virtualenv)
59- cmake_parse_arguments (TOXTEST "" "TOX_PATH" "TOX_ENVS" ${ARGN} )
80+ cmake_parse_arguments (TOXTEST "" "TOX_PATH;COST;TIMEOUT " "TOX_ENVS;LABELS " ${ARGN} )
6081 if (DEFINED TOXTEST_TOX_PATH)
6182 set (tox_path ${TOXTEST_TOX_PATH} )
6283 else ()
@@ -99,4 +120,6 @@ function(add_tox_test name)
99120 PATH =${CMAKE_RUNTIME_OUTPUT_DIRECTORY} :${CMAKE_SOURCE_DIR} /src:$ENV{PATH}
100121 PYTHONPATH=${CMAKE_SOURCE_DIR} /src/pybind)
101122 list (APPEND tox_test run-tox-${name} )
123+ set_tests_properties (${test_name} PROPERTIES LABELS "tox" )
124+ set_test_props("${TOXTEST_LABELS} " "${TOXTEST_COST} " 25.0 "${TOXTEST_TIMEOUT} " )
102125endfunction ()
0 commit comments