[CMake] multi-stage tests with valgrind

Leif Walsh leif.walsh at gmail.com
Tue Apr 24 12:03:48 EDT 2012


Hi,

I have some tests that need to be run as distinct commands, for example:

foo_test --crash
test "$?" != "0"
foo_test --recover

Right now, I have shell scripts that do this, so I have something like

add_test(foo_test run_foo_test.sh ${CMAKE_CFG_INTDIR}/foo_test)

but this doesn't work with MemCheck.

So I add

add_test(foo_test_memcheck run_foo_test.sh ${CMAKE_CFG_INTDIR}/foo_test ${CMAKE_MEMORYCHECK_COMMAND} ${CMAKE_MEMORYCHECK_COMMAND_OPTIONS})

but now, if these tests run concurrently, the two concurrent invocations
of foo_test may trample on each others' directories.

One way to fix this is to give foo_test an option to specify the
directory it will write into, but this is a large undertaking.

There seems like there should be a better way.  Is there another way to
tell cmake that a test involves running multiple commands in succession
as part of a single test?

I see in http://stackoverflow.com/questions/3065220/ctest-with-multiple-commands
that one suggestion is to have a cmake script (rather than my shell
script) that gets invoked with

add_test(NAME foo_test
    COMMAND ${CMAKE_COMMAND} -Dtestbin=$<TARGET_FILE:foo_test> -P run_foo_test.cmake)

In this case, will the test be run with valgrind properly when run with
-D ExperimentalMemCheck, or will valgrind just be run on the cmake
binary?  I expect the latter.

-- 
Cheers,
Leif


More information about the CMake mailing list