Skip to content

Commit

Permalink
cmake: add a "tests" target to build tests
Browse files Browse the repository at this point in the history
please note "make test" is used by cmake to run tests, so we cannot just
repurpose it to *build* them.

* AddCephTest.cmake: depends on "tests"
* CMakeLists.txt: let "check" depend on "tests"
* src/CMakeLists.txt: update the run-tox tests
* run-make-check.sh: use "make tests" and "ctest" instead of "make check"
* ceph-detect-init/CMakeLists.txt: let "tests" depend on
    "ceph-detect-init"
* ceph-disk/CMakeLists.txt: let "tests" depend on "ceph-disk"

Signed-off-by: Kefu Chai <kchai@redhat.com>
  • Loading branch information
tchaikov committed Jul 16, 2016
1 parent 3be6e1c commit ce5724e
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 6 deletions.
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -382,9 +382,13 @@ set(OperatingSystem "Mac OS X")
endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")

# enables testing and creates Make check command
add_custom_target(tests
COMMENT "Building tests")
enable_testing()
set(CMAKE_CTEST_COMMAND ctest)
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND})
add_custom_target(check
COMMAND ${CMAKE_CTEST_COMMAND}
DEPENDS tests)

add_subdirectory(src)

Expand Down
4 changes: 2 additions & 2 deletions cmake/modules/AddCephTest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
#adds makes target/script into a test, test to check target, sets necessary environment variables
function(add_ceph_test test_name test_path)
add_test(NAME ${test_name} COMMAND ${test_path})
add_dependencies(check ${test_name})
set_property(TEST
add_dependencies(tests ${test_name})
set_property(TEST
${test_name}
PROPERTY ENVIRONMENT
CEPH_ROOT=${CMAKE_SOURCE_DIR}
Expand Down
4 changes: 2 additions & 2 deletions run-make-check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ function run() {
if test -x ./do_cmake.sh ; then
$DRY_RUN ./do_cmake.sh || return 1
cd build
export CTEST_OUTPUT_ON_FAILURE=1 CTEST_PARALLEL_LEVEL=$(get_processors)
$DRY_RUN make $BUILD_MAKEOPTS check || return 1
$DRY_RUN make $BUILD_MAKEOPTS tests || return 1
$DRY_RUN ctest $CHECK_MAKEOPTS --output-on-failure || return 1
else
$DRY_RUN ./autogen.sh || return 1
$DRY_RUN ./configure "$@" --with-librocksdb-static --disable-static --with-radosgw --with-debug --without-lttng \
Expand Down
1 change: 1 addition & 0 deletions src/ceph-detect-init/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ add_custom_target(ceph-detect-init
${CEPH_DETECT_INIT_VIRTUALENV}/bin/pip install --disable-pip-version-check --no-index --use-wheel --find-links=file:${CMAKE_SOURCE_DIR}/src/ceph-detect-init/wheelhouse -e .
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/src/ceph-detect-init
COMMENT "ceph-detect-init is being created")
add_dependencies(tests ceph-detect-init)

include(Distutils)
distutils_install_module(ceph_detect_init)
1 change: 1 addition & 0 deletions src/ceph-disk/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ add_custom_target(ceph-disk
${CEPH_DISK_VIRTUALENV}/bin/pip install --disable-pip-version-check --no-index --use-wheel --find-links=file:${CMAKE_SOURCE_DIR}/src/ceph-disk/wheelhouse -e .
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/src/ceph-disk
COMMENT "ceph-disk is being created")
add_dependencies(tests ceph-disk)

include(Distutils)
distutils_install_module(ceph_disk
Expand Down
2 changes: 1 addition & 1 deletion src/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ target_link_libraries(ceph_test_get_blkdev_size
#make check starts here

#following dependencies are run inside make check unit tests
add_dependencies(check
add_dependencies(tests
ceph-mon
ceph
ceph-authtool
Expand Down

0 comments on commit ce5724e

Please sign in to comment.