문제

I have a C++ project in CMake and I have implemented unit tests (using GoogleTest) as well as integration tests i.e. executing applications and checking the results using regexp e.g.

add_test(NAME MyAppIntegration.testRefitRunMse COMMAND my_application "--refit=true")
set_tests_properties(MyAppIntegration.testRefitRunMse PROPERTIES PASS_REGULAR_EXPRESSION "mse\\=1\\.53611e\\-05")

Now I would like to do the same as above but running the application to detect memory errors e.g. simply run ./my_application and check for memory errors with valgrind. How can I do that? Note that I am aware of ctest -D ExperimentalMemCheck and ctest -T memcheck but here I end up with the error Cannot find file DartConfiguration.tcl which seems related to the Dashboard configuration that I don't need.

도움이 되었습니까?

해결책

OK I found a possible solution. Adding these lines to my CMakeLists.txt:

## valgrind
find_program(CTEST_MEMORYCHECK_COMMAND NAMES valgrind)
INCLUDE(Dart)

generates the needed DartConfiguration.tcl whatever that is, and then re-invoking:

ctest -T memcheck

runs all tests also checking for memory errors.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top