CTest MemCheck: Expand log-file to include PID
CMake 3.9.2 (built from source) - Ubuntu 16.04.3 LTS - 32 bits
When running CTest under MemCheck: ctest -T memcheck
- the log-file setting for valgrind doesn't include the PID, which means running with --trace-children=yes
results in jumbled log output.
There's nothing in the manual for updating the log file setting: https://cmake.org/cmake/help/latest/manual/cmake-variables.7.html#variables-for-ctest
Current log file appears to be: <BUILD_DIR>/Testing/Temporary/MemoryChecker.<TEST_NUMBER>.log
It should include %p
in there somewhere, eg: <BUILD_DIR>/Testing/Temporary/MemoryChecker.<TEST_NUMBER>-%p.log
My custom setting in CMake config, note also that they don't have the CTEST_
prefix as shown in the manual. I might be doing this incorrectly, however valgrind
is running with them.
# CTest memory check settings - ctest -T memcheck
# Can't trace children due to log output file format:
# --log-file=<BUILD_DIR>/Testing/Temporary/MemoryChecker.<TEST_NUMBER>.log
set( MEMORYCHECK_COMMAND "/usr/bin/valgrind" )
set( MEMORYCHECK_COMMAND_OPTIONS "--leak-check=full --show-reachable=yes --track-origins=yes --malloc-fill=0xEE --free-fill=0xFF --leak-check-heuristics=none -v --track-fds=yes --error-limit=no --show-below-main=yes --read-var-info=yes --gen-suppressions=all" )
set( MEMORYCHECK_SUPPRESSIONS_FILE "/home/ndt/playpen/valgrind-suppression.txt" )
Results in the following:
Memory check command: /usr/bin/valgrind "--log-file=/home/ndt/playpen/build/Testing/Temporary/MemoryChecker.1.log" "--leak-check=full" "--show-reachable=yes" "--track-origins=yes" "--malloc-fill=0xEE" "--free-fill=0xFF" "--leak-check-heuristics=none" "-v" "--track-fds=yes" "--error-limit=no" "--show-below-main=yes" "--read-var-info=yes" "--gen-suppressions=all" "--suppressions=/home/ndt/playpen/valgrind-suppression.txt"
Manually setting the --log-file
option for valgrind
works - but I'm don't know how to the get the test number.
Memory check command: /usr/bin/valgrind "--log-file=/home/ndt/playpen/build/Testing/Temporary/MemoryChecker.1.log" "--leak-check=full" "--show-reachable=yes" "--track-origins=yes" "--malloc-fill=0xEE" "--free-fill=0xFF" "--leak-check-heuristics=none" "-v" "--track-fds=yes" "--error-limit=no" "--show-below-main=yes" "--read-var-info=yes" "--gen-suppressions=all" "--log-file=mylog-%p.log" "--suppressions=/home/ndt/playpen/valgrind-suppression.txt"