summaryrefslogtreecommitdiffstats
path: root/test/asf/test_perfmon.py
blob: 448a6012c20fb2a5a8e7ab51948c11a50ddd9423 (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
40
41
42
from asfframework import VppAsfTestCase, VppTestRunner
import unittest


class TestPerfmon(VppAsfTestCase):
    """Simple perfmon test"""

    @classmethod
    def setUpClass(cls):
        super(TestPerfmon, cls).setUpClass()

    @classmethod
    def tearDownClass(cls):
        super(TestPerfmon, cls).tearDownClass()

    def test_perfmon(self):
        reply = self.vapi.cli("show perfmon active-bundle")
        self.assertNotIn("context-switches", reply)

        reply = self.vapi.cli("show perfmon bundle")
        self.assertIn("context-switches", reply)

        self.vapi.cli("perfmon start bundle context-switches type thread")
        reply = self.vapi.cli("show perfmon active-bundle")
        self.assertIn("name: context-switches", reply)

        reply = self.vapi.cli("show perfmon statistics")
        self.assertIn("per-thread context switches", reply)

        reply = self.vapi.cli("show perfmon source linux verbose")
        self.assertIn("description: Linux kernel performance counters", reply)
        self.vapi.cli("perfmon reset")

        reply = self.vapi.cli("show perfmon active-bundle")
        self.assertNotIn("context-switches", reply)

        self.vapi.cli("perfmon start bundle context-switches type thread")
        self.vapi.cli("perfmon stop")


if __name__ == "__main__":
    unittest.main(testRunner=VppTestRunner)