Ejemplo n.º 1
0
 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)
Ejemplo n.º 2
0
 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))
Ejemplo n.º 3
0
 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
Ejemplo n.º 4
0
 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)
Ejemplo n.º 5
0
 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
Ejemplo n.º 6
0
 def run(self):
     self.initial_blocks = talloc.total_blocks(None)
     self.errcount = 0
     self.check_all_interfaces()
     return self.errcount
Ejemplo n.º 7
0
 def test_totalblocks(self):
     obj = _test_pytalloc.new()
     # Two blocks: the string, and the name
     self.assertEqual(talloc.total_blocks(obj), 2)
Ejemplo n.º 8
0
 def test_run(self):
     self.initial_blocks = talloc.total_blocks(None)
     self.check_blocks(None, 0)
     self.pas_test()
     self.check_blocks(None, 0)
Ejemplo n.º 9
0
 def tearDown(self):
     super(ArrayTests, self).tearDown()
     self.assertEqual(talloc.total_blocks(), self.startup_blocks)
     talloc.report_full()
Ejemplo n.º 10
0
 def test_totalblocks(self):
     obj = _test_pytalloc.new()
     # Two blocks: the string, and the name
     self.assertEqual(talloc.total_blocks(obj), 2)
Ejemplo n.º 11
0
 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")
Ejemplo n.º 12
0
 def setUp(self):
     super(StringTests, self).setUp()
     talloc.enable_null_tracking()
     self.startup_blocks = talloc.total_blocks()
Ejemplo n.º 13
0
 def tearDown(self):
     super(ArrayTests, self).tearDown()
     self.assertEqual(talloc.total_blocks(), self.startup_blocks)
     talloc.report_full()
Ejemplo n.º 14
0
 def setUp(self):
     super(ArrayTests, self).setUp()
     talloc.enable_null_tracking()
     self.startup_blocks = talloc.total_blocks()
Ejemplo n.º 15
0
 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")
Ejemplo n.º 16
0
 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)
Ejemplo n.º 17
0
 def test_run(self):
     self.initial_blocks = talloc.total_blocks(None)
     self.check_blocks(None, 0)
     self.pas_test()
     self.check_blocks(None, 0)
Ejemplo n.º 18
0
 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)