From 7eb64246230d711f8338ff6f558aa3abe876a17a Mon Sep 17 00:00:00 2001 From: michalbiesek <39981869+michalbiesek@users.noreply.github.com> Date: Thu, 12 Sep 2019 04:28:21 +0200 Subject: [PATCH] Cleanup libcheck related code (#211) - Ref #202, twitter/pelikan@14fcd34 - Replace CHECK_WORKING with CHECK_FOUND - call make test instead of make check - Fix Cmake warning "Policy CMP0075" by remove CMAKE_REQUIRED_LIBRARIES --- CMakeLists.txt | 18 ++++-------------- ci/run.sh | 2 +- test/CMakeLists.txt | 4 +--- test/array/CMakeLists.txt | 1 - test/bstring/CMakeLists.txt | 1 - test/buffer/CMakeLists.txt | 1 - test/channel/pipe/CMakeLists.txt | 1 - test/channel/tcp/CMakeLists.txt | 1 - test/event/CMakeLists.txt | 1 - test/log/CMakeLists.txt | 1 - test/metric/CMakeLists.txt | 1 - test/option/CMakeLists.txt | 1 - test/pool/CMakeLists.txt | 1 - test/rbuf/CMakeLists.txt | 1 - test/ring_array/CMakeLists.txt | 1 - test/time/timer/CMakeLists.txt | 1 - test/time/wheel/CMakeLists.txt | 1 - 17 files changed, 6 insertions(+), 32 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index afff55bc1..5b6d45c22 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -82,7 +82,6 @@ if(BUILD_AND_INSTALL_CHECK) set(CHECK_ROOT_DIR "${LIBCHECK_PREFIX}") set(CMAKE_REQUIRED_INCLUDES "${CHECK_ROOT_DIR}/include") # these make check link correctly in ccommon and pelikan - set(CMAKE_REQUIRED_LIBRARIES "${CHECK_ROOT_DIR}/lib") endif() include(CheckIncludeFiles) @@ -156,15 +155,6 @@ include(FindPackageHandleStandardArgs) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake") find_package(Check) -if(NOT CHECK_FOUND) - message(WARNING "Check is required to build and run tests") -endif(NOT CHECK_FOUND) -if(CHECK_FOUND) - check_symbol_exists(ck_assert_int_eq check.h CHECK_WORKING) - if(NOT CHECK_WORKING) - message(WARNING "Check version too old to build tests") - endif(NOT CHECK_WORKING) -endif(CHECK_FOUND) if (HAVE_ITT_INSTRUMENTATION) if(PKG_CONFIG_FOUND) @@ -192,10 +182,10 @@ include_directories( add_subdirectory(src) -if(CHECK_WORKING) - include_directories(${include_directories} "${CHECK_INCLUDES}") +if(CHECK_FOUND) + include_directories(${include_directories} ${CHECK_INCLUDES}) add_subdirectory(test) -endif(CHECK_WORKING) +endif(CHECK_FOUND) if(HAVE_RUST) @@ -221,4 +211,4 @@ message(STATUS "HAVE_SIGNAME: " ${HAVE_SIGNAME}) message(STATUS "HAVE_BACKTRACE: " ${HAVE_BACKTRACE}) -message(STATUS "CHECK_WORKING: " ${CHECK_WORKING}) +message(STATUS "CHECK_FOUND: " ${CHECK_FOUND}) diff --git a/ci/run.sh b/ci/run.sh index 3bd26d1aa..c9f89d6df 100755 --- a/ci/run.sh +++ b/ci/run.sh @@ -18,7 +18,7 @@ fi export RUST_BACKTRACE=full -mkdir -p _build && ( cd _build && "${cmake_cmd[@]}" .. && make && make check ) +mkdir -p _build && ( cd _build && "${cmake_cmd[@]}" .. && make && make test ) RESULT=$? egrep -r ":F:|:E:" . |grep -v 'Binary file' || true diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 6bea60886..e291873cf 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,6 +1,4 @@ -include_directories(${include_directories} CHECK_INCLUDES) - -add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND}) +include_directories(${include_directories} ${CHECK_INCLUDES}) add_subdirectory(array) add_subdirectory(bstring) diff --git a/test/array/CMakeLists.txt b/test/array/CMakeLists.txt index 41aa3b488..cddb02f59 100644 --- a/test/array/CMakeLists.txt +++ b/test/array/CMakeLists.txt @@ -6,5 +6,4 @@ set(source check_${suite}.c) add_executable(${test_name} ${source}) target_link_libraries(${test_name} ccommon-static ${CHECK_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} m) -add_dependencies(check ${test_name}) add_test(${test_name} ${test_name}) diff --git a/test/bstring/CMakeLists.txt b/test/bstring/CMakeLists.txt index 72e4decdb..62d08c6fb 100644 --- a/test/bstring/CMakeLists.txt +++ b/test/bstring/CMakeLists.txt @@ -6,5 +6,4 @@ set(source check_${suite}.c) add_executable(${test_name} ${source}) target_link_libraries(${test_name} ccommon-static ${CHECK_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} m) -add_dependencies(check ${test_name}) add_test(${test_name} ${test_name}) diff --git a/test/buffer/CMakeLists.txt b/test/buffer/CMakeLists.txt index 4f3fd14a1..aab20310c 100644 --- a/test/buffer/CMakeLists.txt +++ b/test/buffer/CMakeLists.txt @@ -6,5 +6,4 @@ set(source check_${suite}.c) add_executable(${test_name} ${source}) target_link_libraries(${test_name} ccommon-static ${CHECK_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} m) -add_dependencies(check ${test_name}) add_test(${test_name} ${test_name}) diff --git a/test/channel/pipe/CMakeLists.txt b/test/channel/pipe/CMakeLists.txt index 35a8669cb..7a49bc7e7 100644 --- a/test/channel/pipe/CMakeLists.txt +++ b/test/channel/pipe/CMakeLists.txt @@ -6,5 +6,4 @@ set(source check_${suite}.c) add_executable(${test_name} ${source}) target_link_libraries(${test_name} ccommon-static ${CHECK_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} m) -add_dependencies(check ${test_name}) add_test(${test_name} ${test_name}) diff --git a/test/channel/tcp/CMakeLists.txt b/test/channel/tcp/CMakeLists.txt index 7dfa9c54a..e661ae0a5 100644 --- a/test/channel/tcp/CMakeLists.txt +++ b/test/channel/tcp/CMakeLists.txt @@ -6,5 +6,4 @@ set(source check_${suite}.c) add_executable(${test_name} ${source}) target_link_libraries(${test_name} ccommon-static ${CHECK_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} m) -add_dependencies(check ${test_name}) add_test(${test_name} ${test_name}) diff --git a/test/event/CMakeLists.txt b/test/event/CMakeLists.txt index 027b7192b..e559afa8a 100644 --- a/test/event/CMakeLists.txt +++ b/test/event/CMakeLists.txt @@ -6,5 +6,4 @@ set(source check_${suite}.c) add_executable(${test_name} ${source}) target_link_libraries(${test_name} ccommon-static ${CHECK_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} m) -add_dependencies(check ${test_name}) add_test(${test_name} ${test_name}) diff --git a/test/log/CMakeLists.txt b/test/log/CMakeLists.txt index 262271197..5972811ce 100644 --- a/test/log/CMakeLists.txt +++ b/test/log/CMakeLists.txt @@ -24,5 +24,4 @@ if(OS_PLATFORM STREQUAL "OS_DARWIN") set_target_properties(${test_name} PROPERTIES LINK_FLAGS "-Wl,-F/System/Library/Frameworks") endif() -add_dependencies(check ${test_name} ccommon-static) add_test(${test_name} ${test_name}) diff --git a/test/metric/CMakeLists.txt b/test/metric/CMakeLists.txt index d693a8334..ec55a0180 100644 --- a/test/metric/CMakeLists.txt +++ b/test/metric/CMakeLists.txt @@ -6,5 +6,4 @@ set(source check_${suite}.c) add_executable(${test_name} ${source}) target_link_libraries(${test_name} ccommon-static ${CHECK_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} m) -add_dependencies(check ${test_name}) add_test(${test_name} ${test_name}) diff --git a/test/option/CMakeLists.txt b/test/option/CMakeLists.txt index 9dfe88081..d915013ae 100644 --- a/test/option/CMakeLists.txt +++ b/test/option/CMakeLists.txt @@ -6,5 +6,4 @@ set(source check_${suite}.c) add_executable(${test_name} ${source}) target_link_libraries(${test_name} ccommon-static ${CHECK_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} m) -add_dependencies(check ${test_name}) add_test(${test_name} ${test_name}) diff --git a/test/pool/CMakeLists.txt b/test/pool/CMakeLists.txt index c12118208..3db68955f 100644 --- a/test/pool/CMakeLists.txt +++ b/test/pool/CMakeLists.txt @@ -6,5 +6,4 @@ set(source check_${suite}.c) add_executable(${test_name} ${source}) target_link_libraries(${test_name} ccommon-static ${CHECK_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} m) -add_dependencies(check ${test_name}) add_test(${test_name} ${test_name}) diff --git a/test/rbuf/CMakeLists.txt b/test/rbuf/CMakeLists.txt index cfbfe661e..7f3176811 100644 --- a/test/rbuf/CMakeLists.txt +++ b/test/rbuf/CMakeLists.txt @@ -6,5 +6,4 @@ set(source check_${suite}.c) add_executable(${test_name} ${source}) target_link_libraries(${test_name} ccommon-static ${CHECK_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} m) -add_dependencies(check ${test_name}) add_test(${test_name} ${test_name}) diff --git a/test/ring_array/CMakeLists.txt b/test/ring_array/CMakeLists.txt index 732100b67..c2f224801 100644 --- a/test/ring_array/CMakeLists.txt +++ b/test/ring_array/CMakeLists.txt @@ -6,5 +6,4 @@ set(source check_${suite}.c) add_executable(${test_name} ${source}) target_link_libraries(${test_name} ccommon-static ${CHECK_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} m) -add_dependencies(check ${test_name}) add_test(${test_name} ${test_name}) diff --git a/test/time/timer/CMakeLists.txt b/test/time/timer/CMakeLists.txt index 70e8e2a58..b7199dec7 100644 --- a/test/time/timer/CMakeLists.txt +++ b/test/time/timer/CMakeLists.txt @@ -6,5 +6,4 @@ set(source check_${suite}.c) add_executable(${test_name} ${source}) target_link_libraries(${test_name} ccommon-static ${CHECK_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} m) -add_dependencies(check ${test_name}) add_test(${test_name} ${test_name}) diff --git a/test/time/wheel/CMakeLists.txt b/test/time/wheel/CMakeLists.txt index a3c023a18..6bbffeb5d 100644 --- a/test/time/wheel/CMakeLists.txt +++ b/test/time/wheel/CMakeLists.txt @@ -6,5 +6,4 @@ set(source check_${suite}.c) add_executable(${test_name} ${source}) target_link_libraries(${test_name} ccommon-static ${CHECK_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} m) -add_dependencies(check ${test_name}) add_test(${test_name} ${test_name})