]> git.puffer.fish Git - mirror/frr.git/commitdiff
tests: add ability to show all types of valgrind memleaks 14746/head
authorChristian Hopps <chopps@labn.net>
Tue, 7 Nov 2023 20:27:33 +0000 (15:27 -0500)
committerChristian Hopps <chopps@labn.net>
Tue, 7 Nov 2023 20:29:37 +0000 (15:29 -0500)
Signed-off-by: Christian Hopps <chopps@labn.net>
doc/developer/topotests.rst
tests/topotests/conftest.py
tests/topotests/lib/topotest.py

index 35c2bd4202263099091d9e1a752e91d6363fa591..2df01078898a8ca49b1394074dbf1a63248fd71e 100644 (file)
@@ -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
 
index b6b2880db8984de08b16b89cfc5ac194363db69c..d4ab573ddee9551bd0678a9e902bb7ccf8e8ecb1 100755 (executable)
@@ -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",
index 3eb808ac4f452f7e25726be2c2ede5771eb5848a..04c285a053117f515c41cbdff6ca0713400bfc49 100644 (file)
@@ -1806,6 +1806,7 @@ class Router(Node):
         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")
 
@@ -1938,6 +1939,8 @@ class Router(Node):
                         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"