diff mbox series

[4/4] trace-cruncher: Add tests for sorted events/systems

Message ID 20210831125357.56862-4-y.karadz@gmail.com (mailing list archive)
State Accepted
Headers show
Series [1/4] trace-cruncher: Add optional sort to tfs_list2py_list() | expand

Commit Message

Yordan Karadzhov Aug. 31, 2021, 12:53 p.m. UTC
An optional parameter 'sort' was added to available_event_systems()
and available_system_events(). Here we add the corresponding test
cases.

Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
---
 .../tests/1_unit/test_01_ftracepy_unit.py          | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/tracecruncher/tests/1_unit/test_01_ftracepy_unit.py b/tracecruncher/tests/1_unit/test_01_ftracepy_unit.py
index 971fd5f..710d3e1 100644
--- a/tracecruncher/tests/1_unit/test_01_ftracepy_unit.py
+++ b/tracecruncher/tests/1_unit/test_01_ftracepy_unit.py
@@ -111,19 +111,23 @@  class TracersTestCase(unittest.TestCase):
 
 class EventsTestCase(unittest.TestCase):
     def test_available_systems(self):
-        systems = ft.available_event_systems()
-        self.assertTrue(len(systems) > 1)
+        systems = ft.available_event_systems(sort=True)
+        self.assertTrue(len(systems) > 2)
         self.assertTrue('sched' in systems)
+        for i in range(len(systems) - 2):
+            self.assertTrue(systems[i] < systems[i + 1])
 
         inst = ft.create_instance(instance_name)
         systems = ft.available_event_systems(inst)
-        self.assertTrue(len(systems) > 1)
+        self.assertTrue(len(systems) > 2)
         self.assertTrue('sched' in systems)
 
     def test_available_system_events(self):
-        events = ft.available_system_events(system='sched')
-        self.assertTrue(len(events) > 1)
+        events = ft.available_system_events(system='sched', sort=True)
+        self.assertTrue(len(events) > 2)
         self.assertTrue('sched_switch' in events)
+        for i in range(len(events) - 2):
+            self.assertTrue(events[i] < events[i + 1])
 
         inst = ft.create_instance(instance_name)
         events = ft.available_system_events(instance=inst,