Skip to content

Commit

Permalink
tests: add ability to show all types of valgrind memleaks
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Hopps <[email protected]>
  • Loading branch information
choppsv1 committed Nov 7, 2023
1 parent cf51579 commit c27b054
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
13 changes: 8 additions & 5 deletions doc/developer/topotests.rst
Original file line number Diff line number Diff line change
Expand Up @@ -639,11 +639,14 @@ Detecting Memleaks with Valgrind
""""""""""""""""""""""""""""""""

Topotest can automatically launch all daemons with ``valgrind`` to check for
memleaks. This is enabled by specifying 1 or 2 CLI arguments.
``--valgrind-memleaks`` will enable general memleak detection, and
``--valgrind-extra`` enables extra functionality including generating a
suppression file. The suppression file ``tools/valgrind.supp`` is used when
memleak detection is enabled.
memleaks. This is enabled by specifying 1 to 3 CLI arguments.
``--valgrind-memleaks`` enables memleak detection. ``--valgrind-extra`` enables
extra functionality including generating a suppression file. The suppression
file ``tools/valgrind.supp`` is used when memleak detection is enabled. Finally,
``--valgrind-leak-kinds=KINDS`` can be used to modify what types of links are
reported. This corresponds to valgrind's ``--show-link-kinds`` arg. The value is
either ``all`` or a comma-separated list of types:
``definite,indirect,possible,reachable``. The default is ``definite,possible``.

.. code:: shell
Expand Down
6 changes: 6 additions & 0 deletions tests/topotests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,12 @@ def pytest_addoption(parser):
help="Generate suppression file, and enable more precise (slower) valgrind checks",
)

parser.addoption(
"--valgrind-leak-kinds",
metavar="KIND[,KIND...]",
help="Comma-separated list of valgrind leak kinds or 'all'",
)

parser.addoption(
"--valgrind-memleaks",
action="store_true",
Expand Down
3 changes: 3 additions & 0 deletions tests/topotests/lib/topotest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1806,6 +1806,7 @@ def startRouterDaemons(self, daemons=None, tgen=None):
gdb_routers = g_pytest_config.get_option_list("--gdb-routers")
gdb_use_emacs = bool(g_pytest_config.option.gdb_use_emacs)
valgrind_extra = bool(g_pytest_config.option.valgrind_extra)
valgrind_leak_kinds = g_pytest_config.option.valgrind_leak_kinds
valgrind_memleaks = bool(g_pytest_config.option.valgrind_memleaks)
strace_daemons = g_pytest_config.get_option_list("--strace-daemons")

Expand Down Expand Up @@ -1938,6 +1939,8 @@ def do_gdb():
f" --log-file={valgrind_logbase}.%p"
f" --leak-check=full --suppressions={supp_file}"
)
if valgrind_leak_kinds:
cmdenv += f" --show-leak-kinds={valgrind_leak_kinds}"
if valgrind_extra:
cmdenv += (
" --gen-suppressions=all --expensive-definedness-checks=yes"
Expand Down

0 comments on commit c27b054

Please sign in to comment.