def check_interface(self, interface, iname): errcount = self.errcount for n in dir(interface): if n[0] == '_' or n == iname: # skip the special ones continue value = getattr(interface, n) if isinstance(value, str): #print "%s=\"%s\"" % (n, value) pass elif isinstance(value, int) or isinstance(value, long): #print "%s=%d" % (n, value) pass elif isinstance(value, type): try: initial_blocks = talloc.total_blocks(None) self.check_type(interface, n, value) self.check_blocks(None, initial_blocks) except Exception as e: print "ERROR: Failed to check_type %s.%s: %r: %s" % ( iname, n, e.__class__, e) self.errcount += 1 elif callable(value): pass # Method else: print "UNKNOWN: %s=%s" % (n, value) if self.errcount - errcount != 0: print "Found %d errors in %s" % (self.errcount - errcount, iname)
def check_interface(self, interface, iname): errcount = self.errcount for n in dir(interface): if n[0] == '_' or n == iname: # skip the special ones continue value = getattr(interface, n) if isinstance(value, str): #print "%s=\"%s\"" % (n, value) pass elif isinstance(value, int) or isinstance(value, int): #print "%s=%d" % (n, value) pass elif isinstance(value, type): try: initial_blocks = talloc.total_blocks(None) self.check_type(interface, n, value) self.check_blocks(None, initial_blocks) except Exception as e: print("ERROR: Failed to check_type %s.%s: %r: %s" % (iname, n, e.__class__, e)) self.errcount += 1 elif callable(value): pass # Method else: print("UNKNOWN: %s=%s" % (n, value)) if self.errcount - errcount != 0: print("Found %d errors in %s" % (self.errcount - errcount, iname))
def check_blocks(self, object, num_expected): '''check that the number of allocated blocks is correct''' nblocks = talloc.total_blocks(object) if object is None: nblocks -= self.initial_blocks leaked_blocks = (nblocks - num_expected) if leaked_blocks != 0: print "Leaked %d blocks" % leaked_blocks
def check_all_interfaces(self): for iname in dir(samba.dcerpc): if iname[0] == '_': continue if iname == 'ClientConnection' or iname == 'base': continue print "Checking interface %s" % iname iface = getattr(samba.dcerpc, iname) initial_blocks = talloc.total_blocks(None) self.check_interface(iface, iname) self.check_blocks(None, initial_blocks)
def check_interface(self, interface, iname): errcount = self.errcount for n in dir(interface): if n[0] == '_' or n == iname: # skip the special ones continue value = getattr(interface, n) if isinstance(value, str): #print "%s=\"%s\"" % (n, value) pass elif isinstance(value, int) or isinstance(value, long): #print "%s=%d" % (n, value) pass elif isinstance(value, type): try: initial_blocks = talloc.total_blocks(None) self.check_type(interface, n, value) self.check_blocks(None, initial_blocks) except Exception, e: print "ERROR: Failed to check_type {0!s}.{1!s}: {2!r}: {3!s}".format(iname, n, e.__class__, e) self.errcount += 1 elif callable(value): pass # Method
def run(self): self.initial_blocks = talloc.total_blocks(None) self.errcount = 0 self.check_all_interfaces() return self.errcount
def test_totalblocks(self): obj = _test_pytalloc.new() # Two blocks: the string, and the name self.assertEqual(talloc.total_blocks(obj), 2)
def test_run(self): self.initial_blocks = talloc.total_blocks(None) self.check_blocks(None, 0) self.pas_test() self.check_blocks(None, 0)
def tearDown(self): super(ArrayTests, self).tearDown() self.assertEqual(talloc.total_blocks(), self.startup_blocks) talloc.report_full()
def tearDown(self): super(StringTests, self).tearDown() gc.collect() if talloc.total_blocks() != self.startup_blocks: talloc.report_full() self.fail("it appears we are leaking memory")
def setUp(self): super(StringTests, self).setUp() talloc.enable_null_tracking() self.startup_blocks = talloc.total_blocks()
def setUp(self): super(ArrayTests, self).setUp() talloc.enable_null_tracking() self.startup_blocks = talloc.total_blocks()
def tearDown(self): super(ArrayTests, self).tearDown() gc.collect() if talloc.total_blocks() != self.startup_blocks: talloc.report_full() self.fail("it appears we are leaking memory")
def check_blocks(self, object, num_expected): '''check that the number of allocated blocks is correct''' nblocks = talloc.total_blocks(object) if object is None: nblocks -= self.initial_blocks self.assertEquals(nblocks, num_expected)
def check_blocks(self, object, num_expected): '''check that the number of allocated blocks is correct''' nblocks = talloc.total_blocks(object) if object is None: nblocks -= self.initial_blocks self.assertEqual(nblocks, num_expected)