Add memory checker support in CMake

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
This commit is contained in:
Richard Berger
2020-06-23 13:23:11 -04:00
parent 5d1d406e01
commit 8cec13a038
4 changed files with 397 additions and 0 deletions

145
tools/valgrind/Python3.supp Normal file
View File

@ -0,0 +1,145 @@
{
Python3_main_1
Memcheck:Leak
match-leak-kinds: reachable
fun:malloc
fun:PyObject_Malloc
...
fun:_Py_UnixMain
}
{
Python3_main_2
Memcheck:Leak
match-leak-kinds: reachable
fun:malloc
fun:PyObject_Malloc
fun:PyUnicode_New
...
fun:_Py_Init_posix
...
}
{
Python3_main_3
Memcheck:Leak
match-leak-kinds: possible
fun:malloc
fun:PyObject_Malloc
...
fun:_Py_UnixMain
...
}
{
Python3_main_4
Memcheck:Leak
match-leak-kinds: reachable
fun:malloc
fun:PyObject_Malloc
fun:PyUnicode_New
...
fun:PyInit_posix
...
}
{
Python3_eval_1
Memcheck:Leak
match-leak-kinds: reachable
fun:malloc
fun:PyObject_Malloc
...
fun:_PyEval_EvalFrameDefault
}
{
Python3_eval_2
Memcheck:Leak
match-leak-kinds: possible
fun:malloc
fun:PyObject_Malloc
...
fun:_PyEval_EvalFrameDefault
}
{
Python3_eval_3
Memcheck:Leak
match-leak-kinds: possible
fun:malloc
fun:PyObject_Malloc
...
fun:_PyEval_EvalCodeWithName
fun:PyEval_EvalCodeEx
}
{
Python3_call_1
Memcheck:Leak
match-leak-kinds: reachable
fun:malloc
fun:PyObject_Malloc
fun:PyCode_New
...
fun:_PyCFunction_FastCallKeywords
}
{
Python3_call_2
Memcheck:Leak
match-leak-kinds: possible
fun:malloc
fun:PyObject_Malloc
fun:PyUnicode_New
...
fun:_PyMethodDef_RawFastCallKeywords
fun:_PyCFunction_FastCallKeywords
}
{
Python3_call_3
Memcheck:Leak
match-leak-kinds: reachable
fun:malloc
fun:PyObject_Malloc
fun:PyBytes_FromStringAndSize
...
fun:_PyMethodDef_RawFastCallKeywords
}
{
Python3_call_4
Memcheck:Leak
match-leak-kinds: reachable
fun:malloc
fun:PyObject_Malloc
fun:_PyObject_GC_Malloc
fun:PyType_GenericAlloc
...
fun:_PyMethodDef_RawFastCallKeywords
fun:_PyCFunction_FastCallKeywords
...
}
{
Python3_call_5
Memcheck:Leak
match-leak-kinds: reachable
fun:malloc
fun:PyObject_Malloc
fun:_PyObject_GC_Malloc
fun:PyType_GenericAlloc
...
fun:_PyMethodDef_RawFastCallKeywords
}
{
Python3_tuple_1
Memcheck:Leak
match-leak-kinds: possible
fun:malloc
fun:PyObject_Malloc
fun:_PyObject_GC_Malloc
fun:_PyObject_GC_NewVar
fun:PyTuple_New
...
}
{
Python3_unicode_1
Memcheck:Leak
match-leak-kinds: reachable
fun:malloc
fun:PyObject_Malloc
fun:PyUnicode_New
fun:PyUnicode_FromKindAndData
...
}