summaryrefslogtreecommitdiffstats
path: root/test/debug_internal.py
blob: 2cbee27ec819d86bacce8e88483fef8f00c21dc9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import gc
import pprint
import vpp_papi
from vpp_papi_provider import VppPapiProvider
import objgraph
from pympler import tracker
tr = tracker.SummaryTracker()

"""
  Internal debug module

  The module provides functions for debugging test framework
"""


def on_tear_down_class(cls):
    gc.collect()
    tr.print_diff()
    objects = gc.get_objects()
    counter = 0
    with open(cls.tempdir + '/python_objects.txt', 'w') as f:
        interesting = [
            o for o in objects
            if isinstance(o, (VppPapiProvider, vpp_papi.VPP))]
        del objects
        gc.collect()
        for o in interesting:
            objgraph.show_backrefs([o], max_depth=5,
                                   filename="%s/%s.png" %
                                   (cls.tempdir, counter))
            counter += 1
            refs = gc.get_referrers(o)
            pp = pprint.PrettyPrinter(indent=2)
            f.write("%s\n" % pp.pformat(o))
            for r in refs:
                try:
                    f.write("%s\n" % pp.pformat(r))
                except:
                    f.write("%s\n" % type(r))
ss="n">ctx: rv = self.vapi.papi.cli_inband(cmd='wait 10') def test_long_cli_delay_override(self): """ Test per-command _timeout option.""" # noqa rv = self.vapi.papi.cli_inband(cmd='wait 10', _timeout=15) self.assertEqual(rv.retval, 0) class TestCLIExtendedVapiTimeout(VppTestCase): maxDiff = None @classmethod def setUpClass(cls): cls.vapi_response_timeout = 15 cls.__doc__ = " CLI Test Case w/ Extended (%ssec) Vapi Timeout " \ % cls.vapi_response_timeout super(TestCLIExtendedVapiTimeout, cls).setUpClass() @classmethod def tearDownClass(cls): super(TestCLIExtendedVapiTimeout, cls).tearDownClass() def setUp(self): super(TestCLIExtendedVapiTimeout, self).setUp() def tearDown(self): super(TestCLIExtendedVapiTimeout, self).tearDown() def test_long_cli_delay(self): """ Test that delayed result returns with extended timeout.""" wait_secs = self.vapi_response_timeout - 1 # get vpp time as float start = self.vapi.papi.show_vpe_system_time( _no_type_conversion=True).vpe_system_time rv = self.vapi.papi.cli_inband(cmd='wait %s' % wait_secs) now = self.vapi.papi.show_vpe_system_time( _no_type_conversion=True).vpe_system_time # assume that the overhead of the measurement is not more that .5 sec. self.assertEqual(round(now - start), wait_secs) if __name__ == '__main__': unittest.main(testRunner=VppTestRunner)