From 775225319295c08d2d6d7bb84010e4494d1bc5d0 Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Mon, 6 May 2013 13:09:22 +0200 Subject: 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. --- Tests/CTestTestMemcheck/CMakeLists.txt | 27 +++++++++++++++++++++- .../NoLogDummyChecker/CMakeLists.txt | 17 ++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 Tests/CTestTestMemcheck/NoLogDummyChecker/CMakeLists.txt diff --git a/Tests/CTestTestMemcheck/CMakeLists.txt b/Tests/CTestTestMemcheck/CMakeLists.txt index 3d6d8f3..65557c3 100644 --- a/Tests/CTestTestMemcheck/CMakeLists.txt +++ b/Tests/CTestTestMemcheck/CMakeLists.txt @@ -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 $ -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=$ -D PSEUDO_PURIFY=$ -D 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=$ + -D PSEUDO_PURIFY=$ + -D PSEUDO_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}") diff --git a/Tests/CTestTestMemcheck/NoLogDummyChecker/CMakeLists.txt b/Tests/CTestTestMemcheck/NoLogDummyChecker/CMakeLists.txt new file mode 100644 index 0000000..c5aa2cd --- /dev/null +++ b/Tests/CTestTestMemcheck/NoLogDummyChecker/CMakeLists.txt @@ -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() -- cgit v0.12