mariadb/portability/tests/CMakeLists.txt
Leif Walsh d3a6f99e14 [t:5073] fix most clang problems on linux, ignore -Wcast-align for now
git-svn-id: file:///svn/toku/tokudb@44529 c7de825b-a66e-492c-adef-691d508d4ae1
2013-04-17 00:00:49 -04:00

54 lines
1.9 KiB
CMake

include_directories(${CMAKE_CURRENT_SOURCE_DIR})
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS _GNU_SOURCE)
if(BUILD_TESTING)
file(GLOB srcs RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" *.c)
foreach(src test-fsync.c test-fsync-directory.c)
set_property(SOURCE ${src} APPEND PROPERTY COMPILE_DEFINITIONS "ENVDIR=\"dir.${src}.test\"")
set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES dir.${src}.test)
endforeach(src)
include(CheckCCompilerFlag)
check_c_compiler_flag(-Wno-unused-result HAVE_WNO_UNUSED_RESULT)
if (HAVE_WNO_UNUSED_RESULT)
add_space_separated_property(SOURCE try-leak-lost.c COMPILE_FLAGS -Wno-unused-result)
endif ()
foreach(src ${srcs})
get_filename_component(test ${src} NAME_WE)
add_executable(${test} ${src})
target_link_libraries(${test} ${LIBTOKUPORTABILITY})
add_space_separated_property(TARGET ${test} COMPILE_FLAGS "-fvisibility=hidden -fPIE")
add_space_separated_property(TARGET ${test} LINK_FLAGS -pie)
if(HAVE_CLOCK_REALTIME)
target_link_libraries(${test} rt)
else()
target_link_libraries(${test} System)
endif()
list(APPEND tests ${test})
endforeach(src)
list(REMOVE_ITEM tests test-pwrite4g)
add_test(test-pwrite4g test-pwrite4g .)
configure_file(ensure_memcheck_fails.sh . COPYONLY)
foreach(test try-leak-lost try-leak-reachable try-uninit)
list(REMOVE_ITEM tests ${test})
add_test(NAME ${test}
COMMAND ensure_memcheck_fails.sh $<TARGET_FILE:${test}> valgrind --error-exitcode=1 --quiet --leak-check=full --show-reachable=yes --trace-children=yes --trace-children-skip=sh,*/sh,rm,*/rm,cp,*/cp,mv,*/mv,cat,*/cat,diff,test,wc,*/wc)
endforeach(test)
foreach(test ${tests})
add_test(${test} ${test})
endforeach(test)
set(portability_tests_should_fail
try-assert0
try-assert-zero
)
set_tests_properties(${portability_tests_should_fail} PROPERTIES WILL_FAIL TRUE)
endif(BUILD_TESTING)