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

后端 未结 4 2058
生来不讨喜
生来不讨喜 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

    It seems the following is sufficient. I wasn't using separate_arguments before, that was my stupidity.

    function(add_memcheck_test name binary)
      set(memcheck_command "${CMAKE_MEMORYCHECK_COMMAND} ${CMAKE_MEMORYCHECK_COMMAND_OPTIONS}")
      separate_arguments(memcheck_command)
      add_test(${name} ${binary} ${ARGN})
      add_test(memcheck_${name} ${memcheck_command} ./${binary} ${ARGN})
    endfunction(add_memcheck_test)
    
    function(set_memcheck_test_properties name)
      set_tests_properties(${name} ${ARGN})
      set_tests_properties(memcheck_${name} ${ARGN})
    endfunction(set_memcheck_test_properties)
    

提交回复
热议问题