blob: 611746ff203239673f7dc63c39ff9f56f6f2461e [file] [log] [blame]
adrianvilline59761f2023-11-07 10:18:24 +01001from asfframework import VppAsfTestCase, VppTestRunner
adrianvillin5cc67aa2023-11-10 09:59:59 +01002from vpp_qemu_utils import can_create_namespaces
3from config import config
adrianvilline59761f2023-11-07 10:18:24 +01004import unittest
5
6
adrianvillin5cc67aa2023-11-10 09:59:59 +01007@unittest.skipIf(
8 not can_create_namespaces("perfmon_chk"), "Test is not running with root privileges"
9)
10@unittest.skipIf("perfmon" in config.excluded_plugins, "Exclude Perfmon plugin tests")
adrianvilline59761f2023-11-07 10:18:24 +010011class TestPerfmon(VppAsfTestCase):
12 """Simple perfmon test"""
13
14 @classmethod
15 def setUpClass(cls):
16 super(TestPerfmon, cls).setUpClass()
17
18 @classmethod
19 def tearDownClass(cls):
20 super(TestPerfmon, cls).tearDownClass()
21
22 def test_perfmon(self):
23 reply = self.vapi.cli("show perfmon active-bundle")
24 self.assertNotIn("context-switches", reply)
25
26 reply = self.vapi.cli("show perfmon bundle")
27 self.assertIn("context-switches", reply)
28
29 self.vapi.cli("perfmon start bundle context-switches type thread")
30 reply = self.vapi.cli("show perfmon active-bundle")
31 self.assertIn("name: context-switches", reply)
32
33 reply = self.vapi.cli("show perfmon statistics")
34 self.assertIn("per-thread context switches", reply)
35
36 reply = self.vapi.cli("show perfmon source linux verbose")
37 self.assertIn("description: Linux kernel performance counters", reply)
38 self.vapi.cli("perfmon reset")
39
40 reply = self.vapi.cli("show perfmon active-bundle")
41 self.assertNotIn("context-switches", reply)
42
43 self.vapi.cli("perfmon start bundle context-switches type thread")
44 self.vapi.cli("perfmon stop")
45
46
47if __name__ == "__main__":
48 unittest.main(testRunner=VppTestRunner)