Tests: verify that memory checker output files are always present
All supported memory checkers now write their output to a file. Use a dummy checker that ignores the given filename and ensure that the missing file is reported as error.
This commit is contained in:
parent
abf1df48fc
commit
7752253192
|
@ -28,10 +28,15 @@ target_link_libraries(pseudo_BC CMakeLib)
|
|||
add_executable(memcheck_fail "${CMAKE_CURRENT_BINARY_DIR}/ret1.cxx")
|
||||
target_link_libraries(memcheck_fail CMakeLib)
|
||||
|
||||
# Binaries that are used as memchecker that do not write the expected
|
||||
# output file. Need to be in their own subdirectory as they have the
|
||||
# same filenames.
|
||||
add_subdirectory(NoLogDummyChecker)
|
||||
|
||||
set(NORMAL_CTEST_OUTPUT "\n1/1 MemCheck #1: RunCMake \\.+ Passed +[0-9]+.[0-9]+ sec\n\n100% tests passed, 0 tests failed out of 1\n.*\n-- Processing memory checking output: \nMemory checking results:\n")
|
||||
set(BULLSEYE_MSG "(BullseyeCoverage[^\n]*\n)?")
|
||||
|
||||
function(gen_mc_test NAME CHECKER)
|
||||
function(gen_mc_test_internal NAME CHECKER)
|
||||
set(SUBTEST_NAME "${NAME}")
|
||||
set(CHECKER_COMMAND "${CHECKER}")
|
||||
foreach(_file IN ITEMS CMakeLists.txt CTestConfig.cmake test.cmake)
|
||||
|
@ -43,6 +48,12 @@ function(gen_mc_test NAME CHECKER)
|
|||
-C $<CONFIGURATION>
|
||||
-S "${CMAKE_CURRENT_BINARY_DIR}/${NAME}/test.cmake" -V
|
||||
--output-log "${CMAKE_CURRENT_BINARY_DIR}/${NAME}/testOutput.log"
|
||||
${ARGN}
|
||||
)
|
||||
endfunction(gen_mc_test_internal)
|
||||
|
||||
function(gen_mc_test NAME CHECKER)
|
||||
gen_mc_test_internal(${NAME} "${CHECKER}"
|
||||
-D PSEUDO_BC=$<TARGET_FILE:pseudo_BC>
|
||||
-D PSEUDO_PURIFY=$<TARGET_FILE:pseudo_purify>
|
||||
-D PSEUDO_VALGRIND=$<TARGET_FILE:pseudo_valgrind>
|
||||
|
@ -50,6 +61,17 @@ function(gen_mc_test NAME CHECKER)
|
|||
)
|
||||
endfunction(gen_mc_test)
|
||||
|
||||
function(gen_mcnl_test NAME CHECKER)
|
||||
gen_mc_test_internal(${NAME} ${CHECKER}
|
||||
-D PSEUDO_BC=$<TARGET_FILE:pseudonl_BC>
|
||||
-D PSEUDO_PURIFY=$<TARGET_FILE:pseudonl_purify>
|
||||
-D PSEUDO_VALGRIND=$<TARGET_FILE:pseudonl_valgrind>
|
||||
)
|
||||
set_tests_properties(CTestTestMemcheck${NAME}
|
||||
PROPERTIES
|
||||
PASS_REGULAR_EXPRESSION "\nCannot find memory tester output file: ${CMAKE_CURRENT_BINARY_DIR}/${NAME}/Testing/Temporary/MemoryChecker.log\n(.*\n)?Error in read script: ${CMAKE_CURRENT_BINARY_DIR}/${NAME}/test.cmake\n")
|
||||
endfunction(gen_mcnl_test)
|
||||
|
||||
unset(CTEST_EXTRA_CONFIG)
|
||||
unset(CTEST_EXTRA_CODE)
|
||||
unset(CMAKELISTS_EXTRA_CODE)
|
||||
|
@ -57,6 +79,9 @@ unset(CMAKELISTS_EXTRA_CODE)
|
|||
gen_mc_test(DummyPurify "\${PSEUDO_PURIFY}")
|
||||
gen_mc_test(DummyValgrind "\${PSEUDO_VALGRIND}")
|
||||
gen_mc_test(DummyBC "\${PSEUDO_BC}")
|
||||
gen_mcnl_test(DummyPurifyNoLogfile "\${PSEUDO_PURIFY}")
|
||||
gen_mcnl_test(DummyValgrindNoLogfile "\${PSEUDO_VALGRIND}")
|
||||
gen_mcnl_test(DummyBCNoLogfile "\${PSEUDO_BC}")
|
||||
|
||||
set(CTEST_EXTRA_CODE "set(CTEST_CUSTOM_PRE_MEMCHECK \"\${CTEST_MEMORYCHECK_COMMAND}\")\nset(CTEST_CUSTOM_POST_MEMCHECK \"\${CTEST_MEMORYCHECK_COMMAND}\")")
|
||||
gen_mc_test(DummyValgrindPrePost "\${PSEUDO_VALGRIND}")
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
# A dummy checker implementation that does not write the requested output file
|
||||
# so it triggers an error for every checker.
|
||||
|
||||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/ret0.c" "int main(){return 0;}\n")
|
||||
|
||||
foreach(_pseudo IN ITEMS valgrind purify BC)
|
||||
add_executable(pseudonl_${_pseudo} "${CMAKE_CURRENT_BINARY_DIR}/ret0.c")
|
||||
set_target_properties(pseudonl_${_pseudo} PROPERTIES OUTPUT_NAME ${_pseudo})
|
||||
endforeach()
|
||||
|
||||
# Xcode 2.x forgets to create the output directory before linking
|
||||
# the individual architectures.
|
||||
if(CMAKE_OSX_ARCHITECTURES AND XCODE AND NOT "${XCODE_VERSION}" MATCHES "^[^12]")
|
||||
add_custom_command(TARGET pseudonl_valgrind
|
||||
PRE_BUILD COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CFG_INTDIR}"
|
||||
)
|
||||
endif()
|
Loading…
Reference in New Issue