diff options
author | Heikki Toivonen <heikki@heikkitoivonen.net> | 2006-04-05 07:24:19 +0000 |
---|---|---|
committer | Heikki Toivonen <heikki@heikkitoivonen.net> | 2006-04-05 07:24:19 +0000 |
commit | a564adb0005dfc459c7475a5df389580538ba996 (patch) | |
tree | 097b72ee4f86485e7e29aed7474d1f4437f55c2c /tests/alltests.py | |
parent | b5b21ba69470f01d7c7ca0182c9ea6924c0376b7 (diff) | |
download | m2crypto-a564adb0005dfc459c7475a5df389580538ba996.tar.gz |
Add memory leak reporting, off by default (if test_ssl
is included we leak 141 objects). Should be turned on
by default once there are no leaks reported.
git-svn-id: http://svn.osafoundation.org/m2crypto/trunk@403 2715db39-9adf-0310-9c64-84f055769b4b
Diffstat (limited to 'tests/alltests.py')
-rw-r--r-- | tests/alltests.py | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/tests/alltests.py b/tests/alltests.py index 8d92a48..cea3141 100644 --- a/tests/alltests.py +++ b/tests/alltests.py @@ -1,9 +1,8 @@ #!/usr/bin/env python -import os, unittest -from M2Crypto import Rand, m2 - def suite(): + from M2Crypto import m2 + modules_to_test = [ 'test_asn1', 'test_bio', @@ -31,7 +30,35 @@ def suite(): alltests.addTest(module.suite()) return alltests + +def dump_garbage(): + print '\nGarbage:' + leaks = gc.collect() + if leaks: + + print '\nLeaked objects:' + for x in gc.garbage: + s = str(x) + if len(s) > 77: s = s[:73]+'...' + print type(x), '\n ', s + + print 'There were %d leaks.' % leaks + else: + print 'Python garabge collector did not detect any leaks.' + print 'However, it is still possible there are leaks in the C code.' + + if __name__ == '__main__': + report_leaks = 0 + + if report_leaks: + import gc + gc.enable() + gc.set_debug(gc.DEBUG_LEAK) + + import os, unittest + from M2Crypto import Rand + try: Rand.load_file('randpool.dat', -1) unittest.TextTestRunner().run(suite()) @@ -41,4 +68,5 @@ if __name__ == '__main__': from test_ssl import zap_servers zap_servers() - + if report_leaks: + dump_garbage() |