Skip to content

Commit

Permalink
Cleanup libcheck related code (twitter#211)
Browse files Browse the repository at this point in the history
- Ref twitter#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
  • Loading branch information
michalbiesek authored and Yao Yue committed Sep 12, 2019
1 parent 683bc1a commit 7eb6424
Show file tree
Hide file tree
Showing 17 changed files with 6 additions and 32 deletions.
18 changes: 4 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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})
2 changes: 1 addition & 1 deletion ci/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
1 change: 0 additions & 1 deletion test/array/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
1 change: 0 additions & 1 deletion test/bstring/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
1 change: 0 additions & 1 deletion test/buffer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
1 change: 0 additions & 1 deletion test/channel/pipe/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
1 change: 0 additions & 1 deletion test/channel/tcp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
1 change: 0 additions & 1 deletion test/event/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
1 change: 0 additions & 1 deletion test/log/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
1 change: 0 additions & 1 deletion test/metric/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
1 change: 0 additions & 1 deletion test/option/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
1 change: 0 additions & 1 deletion test/pool/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
1 change: 0 additions & 1 deletion test/rbuf/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
1 change: 0 additions & 1 deletion test/ring_array/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
1 change: 0 additions & 1 deletion test/time/timer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
1 change: 0 additions & 1 deletion test/time/wheel/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})

0 comments on commit 7eb6424

Please sign in to comment.