1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-14 02:08:27 +08:00

ci: support valgrind memcheck runs

This commit is contained in:
Ben Boeckel
2025-09-29 10:13:33 -04:00
parent f22d8a3f36
commit f1e8762a8b
2 changed files with 56 additions and 0 deletions

View File

@@ -146,6 +146,19 @@
junit:
- ${CMAKE_CI_BUILD_DIR}/junit.xml
.cmake_valgrind_artifacts:
artifacts:
expire_in: 1d
when: always
reports:
annotations:
- ${CMAKE_CI_BUILD_DIR}/annotations.json
junit:
- ${CMAKE_CI_BUILD_DIR}/junit.xml
paths:
# Valgrind logs.
- ${CMAKE_CI_BUILD_DIR}/Testing/Temporary/MemoryChecker.*.log
.cmake_sphinx_artifacts:
artifacts:
expire_in: 1d

View File

@@ -5,3 +5,46 @@ set(lsan_suppressions "${CMAKE_CURRENT_LIST_DIR}/ctest_memcheck_$ENV{CMAKE_CONFI
if (EXISTS "${lsan_suppressions}")
set(ENV{LSAN_OPTIONS} "suppressions='${lsan_suppressions}'")
endif ()
if (CTEST_MEMORYCHECK_TYPE STREQUAL "Valgrind")
find_program(valgrind_exe NAMES valgrind)
set(CTEST_MEMORYCHECK_COMMAND "${valgrind_exe}")
set(valgrind_suppressions "${CMAKE_CURRENT_LIST_DIR}/ctest_memcheck_$ENV{CMAKE_CONFIGURATION}.valgrind.supp")
set(common_valgrind_suppressions "${CMAKE_CURRENT_LIST_DIR}/ctest_memcheck_$ENV{CMAKE_VALGRIND_CONFIGURATION}.valgrind.supp")
if (EXISTS "${valgrind_suppressions}")
set(CTEST_MEMORYCHECK_SUPPRESSIONS_FILE "${valgrind_suppressions}")
elseif (EXISTS "${common_valgrind_suppressions}")
set(CTEST_MEMORYCHECK_SUPPRESSIONS_FILE "${common_valgrind_suppressions}")
endif ()
set(valgrind_skip
/bin/*
/sbin/*
/usr/bin/*
/usr/lib64/qt5/bin/*
/usr/lib64/qt6/bin/*
/usr/lib64/qt6/libexec/*
bootstrap
sample_script
*/Tests/CTestTest2/kwsysBin/*
*/Tests/CTestTestCrash/Crash
*QtAutogen
# Ignore ISPC files which may contain unimplemented instructions.
*/build/Tests/ISPC/TryCompile/ISPCTryCompile
# Ignore anything CI downloads.
*/.gitlab/*)
list(JOIN valgrind_skip "," valgrind_skip)
string(CONCAT valgrind_options
"--gen-suppressions=all "
"--child-silent-after-fork=yes "
"--trace-children=yes "
"--trace-children-skip=${valgrind_skip} "
"--track-origins=yes "
"-q "
"--leak-check=yes "
"--show-reachable=yes "
"--num-callers=50 "
"-v ")
set(CTEST_MEMORYCHECK_COMMAND_OPTIONS "${valgrind_options}")
endif ()