Esempio 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)
Esempio 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))
Esempio 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
Esempio 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)
Esempio 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
Esempio n. 6
0
 def run(self):
     self.initial_blocks = talloc.total_blocks(None)
     self.errcount = 0
     self.check_all_interfaces()
     return self.errcount
Esempio 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)
Esempio 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)
Esempio n. 9
0
 def tearDown(self):
     super(ArrayTests, self).tearDown()
     self.assertEqual(talloc.total_blocks(), self.startup_blocks)
     talloc.report_full()
Esempio 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)
Esempio 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")
Esempio n. 12
0
 def setUp(self):
     super(StringTests, self).setUp()
     talloc.enable_null_tracking()
     self.startup_blocks = talloc.total_blocks()
Esempio n. 13
0
 def tearDown(self):
     super(ArrayTests, self).tearDown()
     self.assertEqual(talloc.total_blocks(), self.startup_blocks)
     talloc.report_full()
Esempio n. 14
0
 def setUp(self):
     super(ArrayTests, self).setUp()
     talloc.enable_null_tracking()
     self.startup_blocks = talloc.total_blocks()
Esempio 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")
Esempio 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)
Esempio 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)
Esempio 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)