diff mbox series

[2/2] trace-cruncher: Add more histogram tests

Message ID 20211216132921.239628-2-y.karadz@gmail.com (mailing list archive)
State Accepted
Headers show
Series [1/2] trace-cruncher: Fix segfault in PyTraceHist_read() | expand

Commit Message

Yordan Karadzhov Dec. 16, 2021, 1:29 p.m. UTC
Testing the handling of couple of error cases.

Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
---
 .../tests/1_unit/test_01_ftracepy_unit.py      | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
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 7b344e2..7e5b20e 100644
--- a/tracecruncher/tests/1_unit/test_01_ftracepy_unit.py
+++ b/tracecruncher/tests/1_unit/test_01_ftracepy_unit.py
@@ -582,5 +582,23 @@  class HistTestCase(unittest.TestCase):
         self.assertTrue('Available triggers:' in h_buff)
         f.close()
 
+    def test_hist_err(self):
+        inst = ft.create_instance(instance_name)
+        hist = ft.hist(system='kmem', event='kmalloc',
+                       axes={'call_site': 'sym',
+                             'bytes_alloc': 'n'})
+        err = 'Failed read data from histogram'
+        with self.assertRaises(Exception) as context:
+            hist.read(inst)
+        self.assertTrue(err in str(context.exception))
+
+        hist.start(inst)
+        err = 'Failed to start filling the histogram'
+        with self.assertRaises(Exception) as context:
+            hist.start(inst)
+        self.assertTrue(err in str(context.exception))
+        hist.close(inst)
+
+
 if __name__ == '__main__':
     unittest.main()