1
0
mirror of https://github.com/samba-team/samba.git synced 2025-07-15 16:59:09 +03:00

talloc: Add python talloc module, move convenience functions to it.

Autobuild-User: Jelmer Vernooij <jelmer@samba.org>
Autobuild-Date: Fri Nov  5 02:48:21 UTC 2010 on sn-devel-104
This commit is contained in:
Jelmer Vernooij
2010-11-05 03:00:45 +01:00
parent 4edabb3256
commit cd172e7724
7 changed files with 102 additions and 63 deletions

View File

@ -17,15 +17,16 @@ sys.path.insert(0, "bin/python")
import samba
import samba.tests
from samba.dcerpc import drsuapi
import talloc
samba.talloc_enable_null_tracking()
talloc.enable_null_tracking()
class TallocTests(samba.tests.TestCase):
'''test talloc behaviour of pidl generated python code'''
def check_blocks(self, object, num_expected):
'''check that the number of allocated blocks is correct'''
nblocks = samba.talloc_total_blocks(object)
nblocks = talloc.total_blocks(object)
if object is None:
nblocks -= self.initial_blocks
self.assertEquals(nblocks, num_expected)
@ -61,7 +62,7 @@ class TallocTests(samba.tests.TestCase):
self.check_blocks(None, 6)
def test_run(self):
self.initial_blocks = samba.talloc_total_blocks(None)
self.initial_blocks = talloc.total_blocks(None)
self.check_blocks(None, 0)
self.pas_test()
self.check_blocks(None, 0)

View File

@ -10,15 +10,16 @@ sys.path.insert(0, "bin/python")
import samba
import samba.tests
from samba.dcerpc import drsuapi
import talloc
samba.talloc_enable_null_tracking()
talloc.enable_null_tracking()
class RpcTests(object):
'''test type behaviour of pidl generated python RPC code'''
def check_blocks(self, object, num_expected):
'''check that the number of allocated blocks is correct'''
nblocks = samba.talloc_total_blocks(object)
nblocks = talloc.total_blocks(object)
if object is None:
nblocks -= self.initial_blocks
leaked_blocks = (nblocks - num_expected)
@ -89,7 +90,7 @@ class RpcTests(object):
pass
elif isinstance(value, type):
try:
initial_blocks = samba.talloc_total_blocks(None)
initial_blocks = talloc.total_blocks(None)
self.check_type(interface, n, value)
self.check_blocks(None, initial_blocks)
except Exception, e:
@ -110,12 +111,12 @@ class RpcTests(object):
continue
print "Checking interface %s" % iname
iface = getattr(samba.dcerpc, iname)
initial_blocks = samba.talloc_total_blocks(None)
initial_blocks = talloc.total_blocks(None)
self.check_interface(iface, iname)
self.check_blocks(None, initial_blocks)
def run(self):
self.initial_blocks = samba.talloc_total_blocks(None)
self.initial_blocks = talloc.total_blocks(None)
self.errcount = 0
self.check_all_interfaces()
return self.errcount