448a6012c20fb2a5a8e7ab51948c11a50ddd9423
[vpp.git] / test / asf / test_perfmon.py
1 from asfframework import VppAsfTestCase, VppTestRunner
2 import unittest
3
4
5 class TestPerfmon(VppAsfTestCase):
6     """Simple perfmon test"""
7
8     @classmethod
9     def setUpClass(cls):
10         super(TestPerfmon, cls).setUpClass()
11
12     @classmethod
13     def tearDownClass(cls):
14         super(TestPerfmon, cls).tearDownClass()
15
16     def test_perfmon(self):
17         reply = self.vapi.cli("show perfmon active-bundle")
18         self.assertNotIn("context-switches", reply)
19
20         reply = self.vapi.cli("show perfmon bundle")
21         self.assertIn("context-switches", reply)
22
23         self.vapi.cli("perfmon start bundle context-switches type thread")
24         reply = self.vapi.cli("show perfmon active-bundle")
25         self.assertIn("name: context-switches", reply)
26
27         reply = self.vapi.cli("show perfmon statistics")
28         self.assertIn("per-thread context switches", reply)
29
30         reply = self.vapi.cli("show perfmon source linux verbose")
31         self.assertIn("description: Linux kernel performance counters", reply)
32         self.vapi.cli("perfmon reset")
33
34         reply = self.vapi.cli("show perfmon active-bundle")
35         self.assertNotIn("context-switches", reply)
36
37         self.vapi.cli("perfmon start bundle context-switches type thread")
38         self.vapi.cli("perfmon stop")
39
40
41 if __name__ == "__main__":
42     unittest.main(testRunner=VppTestRunner)