]> git.puffer.fish Git - mirror/frr.git/commitdiff
topogen: add memory leak report configuration
authorRafael Zalamena <rzalamena@gmail.com>
Tue, 27 Jun 2017 22:40:54 +0000 (19:40 -0300)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 28 Nov 2018 01:22:11 +0000 (20:22 -0500)
Allow memory leak to be configured from the configuration file.

tests/topotests/GUIDELINES.md
tests/topotests/lib/topogen.py
tests/topotests/pytest.ini

index 8c26c837b97f98ed58c18dc3356f1542dcd52b6b..aeec70f8be6dc7bfe94077815b983f6de2b54971 100644 (file)
@@ -44,8 +44,13 @@ r1-zebra.out # zebra stdout output
 You can also run memory leak tests to get reports:
 
 ```shell
+$ # Set the environment variable to apply to a specific test...
 $ sudo env TOPOTESTS_CHECK_MEMLEAK="/tmp/memleak_report_" pytest ospf-topo1/test_ospf_topo1.py
-...
+$ # ...or apply to all tests adding this line to the configuration file
+$ echo 'memleak_path = /tmp/memleak_report_' >> pytest.ini
+$ # You can also use your editor
+$ $EDITOR pytest.ini
+$ # After running tests you should see your files:
 $ ls /tmp/memleak_report_*
 memleak_report_test_ospf_topo1.txt
 ```
index ed0339d8f0956d4b14faaab10f9b52bb8527b010..2b2ea5dcb55505228c9f88e617f5bbbd9b5e645e 100644 (file)
@@ -123,6 +123,7 @@ class Topogen(object):
             'frrdir': '/usr/lib/frr',
             'quaggadir': '/usr/lib/quagga',
             'routertype': 'frr',
+            'memleak_path': None,
         }
         self.config = ConfigParser.ConfigParser(defaults)
         pytestini_path = os.path.join(CWD, '../pytest.ini')
@@ -144,6 +145,7 @@ class Topogen(object):
 
         params['frrdir'] = self.config.get(self.CONFIG_SECTION, 'frrdir')
         params['quaggadir'] = self.config.get(self.CONFIG_SECTION, 'quaggadir')
+        params['memleak_path'] = self.config.get(self.CONFIG_SECTION, 'memleak_path')
         if not params.has_key('routertype'):
             params['routertype'] = self.config.get(self.CONFIG_SECTION, 'routertype')
 
@@ -388,8 +390,11 @@ class TopoRouter(TopoGear):
         self.net = None
         self.name = name
         self.cls = cls
+        self.options = {}
         if not params.has_key('privateDirs'):
             params['privateDirs'] = self.PRIVATE_DIRS
+
+        self.options['memleak_path'] = params.get('memleak_path', None)
         self.tgen.topo.addNode(self.name, cls=self.cls, **params)
 
     def __str__(self):
@@ -472,9 +477,9 @@ class TopoRouter(TopoGear):
         testname: the test file name for identification
 
         NOTE: to run this you must have the environment variable
-        TOPOTESTS_CHECK_MEMLEAK set to the appropriated path.
+        TOPOTESTS_CHECK_MEMLEAK set or memleak_path configured in `pytest.ini`.
         """
-        memleak_file = os.environ.get('TOPOTESTS_CHECK_MEMLEAK')
+        memleak_file = os.environ.get('TOPOTESTS_CHECK_MEMLEAK') or self.options['memleak_path']
         if memleak_file is None:
             print "SKIPPED check on Memory leaks: Disabled (TOPOTESTS_CHECK_MEMLEAK undefined)"
             return
index 1866bae1cf10a5b1ee487d779b338a9654437779..9dbe3834c243b4b4c08e3916ea0e2fbd24bcff79 100644 (file)
@@ -17,3 +17,11 @@ norecursedirs = .git example-test
 # Default router type to use. Possible values are:
 # 'frr' and 'quagga'.
 #routertype = frr
+
+# Memory leak test reports path
+# Enables and add an output path to memory leak tests.
+# Example:
+# memleak_path = /tmp/memleak_
+# Output files will be named after the testname:
+# /tmp/memleak_test_ospf_topo1.txt
+#memleak_path =