From 95bc8aa6c440437ed62c692c302f6a95f57fc361 Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Sun, 30 Sep 2012 20:25:20 +0200 Subject: CTest: fix usage of memory checker with spaces in path The filename was escaped in cmCTestMemCheckHandler::InitializeMemoryChecking() and again before it was written to output in cmCTestRunTest::ComputeArguments(). Once someone uses e.g. a valgrind path with spaces this leads to double escaping making the memory checker fail completely because of the invalid path. --- Source/CTest/cmCTestMemCheckHandler.cxx | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/Source/CTest/cmCTestMemCheckHandler.cxx b/Source/CTest/cmCTestMemCheckHandler.cxx index a2a16d3..f446c94 100644 --- a/Source/CTest/cmCTestMemCheckHandler.cxx +++ b/Source/CTest/cmCTestMemCheckHandler.cxx @@ -247,7 +247,8 @@ void cmCTestMemCheckHandler::GenerateTestCommand( { std::vector::size_type pp; std::string memcheckcommand = ""; - memcheckcommand = this->MemoryTester; + memcheckcommand + = cmSystemTools::ConvertToOutputPath(this->MemoryTester.c_str()); for ( pp = 0; pp < this->MemoryTesterOptions.size(); pp ++ ) { args.push_back(this->MemoryTesterOptions[pp]); @@ -410,29 +411,25 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking() "MemoryCheckCommand").c_str()) ) { this->MemoryTester - = cmSystemTools::ConvertToOutputPath(this->CTest->GetCTestConfiguration( - "MemoryCheckCommand").c_str()); + = this->CTest->GetCTestConfiguration("MemoryCheckCommand").c_str(); } else if ( cmSystemTools::FileExists(this->CTest->GetCTestConfiguration( "PurifyCommand").c_str()) ) { this->MemoryTester - = cmSystemTools::ConvertToOutputPath(this->CTest->GetCTestConfiguration( - "PurifyCommand").c_str()); + = this->CTest->GetCTestConfiguration("PurifyCommand").c_str(); } else if ( cmSystemTools::FileExists(this->CTest->GetCTestConfiguration( "ValgrindCommand").c_str()) ) { this->MemoryTester - = cmSystemTools::ConvertToOutputPath(this->CTest->GetCTestConfiguration( - "ValgrindCommand").c_str()); + = this->CTest->GetCTestConfiguration("ValgrindCommand").c_str(); } else if ( cmSystemTools::FileExists(this->CTest->GetCTestConfiguration( "BoundsCheckerCommand").c_str()) ) { this->MemoryTester - = cmSystemTools::ConvertToOutputPath(this->CTest->GetCTestConfiguration( - "BoundsCheckerCommand").c_str()); + = this->CTest->GetCTestConfiguration("BoundsCheckerCommand").c_str(); } else { -- cgit v0.12 From 6187876dea89618044e200808bcae75a18bd4043 Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Sun, 30 Sep 2012 22:58:56 +0200 Subject: CTest: fix pre and post test commands with spaces If the pre or post memcheck or test commands have spaces in the path these were never escaped, leading to broken commands. This was not covered in the test suite so it went unnoticed. --- Source/CTest/cmCTestTestHandler.cxx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index ead449e..b796b83 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -1304,9 +1304,10 @@ int cmCTestTestHandler::ExecuteCommands(std::vector& vec) for ( it = vec.begin(); it != vec.end(); ++it ) { int retVal = 0; - cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run command: " << *it + std::string cmd = cmSystemTools::ConvertToOutputPath(it->c_str()); + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run command: " << cmd << std::endl); - if ( !cmSystemTools::RunSingleCommand(it->c_str(), 0, &retVal, 0, + if ( !cmSystemTools::RunSingleCommand(cmd.c_str(), 0, &retVal, 0, cmSystemTools::OUTPUT_MERGE /*this->Verbose*/) || retVal != 0 ) { -- cgit v0.12 From fcae1dacead9d97782d49e74dc8fca2505b2e28e Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Sun, 30 Sep 2012 18:21:18 +0200 Subject: CTest: add tests that simulate memcheck runs --- Tests/CMakeLists.txt | 2 + Tests/CTestTestMemcheck/CMakeLists.txt | 71 ++++++++++++++++++++++ Tests/CTestTestMemcheck/DummyBC/CMakeLists.txt | 5 ++ Tests/CTestTestMemcheck/DummyBC/CTestConfig.cmake | 7 +++ Tests/CTestTestMemcheck/DummyBC/test.cmake.in | 24 ++++++++ Tests/CTestTestMemcheck/DummyPurify/CMakeLists.txt | 5 ++ .../DummyPurify/CTestConfig.cmake | 7 +++ Tests/CTestTestMemcheck/DummyPurify/test.cmake.in | 24 ++++++++ .../CTestTestMemcheck/DummyValgrind/CMakeLists.txt | 5 ++ .../DummyValgrind/CTestConfig.cmake | 7 +++ .../CTestTestMemcheck/DummyValgrind/test.cmake.in | 24 ++++++++ .../DummyValgrindFailPost/CMakeLists.txt | 5 ++ .../DummyValgrindFailPost/CTestConfig.cmake | 7 +++ .../DummyValgrindFailPost/test.cmake.in | 26 ++++++++ .../DummyValgrindFailPre/CMakeLists.txt | 5 ++ .../DummyValgrindFailPre/CTestConfig.cmake | 7 +++ .../DummyValgrindFailPre/test.cmake.in | 26 ++++++++ .../DummyValgrindPrePost/CMakeLists.txt | 5 ++ .../DummyValgrindPrePost/CTestConfig.cmake | 7 +++ .../DummyValgrindPrePost/test.cmake.in | 27 ++++++++ Tests/CTestTestMemcheck/NotExist/CMakeLists.txt | 5 ++ Tests/CTestTestMemcheck/NotExist/CTestConfig.cmake | 7 +++ Tests/CTestTestMemcheck/NotExist/test.cmake.in | 18 ++++++ Tests/CTestTestMemcheck/Unknown/CMakeLists.txt | 5 ++ Tests/CTestTestMemcheck/Unknown/CTestConfig.cmake | 7 +++ Tests/CTestTestMemcheck/Unknown/test.cmake.in | 18 ++++++ 26 files changed, 356 insertions(+) create mode 100644 Tests/CTestTestMemcheck/CMakeLists.txt create mode 100644 Tests/CTestTestMemcheck/DummyBC/CMakeLists.txt create mode 100644 Tests/CTestTestMemcheck/DummyBC/CTestConfig.cmake create mode 100644 Tests/CTestTestMemcheck/DummyBC/test.cmake.in create mode 100644 Tests/CTestTestMemcheck/DummyPurify/CMakeLists.txt create mode 100644 Tests/CTestTestMemcheck/DummyPurify/CTestConfig.cmake create mode 100644 Tests/CTestTestMemcheck/DummyPurify/test.cmake.in create mode 100644 Tests/CTestTestMemcheck/DummyValgrind/CMakeLists.txt create mode 100644 Tests/CTestTestMemcheck/DummyValgrind/CTestConfig.cmake create mode 100644 Tests/CTestTestMemcheck/DummyValgrind/test.cmake.in create mode 100644 Tests/CTestTestMemcheck/DummyValgrindFailPost/CMakeLists.txt create mode 100644 Tests/CTestTestMemcheck/DummyValgrindFailPost/CTestConfig.cmake create mode 100644 Tests/CTestTestMemcheck/DummyValgrindFailPost/test.cmake.in create mode 100644 Tests/CTestTestMemcheck/DummyValgrindFailPre/CMakeLists.txt create mode 100644 Tests/CTestTestMemcheck/DummyValgrindFailPre/CTestConfig.cmake create mode 100644 Tests/CTestTestMemcheck/DummyValgrindFailPre/test.cmake.in create mode 100644 Tests/CTestTestMemcheck/DummyValgrindPrePost/CMakeLists.txt create mode 100644 Tests/CTestTestMemcheck/DummyValgrindPrePost/CTestConfig.cmake create mode 100644 Tests/CTestTestMemcheck/DummyValgrindPrePost/test.cmake.in create mode 100644 Tests/CTestTestMemcheck/NotExist/CMakeLists.txt create mode 100644 Tests/CTestTestMemcheck/NotExist/CTestConfig.cmake create mode 100644 Tests/CTestTestMemcheck/NotExist/test.cmake.in create mode 100644 Tests/CTestTestMemcheck/Unknown/CMakeLists.txt create mode 100644 Tests/CTestTestMemcheck/Unknown/CTestConfig.cmake create mode 100644 Tests/CTestTestMemcheck/Unknown/test.cmake.in diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index e03b926..ac02376 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -57,6 +57,8 @@ if(BUILD_TESTING) add_subdirectory(FindPackageModeMakefileTest) + add_subdirectory(CTestTestMemcheck) + # Collect a list of all test build directories. set(TEST_BUILD_DIRS) diff --git a/Tests/CTestTestMemcheck/CMakeLists.txt b/Tests/CTestTestMemcheck/CMakeLists.txt new file mode 100644 index 0000000..544d0ed --- /dev/null +++ b/Tests/CTestTestMemcheck/CMakeLists.txt @@ -0,0 +1,71 @@ +foreach (_retval 0 1) + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/ret${_retval}.c" "int main(){return ${_retval};}\n") +endforeach () + +# create binaries that we will use as a pseudo memory checker +add_executable(pseudo_valgrind "${CMAKE_CURRENT_BINARY_DIR}/ret0.c") +set_target_properties(pseudo_valgrind PROPERTIES OUTPUT_NAME valgrind) + +# 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 pseudo_valgrind + PRE_BUILD COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CFG_INTDIR}" + ) +endif() + +add_executable(pseudo_purify "${CMAKE_CURRENT_BINARY_DIR}/ret0.c") +set_target_properties(pseudo_purify PROPERTIES OUTPUT_NAME purify) +add_executable(pseudo_BC "${CMAKE_CURRENT_BINARY_DIR}/ret0.c") +set_target_properties(pseudo_BC PROPERTIES OUTPUT_NAME BC) + +# binary to be used as pre- and post-memcheck command that fails +add_executable(memcheck_fail "${CMAKE_CURRENT_BINARY_DIR}/ret1.c") + +foreach (_test IN ITEMS Unknown NotExist DummyValgrind DummyValgrindPrePost + DummyValgrindFailPre DummyValgrindFailPost DummyPurify DummyBC) + configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/${_test}/test.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/${_test}/test.cmake" + @ONLY ESCAPE_QUOTES) + add_test(NAME CTestTestMemcheck${_test} + COMMAND ${CMAKE_CTEST_COMMAND} + -S "${CMAKE_CURRENT_BINARY_DIR}/${_test}/test.cmake" -V + --output-log "${CMAKE_CURRENT_BINARY_DIR}/${_test}/testOutput.log" + -D PSEUDO_BC=$ + -D PSEUDO_PURIFY=$ + -D PSEUDO_VALGRIND=$ + -D ERROR_COMMAND=$ + ) +endforeach () + +string(REPLACE "\\" "\\\\" CMAKE_COMMAND_ESCAPED "${CMAKE_COMMAND}") +string(REPLACE "(" "\\(" CMAKE_COMMAND_ESCAPED "${CMAKE_COMMAND_ESCAPED}") +string(REPLACE ")" "\\)" CMAKE_COMMAND_ESCAPED "${CMAKE_COMMAND_ESCAPED}") +string(REPLACE "+" "\\+" CMAKE_COMMAND_ESCAPED "${CMAKE_COMMAND_ESCAPED}") +set_tests_properties(CTestTestMemcheckUnknown PROPERTIES + PASS_REGULAR_EXPRESSION "Do not understand memory checker: ${CMAKE_COMMAND_ESCAPED}\n(.*\n)?Error in read script: ${CMAKE_CURRENT_BINARY_DIR}/Unknown/test.cmake\n") + +set_tests_properties(CTestTestMemcheckNotExist PROPERTIES + PASS_REGULAR_EXPRESSION "Memory checker \\(MemoryCheckCommand\\) not set, or cannot find the specified program.") + +set(NORMAL_CTEST_OUTPUT "\n-- Processing memory checking output: \nMemory checking results:\n(BullseyeCoverage[^\n]*\n)?") + +# It is a valid result if valgrind does not output any files (can e.g. happen +# if you have not compiled in debug mode), so these tests will not fail. +set_tests_properties(CTestTestMemcheckDummyValgrind CTestTestMemcheckDummyValgrindPrePost + PROPERTIES + PASS_REGULAR_EXPRESSION "${NORMAL_CTEST_OUTPUT}") + +foreach (_pp Pre Post) + string(TOLOWER ${_pp} _pp_lower) + set_tests_properties(CTestTestMemcheckDummyValgrindFail${_pp} + PROPERTIES + PASS_REGULAR_EXPRESSION "\nProblem running command: ${CMAKE_CURRENT_BINARY_DIR}[^\n]*fail[^\n]*\n(.*\n)?Problem executing ${_pp_lower}-memcheck command\\(s\\\).\n(.*\n)?Error in read script: ${CMAKE_CURRENT_BINARY_DIR}/DummyValgrindFail${_pp}/test.cmake\n") +endforeach () + +set_tests_properties(CTestTestMemcheckDummyPurify PROPERTIES + PASS_REGULAR_EXPRESSION "\nCannot find memory tester output file: ${CMAKE_CURRENT_BINARY_DIR}/DummyPurify/Testing/Temporary/MemoryChecker.log\n(.*\n)?Error in read script: ${CMAKE_CURRENT_BINARY_DIR}/DummyPurify/test.cmake\n") + +set_tests_properties(CTestTestMemcheckDummyBC PROPERTIES + PASS_REGULAR_EXPRESSION "\nCannot find memory tester output file: ${CMAKE_CURRENT_BINARY_DIR}/DummyBC/Testing/Temporary/MemoryChecker.log\n(.*\n)?Error parsing XML in stream at line 1: no element found\n(.*\n)?Error in read script: ${CMAKE_CURRENT_BINARY_DIR}/DummyBC/test.cmake\n") diff --git a/Tests/CTestTestMemcheck/DummyBC/CMakeLists.txt b/Tests/CTestTestMemcheck/DummyBC/CMakeLists.txt new file mode 100644 index 0000000..aa0e495 --- /dev/null +++ b/Tests/CTestTestMemcheck/DummyBC/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 2.8.9) +project(CTestTestMemcheckDummyBC) +include(CTest) + +add_test (RunCMake "${CMAKE_COMMAND}") diff --git a/Tests/CTestTestMemcheck/DummyBC/CTestConfig.cmake b/Tests/CTestTestMemcheck/DummyBC/CTestConfig.cmake new file mode 100644 index 0000000..39cdd88 --- /dev/null +++ b/Tests/CTestTestMemcheck/DummyBC/CTestConfig.cmake @@ -0,0 +1,7 @@ +set (CTEST_PROJECT_NAME "CTestTestMemcheckDummyBC") +set (CTEST_NIGHTLY_START_TIME "21:00:00 EDT") +set (CTEST_DART_SERVER_VERSION "2") +set(CTEST_DROP_METHOD "http") +set(CTEST_DROP_SITE "www.cdash.org") +set(CTEST_DROP_LOCATION "/CDash/submit.php?project=PublicDashboard") +set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/Tests/CTestTestMemcheck/DummyBC/test.cmake.in b/Tests/CTestTestMemcheck/DummyBC/test.cmake.in new file mode 100644 index 0000000..5005498 --- /dev/null +++ b/Tests/CTestTestMemcheck/DummyBC/test.cmake.in @@ -0,0 +1,24 @@ +cmake_minimum_required(VERSION 2.8.9) + +# Settings: +set(CTEST_DASHBOARD_ROOT "@CMAKE_CURRENT_BINARY_DIR@") +set(CTEST_SITE "@SITE@") +set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-MemcheckDummyBC") + +set(CTEST_SOURCE_DIRECTORY "@CMAKE_CURRENT_SOURCE_DIR@/DummyBC") +set(CTEST_BINARY_DIRECTORY "@CMAKE_CURRENT_BINARY_DIR@/DummyBC") +set(CTEST_CVS_COMMAND "@CVSCOMMAND@") +set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") +set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") +set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") +set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") + +set(CTEST_MEMORYCHECK_COMMAND "${PSEUDO_BC}") + +#CTEST_EMPTY_BINARY_DIRECTORY(${CTEST_BINARY_DIRECTORY}) + +CTEST_START(Experimental) +CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +#CTEST_BUILD(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +CTEST_MEMCHECK(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) diff --git a/Tests/CTestTestMemcheck/DummyPurify/CMakeLists.txt b/Tests/CTestTestMemcheck/DummyPurify/CMakeLists.txt new file mode 100644 index 0000000..dfd93fd --- /dev/null +++ b/Tests/CTestTestMemcheck/DummyPurify/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 2.8.9) +project(CTestTestMemcheckDummyPurify) +include(CTest) + +add_test (RunCMake "${CMAKE_COMMAND}") diff --git a/Tests/CTestTestMemcheck/DummyPurify/CTestConfig.cmake b/Tests/CTestTestMemcheck/DummyPurify/CTestConfig.cmake new file mode 100644 index 0000000..40b9608 --- /dev/null +++ b/Tests/CTestTestMemcheck/DummyPurify/CTestConfig.cmake @@ -0,0 +1,7 @@ +set (CTEST_PROJECT_NAME "CTestTestMemcheckDummyPurify") +set (CTEST_NIGHTLY_START_TIME "21:00:00 EDT") +set (CTEST_DART_SERVER_VERSION "2") +set(CTEST_DROP_METHOD "http") +set(CTEST_DROP_SITE "www.cdash.org") +set(CTEST_DROP_LOCATION "/CDash/submit.php?project=PublicDashboard") +set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/Tests/CTestTestMemcheck/DummyPurify/test.cmake.in b/Tests/CTestTestMemcheck/DummyPurify/test.cmake.in new file mode 100644 index 0000000..0df4f68 --- /dev/null +++ b/Tests/CTestTestMemcheck/DummyPurify/test.cmake.in @@ -0,0 +1,24 @@ +cmake_minimum_required(VERSION 2.8.9) + +# Settings: +set(CTEST_DASHBOARD_ROOT "@CMAKE_CURRENT_BINARY_DIR@") +set(CTEST_SITE "@SITE@") +set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-MemcheckDummyPurify") + +set(CTEST_SOURCE_DIRECTORY "@CMAKE_CURRENT_SOURCE_DIR@/DummyPurify") +set(CTEST_BINARY_DIRECTORY "@CMAKE_CURRENT_BINARY_DIR@/DummyPurify") +set(CTEST_CVS_COMMAND "@CVSCOMMAND@") +set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") +set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") +set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") +set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") + +set(CTEST_MEMORYCHECK_COMMAND "${PSEUDO_PURIFY}") + +#CTEST_EMPTY_BINARY_DIRECTORY(${CTEST_BINARY_DIRECTORY}) + +CTEST_START(Experimental) +CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +#CTEST_BUILD(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +CTEST_MEMCHECK(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) diff --git a/Tests/CTestTestMemcheck/DummyValgrind/CMakeLists.txt b/Tests/CTestTestMemcheck/DummyValgrind/CMakeLists.txt new file mode 100644 index 0000000..822966a --- /dev/null +++ b/Tests/CTestTestMemcheck/DummyValgrind/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 2.8.9) +project(CTestTestMemcheckDummyValgrind) +include(CTest) + +add_test (RunCMake "${CMAKE_COMMAND}") diff --git a/Tests/CTestTestMemcheck/DummyValgrind/CTestConfig.cmake b/Tests/CTestTestMemcheck/DummyValgrind/CTestConfig.cmake new file mode 100644 index 0000000..4ca59a4 --- /dev/null +++ b/Tests/CTestTestMemcheck/DummyValgrind/CTestConfig.cmake @@ -0,0 +1,7 @@ +set (CTEST_PROJECT_NAME "CTestTestMemcheckDummyValgrind") +set (CTEST_NIGHTLY_START_TIME "21:00:00 EDT") +set (CTEST_DART_SERVER_VERSION "2") +set(CTEST_DROP_METHOD "http") +set(CTEST_DROP_SITE "www.cdash.org") +set(CTEST_DROP_LOCATION "/CDash/submit.php?project=PublicDashboard") +set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/Tests/CTestTestMemcheck/DummyValgrind/test.cmake.in b/Tests/CTestTestMemcheck/DummyValgrind/test.cmake.in new file mode 100644 index 0000000..e341fed --- /dev/null +++ b/Tests/CTestTestMemcheck/DummyValgrind/test.cmake.in @@ -0,0 +1,24 @@ +cmake_minimum_required(VERSION 2.8.9) + +# Settings: +set(CTEST_DASHBOARD_ROOT "@CMAKE_CURRENT_BINARY_DIR@") +set(CTEST_SITE "@SITE@") +set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-MemcheckDummyValgrind") + +set(CTEST_SOURCE_DIRECTORY "@CMAKE_CURRENT_SOURCE_DIR@/DummyValgrind") +set(CTEST_BINARY_DIRECTORY "@CMAKE_CURRENT_BINARY_DIR@/DummyValgrind") +set(CTEST_CVS_COMMAND "@CVSCOMMAND@") +set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") +set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") +set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") +set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") + +set(CTEST_MEMORYCHECK_COMMAND "${PSEUDO_VALGRIND}") + +#CTEST_EMPTY_BINARY_DIRECTORY(${CTEST_BINARY_DIRECTORY}) + +CTEST_START(Experimental) +CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +#CTEST_BUILD(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +CTEST_MEMCHECK(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) diff --git a/Tests/CTestTestMemcheck/DummyValgrindFailPost/CMakeLists.txt b/Tests/CTestTestMemcheck/DummyValgrindFailPost/CMakeLists.txt new file mode 100644 index 0000000..8185071 --- /dev/null +++ b/Tests/CTestTestMemcheck/DummyValgrindFailPost/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 2.8.9) +project(CTestTestMemcheckDummyValgrindFailPost) +include(CTest) + +add_test (RunCMake "${CMAKE_COMMAND}") diff --git a/Tests/CTestTestMemcheck/DummyValgrindFailPost/CTestConfig.cmake b/Tests/CTestTestMemcheck/DummyValgrindFailPost/CTestConfig.cmake new file mode 100644 index 0000000..4ca59a4 --- /dev/null +++ b/Tests/CTestTestMemcheck/DummyValgrindFailPost/CTestConfig.cmake @@ -0,0 +1,7 @@ +set (CTEST_PROJECT_NAME "CTestTestMemcheckDummyValgrind") +set (CTEST_NIGHTLY_START_TIME "21:00:00 EDT") +set (CTEST_DART_SERVER_VERSION "2") +set(CTEST_DROP_METHOD "http") +set(CTEST_DROP_SITE "www.cdash.org") +set(CTEST_DROP_LOCATION "/CDash/submit.php?project=PublicDashboard") +set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/Tests/CTestTestMemcheck/DummyValgrindFailPost/test.cmake.in b/Tests/CTestTestMemcheck/DummyValgrindFailPost/test.cmake.in new file mode 100644 index 0000000..7c1aa66 --- /dev/null +++ b/Tests/CTestTestMemcheck/DummyValgrindFailPost/test.cmake.in @@ -0,0 +1,26 @@ +cmake_minimum_required(VERSION 2.8.9) + +# Settings: +set(CTEST_DASHBOARD_ROOT "@CMAKE_CURRENT_BINARY_DIR@") +set(CTEST_SITE "@SITE@") +set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-MemcheckDummyValgrindFailPost") + +set(CTEST_SOURCE_DIRECTORY "@CMAKE_CURRENT_SOURCE_DIR@/DummyValgrindFailPost") +set(CTEST_BINARY_DIRECTORY "@CMAKE_CURRENT_BINARY_DIR@/DummyValgrindFailPost") +set(CTEST_CVS_COMMAND "@CVSCOMMAND@") +set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") +set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") +set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") +set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") + +set(CTEST_MEMORYCHECK_COMMAND "${PSEUDO_VALGRIND}") + +set(CTEST_CUSTOM_POST_MEMCHECK "${ERROR_COMMAND}") + +#CTEST_EMPTY_BINARY_DIRECTORY(${CTEST_BINARY_DIRECTORY}) + +CTEST_START(Experimental) +CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +#CTEST_BUILD(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +CTEST_MEMCHECK(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) diff --git a/Tests/CTestTestMemcheck/DummyValgrindFailPre/CMakeLists.txt b/Tests/CTestTestMemcheck/DummyValgrindFailPre/CMakeLists.txt new file mode 100644 index 0000000..3714cd6 --- /dev/null +++ b/Tests/CTestTestMemcheck/DummyValgrindFailPre/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 2.8.9) +project(CTestTestMemcheckDummyValgrindFailPre) +include(CTest) + +add_test (RunCMake "${CMAKE_COMMAND}") diff --git a/Tests/CTestTestMemcheck/DummyValgrindFailPre/CTestConfig.cmake b/Tests/CTestTestMemcheck/DummyValgrindFailPre/CTestConfig.cmake new file mode 100644 index 0000000..4ca59a4 --- /dev/null +++ b/Tests/CTestTestMemcheck/DummyValgrindFailPre/CTestConfig.cmake @@ -0,0 +1,7 @@ +set (CTEST_PROJECT_NAME "CTestTestMemcheckDummyValgrind") +set (CTEST_NIGHTLY_START_TIME "21:00:00 EDT") +set (CTEST_DART_SERVER_VERSION "2") +set(CTEST_DROP_METHOD "http") +set(CTEST_DROP_SITE "www.cdash.org") +set(CTEST_DROP_LOCATION "/CDash/submit.php?project=PublicDashboard") +set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/Tests/CTestTestMemcheck/DummyValgrindFailPre/test.cmake.in b/Tests/CTestTestMemcheck/DummyValgrindFailPre/test.cmake.in new file mode 100644 index 0000000..b2d7bb1 --- /dev/null +++ b/Tests/CTestTestMemcheck/DummyValgrindFailPre/test.cmake.in @@ -0,0 +1,26 @@ +cmake_minimum_required(VERSION 2.8.9) + +# Settings: +set(CTEST_DASHBOARD_ROOT "@CMAKE_CURRENT_BINARY_DIR@") +set(CTEST_SITE "@SITE@") +set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-MemcheckDummyValgrindFailPre") + +set(CTEST_SOURCE_DIRECTORY "@CMAKE_CURRENT_SOURCE_DIR@/DummyValgrindFailPre") +set(CTEST_BINARY_DIRECTORY "@CMAKE_CURRENT_BINARY_DIR@/DummyValgrindFailPre") +set(CTEST_CVS_COMMAND "@CVSCOMMAND@") +set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") +set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") +set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") +set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") + +set(CTEST_MEMORYCHECK_COMMAND "${PSEUDO_VALGRIND}") + +set(CTEST_CUSTOM_PRE_MEMCHECK "${ERROR_COMMAND}") + +#CTEST_EMPTY_BINARY_DIRECTORY(${CTEST_BINARY_DIRECTORY}) + +CTEST_START(Experimental) +CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +#CTEST_BUILD(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +CTEST_MEMCHECK(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) diff --git a/Tests/CTestTestMemcheck/DummyValgrindPrePost/CMakeLists.txt b/Tests/CTestTestMemcheck/DummyValgrindPrePost/CMakeLists.txt new file mode 100644 index 0000000..bc15632 --- /dev/null +++ b/Tests/CTestTestMemcheck/DummyValgrindPrePost/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 2.8.9) +project(CTestTestMemcheckDummyValgrindPrePost) +include(CTest) + +add_test (RunCMake "${CMAKE_COMMAND}") diff --git a/Tests/CTestTestMemcheck/DummyValgrindPrePost/CTestConfig.cmake b/Tests/CTestTestMemcheck/DummyValgrindPrePost/CTestConfig.cmake new file mode 100644 index 0000000..6e4c2e8 --- /dev/null +++ b/Tests/CTestTestMemcheck/DummyValgrindPrePost/CTestConfig.cmake @@ -0,0 +1,7 @@ +set (CTEST_PROJECT_NAME "CTestTestMemcheckDummyValgrindPrePost") +set (CTEST_NIGHTLY_START_TIME "21:00:00 EDT") +set (CTEST_DART_SERVER_VERSION "2") +set(CTEST_DROP_METHOD "http") +set(CTEST_DROP_SITE "www.cdash.org") +set(CTEST_DROP_LOCATION "/CDash/submit.php?project=PublicDashboard") +set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/Tests/CTestTestMemcheck/DummyValgrindPrePost/test.cmake.in b/Tests/CTestTestMemcheck/DummyValgrindPrePost/test.cmake.in new file mode 100644 index 0000000..44c416e --- /dev/null +++ b/Tests/CTestTestMemcheck/DummyValgrindPrePost/test.cmake.in @@ -0,0 +1,27 @@ +cmake_minimum_required(VERSION 2.8.9) + +# Settings: +set(CTEST_DASHBOARD_ROOT "@CMAKE_CURRENT_BINARY_DIR@") +set(CTEST_SITE "@SITE@") +set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-MemcheckDummyValgrindPrePost") + +set(CTEST_SOURCE_DIRECTORY "@CMAKE_CURRENT_SOURCE_DIR@/DummyValgrindPrePost") +set(CTEST_BINARY_DIRECTORY "@CMAKE_CURRENT_BINARY_DIR@/DummyValgrindPrePost") +set(CTEST_CVS_COMMAND "@CVSCOMMAND@") +set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") +set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") +set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") +set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") + +set(CTEST_MEMORYCHECK_COMMAND "${PSEUDO_VALGRIND}") + +set(CTEST_CUSTOM_PRE_MEMCHECK "${CTEST_MEMORYCHECK_COMMAND}") +set(CTEST_CUSTOM_POST_MEMCHECK "${CTEST_MEMORYCHECK_COMMAND}") + +#CTEST_EMPTY_BINARY_DIRECTORY(${CTEST_BINARY_DIRECTORY}) + +CTEST_START(Experimental) +CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +#CTEST_BUILD(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +CTEST_MEMCHECK(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) diff --git a/Tests/CTestTestMemcheck/NotExist/CMakeLists.txt b/Tests/CTestTestMemcheck/NotExist/CMakeLists.txt new file mode 100644 index 0000000..4d905de --- /dev/null +++ b/Tests/CTestTestMemcheck/NotExist/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 2.8.9) +project(CTestTestMemcheckNotExist) +include(CTest) + +add_test (RunCMake "${CMAKE_COMMAND}") diff --git a/Tests/CTestTestMemcheck/NotExist/CTestConfig.cmake b/Tests/CTestTestMemcheck/NotExist/CTestConfig.cmake new file mode 100644 index 0000000..3ed84aa --- /dev/null +++ b/Tests/CTestTestMemcheck/NotExist/CTestConfig.cmake @@ -0,0 +1,7 @@ +set (CTEST_PROJECT_NAME "CTestTestMemcheckUnknown") +set (CTEST_NIGHTLY_START_TIME "21:00:00 EDT") +set (CTEST_DART_SERVER_VERSION "2") +set(CTEST_DROP_METHOD "http") +set(CTEST_DROP_SITE "www.cdash.org") +set(CTEST_DROP_LOCATION "/CDash/submit.php?project=PublicDashboard") +set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/Tests/CTestTestMemcheck/NotExist/test.cmake.in b/Tests/CTestTestMemcheck/NotExist/test.cmake.in new file mode 100644 index 0000000..78db7e2 --- /dev/null +++ b/Tests/CTestTestMemcheck/NotExist/test.cmake.in @@ -0,0 +1,18 @@ +cmake_minimum_required(VERSION 2.8.9) + +# Settings: +set(CTEST_DASHBOARD_ROOT "@CMAKE_CURRENT_BINARY_DIR@") +set(CTEST_SITE "@SITE@") +set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-MemcheckNotExist") + +set(CTEST_SOURCE_DIRECTORY "@CMAKE_CURRENT_SOURCE_DIR@/NotExist") +set(CTEST_BINARY_DIRECTORY "@CMAKE_CURRENT_BINARY_DIR@/NotExist") +set(CTEST_CVS_COMMAND "@CVSCOMMAND@") +set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") +set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") +set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") +set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") +set(CTEST_MEMORYCHECK_COMMAND "${CTEST_BINARY_DIRECTORY}/no-memcheck-exe") + +CTEST_START(Experimental) +CTEST_MEMCHECK(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) diff --git a/Tests/CTestTestMemcheck/Unknown/CMakeLists.txt b/Tests/CTestTestMemcheck/Unknown/CMakeLists.txt new file mode 100644 index 0000000..3fd3103 --- /dev/null +++ b/Tests/CTestTestMemcheck/Unknown/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 2.8.9) +project(CTestTestMemcheckUnknown) +include(CTest) + +add_test (RunCMake "${CMAKE_COMMAND}") diff --git a/Tests/CTestTestMemcheck/Unknown/CTestConfig.cmake b/Tests/CTestTestMemcheck/Unknown/CTestConfig.cmake new file mode 100644 index 0000000..3ed84aa --- /dev/null +++ b/Tests/CTestTestMemcheck/Unknown/CTestConfig.cmake @@ -0,0 +1,7 @@ +set (CTEST_PROJECT_NAME "CTestTestMemcheckUnknown") +set (CTEST_NIGHTLY_START_TIME "21:00:00 EDT") +set (CTEST_DART_SERVER_VERSION "2") +set(CTEST_DROP_METHOD "http") +set(CTEST_DROP_SITE "www.cdash.org") +set(CTEST_DROP_LOCATION "/CDash/submit.php?project=PublicDashboard") +set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/Tests/CTestTestMemcheck/Unknown/test.cmake.in b/Tests/CTestTestMemcheck/Unknown/test.cmake.in new file mode 100644 index 0000000..c0b7839 --- /dev/null +++ b/Tests/CTestTestMemcheck/Unknown/test.cmake.in @@ -0,0 +1,18 @@ +cmake_minimum_required(VERSION 2.8.9) + +# Settings: +set(CTEST_DASHBOARD_ROOT "@CMAKE_CURRENT_BINARY_DIR@") +set(CTEST_SITE "@SITE@") +set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-MemcheckUnknown") + +set(CTEST_SOURCE_DIRECTORY "@CMAKE_CURRENT_SOURCE_DIR@/Unknown") +set(CTEST_BINARY_DIRECTORY "@CMAKE_CURRENT_BINARY_DIR@/Unknown") +set(CTEST_CVS_COMMAND "@CVSCOMMAND@") +set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") +set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") +set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") +set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") +set(CTEST_MEMORYCHECK_COMMAND "@CMAKE_COMMAND@") + +CTEST_START(Experimental) +CTEST_MEMCHECK(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) -- cgit v0.12 From d26c9b69c57ae051e9bdc7a084326dff50dfb2ba Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Sun, 30 Sep 2012 20:53:27 +0200 Subject: CTest: improve memory checker type detection If the checker was explicitely set with a "TypeCommand" variable (e.g. ValgrindCommand) then we now just believe that this is valgrind, even if nothing in the path matches "valgrind". Only when "MemoryCheckCommand" was used we still scan the path to find out what checker we have. --- Source/CTest/cmCTestMemCheckHandler.cxx | 158 ++++++++++++++++++-------------- 1 file changed, 89 insertions(+), 69 deletions(-) diff --git a/Source/CTest/cmCTestMemCheckHandler.cxx b/Source/CTest/cmCTestMemCheckHandler.cxx index f446c94..80218ad 100644 --- a/Source/CTest/cmCTestMemCheckHandler.cxx +++ b/Source/CTest/cmCTestMemCheckHandler.cxx @@ -412,24 +412,45 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking() { this->MemoryTester = this->CTest->GetCTestConfiguration("MemoryCheckCommand").c_str(); + + // determine the checker type + if ( this->MemoryTester.find("valgrind") != std::string::npos ) + { + this->MemoryTesterStyle = cmCTestMemCheckHandler::VALGRIND; + } + else if ( this->MemoryTester.find("purify") != std::string::npos ) + { + this->MemoryTesterStyle = cmCTestMemCheckHandler::PURIFY; + } + else if ( this->MemoryTester.find("BC") != std::string::npos ) + { + this->MemoryTesterStyle = cmCTestMemCheckHandler::BOUNDS_CHECKER; + } + else + { + this->MemoryTesterStyle = cmCTestMemCheckHandler::UNKNOWN; + } } else if ( cmSystemTools::FileExists(this->CTest->GetCTestConfiguration( "PurifyCommand").c_str()) ) { this->MemoryTester = this->CTest->GetCTestConfiguration("PurifyCommand").c_str(); + this->MemoryTesterStyle = cmCTestMemCheckHandler::PURIFY; } else if ( cmSystemTools::FileExists(this->CTest->GetCTestConfiguration( "ValgrindCommand").c_str()) ) { this->MemoryTester = this->CTest->GetCTestConfiguration("ValgrindCommand").c_str(); + this->MemoryTesterStyle = cmCTestMemCheckHandler::VALGRIND; } else if ( cmSystemTools::FileExists(this->CTest->GetCTestConfiguration( "BoundsCheckerCommand").c_str()) ) { this->MemoryTester = this->CTest->GetCTestConfiguration("BoundsCheckerCommand").c_str(); + this->MemoryTesterStyle = cmCTestMemCheckHandler::BOUNDS_CHECKER; } else { @@ -467,82 +488,81 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking() this->MemoryTesterOutputFile = this->CTest->GetBinaryDir() + "/Testing/Temporary/MemoryChecker.log"; - if ( this->MemoryTester.find("valgrind") != std::string::npos ) + switch ( this->MemoryTesterStyle ) { - this->MemoryTesterStyle = cmCTestMemCheckHandler::VALGRIND; - if ( this->MemoryTesterOptions.empty() ) - { - this->MemoryTesterOptions.push_back("-q"); - this->MemoryTesterOptions.push_back("--tool=memcheck"); - this->MemoryTesterOptions.push_back("--leak-check=yes"); - this->MemoryTesterOptions.push_back("--show-reachable=yes"); - this->MemoryTesterOptions.push_back("--workaround-gcc296-bugs=yes"); - this->MemoryTesterOptions.push_back("--num-callers=50"); - } - if ( this->CTest->GetCTestConfiguration( - "MemoryCheckSuppressionFile").size() ) - { - if ( !cmSystemTools::FileExists(this->CTest->GetCTestConfiguration( - "MemoryCheckSuppressionFile").c_str()) ) + case cmCTestMemCheckHandler::VALGRIND: + if ( this->MemoryTesterOptions.empty() ) { - cmCTestLog(this->CTest, ERROR_MESSAGE, - "Cannot find memory checker suppression file: " - << this->CTest->GetCTestConfiguration( - "MemoryCheckSuppressionFile").c_str() << std::endl); - return false; - } - std::string suppressions = "--suppressions=" - + this->CTest->GetCTestConfiguration("MemoryCheckSuppressionFile"); - this->MemoryTesterOptions.push_back(suppressions); - } - } - else if ( this->MemoryTester.find("purify") != std::string::npos ) - { - this->MemoryTesterStyle = cmCTestMemCheckHandler::PURIFY; - std::string outputFile; -#ifdef _WIN32 - if( this->CTest->GetCTestConfiguration( + this->MemoryTesterOptions.push_back("-q"); + this->MemoryTesterOptions.push_back("--tool=memcheck"); + this->MemoryTesterOptions.push_back("--leak-check=yes"); + this->MemoryTesterOptions.push_back("--show-reachable=yes"); + this->MemoryTesterOptions.push_back("--workaround-gcc296-bugs=yes"); + this->MemoryTesterOptions.push_back("--num-callers=50"); + } + if ( this->CTest->GetCTestConfiguration( "MemoryCheckSuppressionFile").size() ) + { + if ( !cmSystemTools::FileExists(this->CTest->GetCTestConfiguration( + "MemoryCheckSuppressionFile").c_str()) ) + { + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Cannot find memory checker suppression file: " + << this->CTest->GetCTestConfiguration( + "MemoryCheckSuppressionFile").c_str() << std::endl); + return false; + } + std::string suppressions = "--suppressions=" + + this->CTest->GetCTestConfiguration("MemoryCheckSuppressionFile"); + this->MemoryTesterOptions.push_back(suppressions); + } + break; + case cmCTestMemCheckHandler::PURIFY: { - if( !cmSystemTools::FileExists(this->CTest->GetCTestConfiguration( - "MemoryCheckSuppressionFile").c_str()) ) + std::string outputFile; +#ifdef _WIN32 + if( this->CTest->GetCTestConfiguration( + "MemoryCheckSuppressionFile").size() ) { - cmCTestLog(this->CTest, ERROR_MESSAGE, - "Cannot find memory checker suppression file: " - << this->CTest->GetCTestConfiguration( - "MemoryCheckSuppressionFile").c_str() << std::endl); - return false; - } - std::string filterFiles = "/FilterFiles=" - + this->CTest->GetCTestConfiguration("MemoryCheckSuppressionFile"); - this->MemoryTesterOptions.push_back(filterFiles); - } - outputFile = "/SAVETEXTDATA="; + if( !cmSystemTools::FileExists(this->CTest->GetCTestConfiguration( + "MemoryCheckSuppressionFile").c_str()) ) + { + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Cannot find memory checker suppression file: " + << this->CTest->GetCTestConfiguration( + "MemoryCheckSuppressionFile").c_str() << std::endl); + return false; + } + std::string filterFiles = "/FilterFiles=" + + this->CTest->GetCTestConfiguration("MemoryCheckSuppressionFile"); + this->MemoryTesterOptions.push_back(filterFiles); + } + outputFile = "/SAVETEXTDATA="; #else - outputFile = "-log-file="; + outputFile = "-log-file="; #endif - outputFile += this->MemoryTesterOutputFile; - this->MemoryTesterOptions.push_back(outputFile); - } - else if ( this->MemoryTester.find("BC") != std::string::npos ) - { - this->BoundsCheckerXMLFile = this->MemoryTesterOutputFile; - std::string dpbdFile = this->CTest->GetBinaryDir() - + "/Testing/Temporary/MemoryChecker.DPbd"; - this->BoundsCheckerDPBDFile = dpbdFile; - this->MemoryTesterStyle = cmCTestMemCheckHandler::BOUNDS_CHECKER; - this->MemoryTesterOptions.push_back("/B"); - this->MemoryTesterOptions.push_back(dpbdFile); - this->MemoryTesterOptions.push_back("/X"); - this->MemoryTesterOptions.push_back(this->MemoryTesterOutputFile); - this->MemoryTesterOptions.push_back("/M"); - } - else - { - cmCTestLog(this->CTest, ERROR_MESSAGE, - "Do not understand memory checker: " << this->MemoryTester.c_str() - << std::endl); - return false; + outputFile += this->MemoryTesterOutputFile; + this->MemoryTesterOptions.push_back(outputFile); + break; + } + case cmCTestMemCheckHandler::BOUNDS_CHECKER: + { + this->BoundsCheckerXMLFile = this->MemoryTesterOutputFile; + std::string dpbdFile = this->CTest->GetBinaryDir() + + "/Testing/Temporary/MemoryChecker.DPbd"; + this->BoundsCheckerDPBDFile = dpbdFile; + this->MemoryTesterOptions.push_back("/B"); + this->MemoryTesterOptions.push_back(dpbdFile); + this->MemoryTesterOptions.push_back("/X"); + this->MemoryTesterOptions.push_back(this->MemoryTesterOutputFile); + this->MemoryTesterOptions.push_back("/M"); + break; + } + default: + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Do not understand memory checker: " << this->MemoryTester.c_str() + << std::endl); + return false; } std::vector::size_type cc; -- cgit v0.12 From de8bffc8f8b1d18987f23e8b343bcf82b37e4683 Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Mon, 1 Oct 2012 17:51:00 +0200 Subject: CTest: add a test for CTEST_CUSTOM_MEMCHECK_IGNORE --- Tests/CTestTestMemcheck/CMakeLists.txt | 7 ++++++- .../DummyValgrindIgnoreMemcheck/CMakeLists.txt | 6 ++++++ .../DummyValgrindIgnoreMemcheck/CTestConfig.cmake | 9 ++++++++ .../DummyValgrindIgnoreMemcheck/test.cmake.in | 24 ++++++++++++++++++++++ 4 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 Tests/CTestTestMemcheck/DummyValgrindIgnoreMemcheck/CMakeLists.txt create mode 100644 Tests/CTestTestMemcheck/DummyValgrindIgnoreMemcheck/CTestConfig.cmake create mode 100644 Tests/CTestTestMemcheck/DummyValgrindIgnoreMemcheck/test.cmake.in diff --git a/Tests/CTestTestMemcheck/CMakeLists.txt b/Tests/CTestTestMemcheck/CMakeLists.txt index 544d0ed..b4a5f15 100644 --- a/Tests/CTestTestMemcheck/CMakeLists.txt +++ b/Tests/CTestTestMemcheck/CMakeLists.txt @@ -23,7 +23,8 @@ set_target_properties(pseudo_BC PROPERTIES OUTPUT_NAME BC) add_executable(memcheck_fail "${CMAKE_CURRENT_BINARY_DIR}/ret1.c") foreach (_test IN ITEMS Unknown NotExist DummyValgrind DummyValgrindPrePost - DummyValgrindFailPre DummyValgrindFailPost DummyPurify DummyBC) + DummyValgrindFailPre DummyValgrindFailPost DummyPurify DummyBC + DummyValgrindIgnoreMemcheck) configure_file( "${CMAKE_CURRENT_SOURCE_DIR}/${_test}/test.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/${_test}/test.cmake" @@ -64,6 +65,10 @@ foreach (_pp Pre Post) PASS_REGULAR_EXPRESSION "\nProblem running command: ${CMAKE_CURRENT_BINARY_DIR}[^\n]*fail[^\n]*\n(.*\n)?Problem executing ${_pp_lower}-memcheck command\\(s\\\).\n(.*\n)?Error in read script: ${CMAKE_CURRENT_BINARY_DIR}/DummyValgrindFail${_pp}/test.cmake\n") endforeach () +set_tests_properties(CTestTestMemcheckDummyValgrindIgnoreMemcheck + PROPERTIES + PASS_REGULAR_EXPRESSION "\n2/2 Test #2: RunCMakeAgain .*\n1/1 MemCheck #1: RunCMake .*${NORMAL_CTEST_OUTPUT}") + set_tests_properties(CTestTestMemcheckDummyPurify PROPERTIES PASS_REGULAR_EXPRESSION "\nCannot find memory tester output file: ${CMAKE_CURRENT_BINARY_DIR}/DummyPurify/Testing/Temporary/MemoryChecker.log\n(.*\n)?Error in read script: ${CMAKE_CURRENT_BINARY_DIR}/DummyPurify/test.cmake\n") diff --git a/Tests/CTestTestMemcheck/DummyValgrindIgnoreMemcheck/CMakeLists.txt b/Tests/CTestTestMemcheck/DummyValgrindIgnoreMemcheck/CMakeLists.txt new file mode 100644 index 0000000..5d437d1 --- /dev/null +++ b/Tests/CTestTestMemcheck/DummyValgrindIgnoreMemcheck/CMakeLists.txt @@ -0,0 +1,6 @@ +cmake_minimum_required(VERSION 2.8.9) +project(CTestTestMemcheckDummyValgrindIgnoreMemcheck) +include(CTest) + +add_test (RunCMake "${CMAKE_COMMAND}") +add_test (RunCMakeAgain "${CMAKE_COMMAND}") diff --git a/Tests/CTestTestMemcheck/DummyValgrindIgnoreMemcheck/CTestConfig.cmake b/Tests/CTestTestMemcheck/DummyValgrindIgnoreMemcheck/CTestConfig.cmake new file mode 100644 index 0000000..6eee3e6 --- /dev/null +++ b/Tests/CTestTestMemcheck/DummyValgrindIgnoreMemcheck/CTestConfig.cmake @@ -0,0 +1,9 @@ +set (CTEST_PROJECT_NAME "CTestTestMemcheckDummyValgrindIgnoreMemcheck") +set (CTEST_NIGHTLY_START_TIME "21:00:00 EDT") +set (CTEST_DART_SERVER_VERSION "2") +set(CTEST_DROP_METHOD "http") +set(CTEST_DROP_SITE "www.cdash.org") +set(CTEST_DROP_LOCATION "/CDash/submit.php?project=PublicDashboard") +set(CTEST_DROP_SITE_CDASH TRUE) + +set(CTEST_CUSTOM_MEMCHECK_IGNORE RunCMakeAgain) diff --git a/Tests/CTestTestMemcheck/DummyValgrindIgnoreMemcheck/test.cmake.in b/Tests/CTestTestMemcheck/DummyValgrindIgnoreMemcheck/test.cmake.in new file mode 100644 index 0000000..031a232 --- /dev/null +++ b/Tests/CTestTestMemcheck/DummyValgrindIgnoreMemcheck/test.cmake.in @@ -0,0 +1,24 @@ +cmake_minimum_required(VERSION 2.8.9) + +# Settings: +set(CTEST_DASHBOARD_ROOT "@CMAKE_CURRENT_BINARY_DIR@") +set(CTEST_SITE "@SITE@") +set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-MemcheckDummyValgrindIgnoreMemcheck") + +set(CTEST_SOURCE_DIRECTORY "@CMAKE_CURRENT_SOURCE_DIR@/DummyValgrindIgnoreMemcheck") +set(CTEST_BINARY_DIRECTORY "@CMAKE_CURRENT_BINARY_DIR@/DummyValgrindIgnoreMemcheck") +set(CTEST_CVS_COMMAND "@CVSCOMMAND@") +set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") +set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") +set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") +set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") + +set(CTEST_MEMORYCHECK_COMMAND "${PSEUDO_VALGRIND}") + +#CTEST_EMPTY_BINARY_DIRECTORY(${CTEST_BINARY_DIRECTORY}) + +CTEST_START(Experimental) +CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +#CTEST_BUILD(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +CTEST_MEMCHECK(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) -- cgit v0.12 From 995a35fe12e9582c4488a7bc2deb66b0e4d25315 Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Tue, 2 Oct 2012 21:56:48 +0200 Subject: CTest: add a check with a quoted memory checker --- Tests/CTestTestMemcheck/CMakeLists.txt | 13 +++++++++---- Tests/CTestTestMemcheck/UnknownQuoted/CMakeLists.txt | 5 +++++ .../CTestTestMemcheck/UnknownQuoted/CTestConfig.cmake | 7 +++++++ Tests/CTestTestMemcheck/UnknownQuoted/test.cmake.in | 18 ++++++++++++++++++ 4 files changed, 39 insertions(+), 4 deletions(-) create mode 100644 Tests/CTestTestMemcheck/UnknownQuoted/CMakeLists.txt create mode 100644 Tests/CTestTestMemcheck/UnknownQuoted/CTestConfig.cmake create mode 100644 Tests/CTestTestMemcheck/UnknownQuoted/test.cmake.in diff --git a/Tests/CTestTestMemcheck/CMakeLists.txt b/Tests/CTestTestMemcheck/CMakeLists.txt index b4a5f15..2730a61 100644 --- a/Tests/CTestTestMemcheck/CMakeLists.txt +++ b/Tests/CTestTestMemcheck/CMakeLists.txt @@ -22,8 +22,10 @@ set_target_properties(pseudo_BC PROPERTIES OUTPUT_NAME BC) # binary to be used as pre- and post-memcheck command that fails add_executable(memcheck_fail "${CMAKE_CURRENT_BINARY_DIR}/ret1.c") -foreach (_test IN ITEMS Unknown NotExist DummyValgrind DummyValgrindPrePost - DummyValgrindFailPre DummyValgrindFailPost DummyPurify DummyBC +foreach (_test IN ITEMS Unknown UnknownQuoted NotExist + DummyValgrind DummyValgrindPrePost + DummyValgrindFailPre DummyValgrindFailPost + DummyPurify DummyBC DummyValgrindIgnoreMemcheck) configure_file( "${CMAKE_CURRENT_SOURCE_DIR}/${_test}/test.cmake.in" @@ -44,8 +46,11 @@ string(REPLACE "\\" "\\\\" CMAKE_COMMAND_ESCAPED "${CMAKE_COMMAND}") string(REPLACE "(" "\\(" CMAKE_COMMAND_ESCAPED "${CMAKE_COMMAND_ESCAPED}") string(REPLACE ")" "\\)" CMAKE_COMMAND_ESCAPED "${CMAKE_COMMAND_ESCAPED}") string(REPLACE "+" "\\+" CMAKE_COMMAND_ESCAPED "${CMAKE_COMMAND_ESCAPED}") -set_tests_properties(CTestTestMemcheckUnknown PROPERTIES - PASS_REGULAR_EXPRESSION "Do not understand memory checker: ${CMAKE_COMMAND_ESCAPED}\n(.*\n)?Error in read script: ${CMAKE_CURRENT_BINARY_DIR}/Unknown/test.cmake\n") + +foreach (_unkn Unknown UnknownQuoted) + set_tests_properties(CTestTestMemcheck${_unkn} PROPERTIES + PASS_REGULAR_EXPRESSION "Do not understand memory checker: ${CMAKE_COMMAND_ESCAPED}\n(.*\n)?Error in read script: ${CMAKE_CURRENT_BINARY_DIR}/${_unkn}/test.cmake\n") +endforeach () set_tests_properties(CTestTestMemcheckNotExist PROPERTIES PASS_REGULAR_EXPRESSION "Memory checker \\(MemoryCheckCommand\\) not set, or cannot find the specified program.") diff --git a/Tests/CTestTestMemcheck/UnknownQuoted/CMakeLists.txt b/Tests/CTestTestMemcheck/UnknownQuoted/CMakeLists.txt new file mode 100644 index 0000000..6f49c61 --- /dev/null +++ b/Tests/CTestTestMemcheck/UnknownQuoted/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 2.8.9) +project(CTestTestMemcheckUnknownQuoted) +include(CTest) + +add_test (RunCMake "\"${CMAKE_COMMAND}\"") diff --git a/Tests/CTestTestMemcheck/UnknownQuoted/CTestConfig.cmake b/Tests/CTestTestMemcheck/UnknownQuoted/CTestConfig.cmake new file mode 100644 index 0000000..f0233a7 --- /dev/null +++ b/Tests/CTestTestMemcheck/UnknownQuoted/CTestConfig.cmake @@ -0,0 +1,7 @@ +set (CTEST_PROJECT_NAME "CTestTestMemcheckUnknownQuoted") +set (CTEST_NIGHTLY_START_TIME "21:00:00 EDT") +set (CTEST_DART_SERVER_VERSION "2") +set(CTEST_DROP_METHOD "http") +set(CTEST_DROP_SITE "www.cdash.org") +set(CTEST_DROP_LOCATION "/CDash/submit.php?project=PublicDashboard") +set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/Tests/CTestTestMemcheck/UnknownQuoted/test.cmake.in b/Tests/CTestTestMemcheck/UnknownQuoted/test.cmake.in new file mode 100644 index 0000000..e2bfb60 --- /dev/null +++ b/Tests/CTestTestMemcheck/UnknownQuoted/test.cmake.in @@ -0,0 +1,18 @@ +cmake_minimum_required(VERSION 2.8.9) + +# Settings: +set(CTEST_DASHBOARD_ROOT "@CMAKE_CURRENT_BINARY_DIR@") +set(CTEST_SITE "@SITE@") +set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-MemcheckUnknownQuoted") + +set(CTEST_SOURCE_DIRECTORY "@CMAKE_CURRENT_SOURCE_DIR@/UnknownQuoted") +set(CTEST_BINARY_DIRECTORY "@CMAKE_CURRENT_BINARY_DIR@/UnknownQuoted") +set(CTEST_CVS_COMMAND "@CVSCOMMAND@") +set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") +set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") +set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") +set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") +set(CTEST_MEMORYCHECK_COMMAND "@CMAKE_COMMAND@") + +CTEST_START(Experimental) +CTEST_MEMCHECK(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) -- cgit v0.12