If ENABLE_TESTING is ON, you can now use memory checking tools to run the test suite and check for memory leaks. By default CMake will try to find valgrind in your path and set some default options. To customize this behavior use the MEMORYCHECK_COMMAND and MEMORYCHECK_COMMAND_OPTIONS variables. To run tests with the memory checker, use the MemCheck action in ctest: Run entire test suite: ctest -T MemCheck Run single test: ctest -T MemCheck -R TESTNAME Run test in verbose mode: ctest -V -T MemCheck -R TESTNAME
31 lines
1.3 KiB
CMake
31 lines
1.3 KiB
CMake
###############################################################################
|
|
# Testing
|
|
###############################################################################
|
|
option(ENABLE_TESTING "Enable testing" OFF)
|
|
if(ENABLE_TESTING)
|
|
find_program(VALGRIND_BINARY NAMES valgrind)
|
|
set(VALGRIND_DEFAULT_OPTIONS "--leak-check=full --show-leak-kinds=all --track-origins=yes")
|
|
|
|
if(BUILD_MPI)
|
|
set(VALGRIND_DEFAULT_OPTIONS "${VALGRIND_DEFAULT_OPTIONS} --suppressions=${LAMMPS_TOOLS_DIR}/valgrind/OpenMP.supp")
|
|
endif()
|
|
|
|
if(BUILD_OMP)
|
|
set(VALGRIND_DEFAULT_OPTIONS "${VALGRIND_DEFAULT_OPTIONS} --suppressions=${LAMMPS_TOOLS_DIR}/valgrind/OpenMP.supp")
|
|
endif()
|
|
|
|
if(PKG_PYTHON)
|
|
set(VALGRIND_DEFAULT_OPTIONS "${VALGRIND_DEFAULT_OPTIONS} --suppressions=${LAMMPS_TOOLS_DIR}/valgrind/Python3.supp")
|
|
endif()
|
|
|
|
set(MEMORYCHECK_COMMAND "${VALGRIND_BINARY}" CACHE FILEPATH "Memory Check Command")
|
|
set(MEMORYCHECK_COMMAND_OPTIONS "${VALGRIND_DEFAULT_OPTIONS}" CACHE STRING "Memory Check Command Options")
|
|
|
|
include(CTest)
|
|
|
|
enable_testing()
|
|
get_filename_component(LAMMPS_UNITTEST_DIR ${LAMMPS_SOURCE_DIR}/../unittest ABSOLUTE)
|
|
get_filename_component(LAMMPS_UNITTEST_BIN ${CMAKE_BINARY_DIR}/unittest ABSOLUTE)
|
|
add_subdirectory(${LAMMPS_UNITTEST_DIR} ${LAMMPS_UNITTEST_BIN})
|
|
endif()
|