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
```
'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')
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')
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):
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
# 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 =