How do I make ctest run a program with valgrind without dart?

后端 未结 4 2055
生来不讨喜
生来不讨喜 2021-01-31 09:16

I want to write a CMakeLists.txt so that I can run my tests normally or with valgrind. I have seen much on integrating ctest with valgrind but all with the assumption that you w

4条回答
  •  情歌与酒
    2021-01-31 09:55

    I use valgrind for my memory check. To configure valgrind, I define the following variables in my build system:

    find_program( MEMORYCHECK_COMMAND valgrind )
    set( MEMORYCHECK_COMMAND_OPTIONS "--trace-children=yes --leak-check=full" )
    

    Also, in there is my valgrind suppression file:

    set( MEMORYCHECK_SUPPRESSIONS_FILE "${PROJECT_SOURCE_DIR}/valgrind_suppress.txt" )
    

    After you write your CMakeLists.txt files and configure valgrind correctly in them, you can run the following command:

    cmake -G ... (to configure your build)
    ctest -D ExperimentalBuild (this will build your code)
    ctest -R testName -D ExperimentalTest (just runs the test)
    ctest -R testName -D ExperimentalMemCheck (to run the test under valgrind)
    

    This will trick your build system to run the test automation locally. It expects you to run:

    ctest -R testName -D ExperimentalSubmit
    

    next, to submit to the (default or your) Dashboard, but you don't need to go through this step to run what you want. The results will be stored in the Testing/Temporary/ directory.

提交回复
热议问题