Tests: add a test with custom options passed to valgrind

This commit is contained in:
Rolf Eike Beer 2013-05-09 12:24:09 +02:00
parent 61ddb9319b
commit 159c3e91ac
2 changed files with 15 additions and 0 deletions

View File

@ -101,6 +101,12 @@ set(CTEST_EXTRA_CONFIG "set(CTEST_MEMORYCHECK_SUPPRESSIONS_FILE \"\${CMAKE_CURRE
unset(CMAKELISTS_EXTRA_CODE) unset(CMAKELISTS_EXTRA_CODE)
gen_mc_test(DummyValgrindInvalidSupFile "\${PSEUDO_VALGRIND}") gen_mc_test(DummyValgrindInvalidSupFile "\${PSEUDO_VALGRIND}")
# CTest will add the logfile option as last option. Tell the dummy memcheck
# to ignore that argument. This will cause the logfile to be missing, which
# will be the prove for us that the custom option is indeed used.
set(CTEST_EXTRA_CONFIG "set(CTEST_MEMORYCHECK_COMMAND_OPTIONS \"--\")")
gen_mc_test(DummyValgrindCustomOptions "\${PSEUDO_VALGRIND}")
unset(CTEST_EXTRA_CONFIG) unset(CTEST_EXTRA_CONFIG)
gen_mc_test(NotExist "\${CTEST_BINARY_DIRECTORY}/no-memcheck-exe") gen_mc_test(NotExist "\${CTEST_BINARY_DIRECTORY}/no-memcheck-exe")
@ -141,3 +147,6 @@ set_tests_properties(CTestTestMemcheckDummyBC PROPERTIES
set_tests_properties(CTestTestMemcheckDummyValgrindInvalidSupFile PROPERTIES set_tests_properties(CTestTestMemcheckDummyValgrindInvalidSupFile PROPERTIES
PASS_REGULAR_EXPRESSION "\nCannot find memory checker suppression file: ${CMAKE_CURRENT_BINARY_DIR}/does-not-exist\n") PASS_REGULAR_EXPRESSION "\nCannot find memory checker suppression file: ${CMAKE_CURRENT_BINARY_DIR}/does-not-exist\n")
set_tests_properties(CTestTestMemcheckDummyValgrindCustomOptions PROPERTIES
PASS_REGULAR_EXPRESSION "\nCannot find memory tester output file: ${CMAKE_CURRENT_BINARY_DIR}/DummyValgrindCustomOptions/Testing/Temporary/MemoryChecker.log\n(.*\n)?Error in read script: ${CMAKE_CURRENT_BINARY_DIR}/DummyValgrindCustomOptions/test.cmake\n")

View File

@ -28,6 +28,12 @@ main(int argc, char **argv)
std::string logfile; std::string logfile;
for (int i = 1; i < argc; i++) { for (int i = 1; i < argc; i++) {
std::string arg = argv[i]; std::string arg = argv[i];
// stop processing options, this allows to force
// the logfile to be ignored
if (arg == "--")
{
break;
}
if (arg.find(logarg) == 0) if (arg.find(logarg) == 0)
{ {
if (nextarg) if (nextarg)