lib: make packets and packet messages optional, disabled by default
[babeltrace.git] / tests / bindings / python / bt2 / test_stream_class.py
index 56dcf9203e1a120ecef6902b7fd321585ed44bdd..55cdb3109304a0158a1121e31f4aedae14d8bbbe 100644 (file)
@@ -40,6 +40,7 @@ class StreamClassTestCase(unittest.TestCase):
         self.assertIsNone(sc.default_clock_class)
         self.assertTrue(sc.assigns_automatic_event_class_id)
         self.assertTrue(sc.assigns_automatic_stream_id)
+        self.assertFalse(sc.supports_packets)
         self.assertFalse(sc.packets_have_beginning_default_clock_snapshot)
         self.assertFalse(sc.packets_have_end_default_clock_snapshot)
         self.assertFalse(sc.supports_discarded_events)
@@ -57,13 +58,20 @@ class StreamClassTestCase(unittest.TestCase):
 
     def test_create_packet_context_field_class(self):
         fc = self._tc.create_structure_field_class()
-        sc = self._tc.create_stream_class(packet_context_field_class=fc)
+        sc = self._tc.create_stream_class(packet_context_field_class=fc,
+                                          supports_packets=True)
         self.assertEqual(sc.packet_context_field_class, fc)
 
     def test_create_invalid_packet_context_field_class(self):
         with self.assertRaises(TypeError):
             self._tc.create_stream_class(packet_context_field_class=22)
 
+    def test_create_invalid_packet_context_field_class_no_packets(self):
+        fc = self._tc.create_structure_field_class()
+
+        with self.assertRaises(ValueError):
+            self._tc.create_stream_class(packet_context_field_class=fc)
+
     def test_create_event_common_context_field_class(self):
         fc = self._tc.create_structure_field_class()
         sc = self._tc.create_stream_class(event_common_context_field_class=fc)
@@ -137,21 +145,53 @@ class StreamClassTestCase(unittest.TestCase):
         with self.assertRaises(ValueError):
             sc.create_event_class()
 
-    def test_packets_have_beginning_default_clock_snapshot(self):
-        sc = self._tc.create_stream_class(default_clock_class=self._cc, packets_have_beginning_default_clock_snapshot=True)
+    def test_supports_packets_without_cs(self):
+        sc = self._tc.create_stream_class(default_clock_class=self._cc,
+                                          supports_packets=True)
+        self.assertTrue(sc.supports_packets)
+        self.assertFalse(sc.packets_have_beginning_default_clock_snapshot)
+        self.assertFalse(sc.packets_have_end_default_clock_snapshot)
+
+    def test_supports_packets_with_begin_cs(self):
+        sc = self._tc.create_stream_class(default_clock_class=self._cc,
+                                          supports_packets=True,
+                                          packets_have_beginning_default_clock_snapshot=True)
+        self.assertTrue(sc.supports_packets)
         self.assertTrue(sc.packets_have_beginning_default_clock_snapshot)
+        self.assertFalse(sc.packets_have_end_default_clock_snapshot)
 
-    def test_packets_have_beginning_default_clock_snapshot_raises(self):
+    def test_supports_packets_with_end_cs(self):
+        sc = self._tc.create_stream_class(default_clock_class=self._cc,
+                                          supports_packets=True,
+                                          packets_have_end_default_clock_snapshot=True)
+        self.assertTrue(sc.supports_packets)
+        self.assertFalse(sc.packets_have_beginning_default_clock_snapshot)
+        self.assertTrue(sc.packets_have_end_default_clock_snapshot)
+
+    def test_supports_packets_raises_type_error(self):
         with self.assertRaises(TypeError):
-            sc = self._tc.create_stream_class(packets_have_beginning_default_clock_snapshot="something")
+            sc = self._tc.create_stream_class(default_clock_class=self._cc,
+                                              supports_packets=23)
 
-    def test_packets_have_end_default_clock_snapshot(self):
-        sc = self._tc.create_stream_class(default_clock_class=self._cc, packets_have_end_default_clock_snapshot=True)
-        self.assertTrue(sc.packets_have_end_default_clock_snapshot)
+    def test_packets_have_begin_default_cs_raises_type_error(self):
+        with self.assertRaises(TypeError):
+            sc = self._tc.create_stream_class(default_clock_class=self._cc,
+                                              packets_have_beginning_default_clock_snapshot=23)
 
-    def test_packets_have_end_default_clock_snapshot_raises(self):
+    def test_packets_have_end_default_cs_raises_type_error(self):
         with self.assertRaises(TypeError):
-            sc = self._tc.create_stream_class(packets_have_end_default_clock_snapshot="something")
+            sc = self._tc.create_stream_class(default_clock_class=self._cc,
+                                              packets_have_end_default_clock_snapshot=23)
+
+    def test_does_not_support_packets_raises_with_begin_cs(self):
+        with self.assertRaises(ValueError):
+            sc = self._tc.create_stream_class(default_clock_class=self._cc,
+                                              packets_have_beginning_default_clock_snapshot=True)
+
+    def test_does_not_support_packets_raises_with_end_cs(self):
+        with self.assertRaises(ValueError):
+            sc = self._tc.create_stream_class(default_clock_class=self._cc,
+                                              packets_have_end_default_clock_snapshot=True)
 
     def test_supports_discarded_events_without_cs(self):
         sc = self._tc.create_stream_class(default_clock_class=self._cc,
@@ -183,31 +223,41 @@ class StreamClassTestCase(unittest.TestCase):
 
     def test_supports_discarded_packets_without_cs(self):
         sc = self._tc.create_stream_class(default_clock_class=self._cc,
-                                          supports_discarded_packets=True)
+                                          supports_discarded_packets=True,
+                                          supports_packets=True)
         self.assertTrue(sc.supports_discarded_packets)
         self.assertFalse(sc.discarded_packets_have_default_clock_snapshots)
 
     def test_supports_discarded_packets_with_cs(self):
         sc = self._tc.create_stream_class(default_clock_class=self._cc,
                                           supports_discarded_packets=True,
-                                          discarded_packets_have_default_clock_snapshots=True)
+                                          discarded_packets_have_default_clock_snapshots=True,
+                                          supports_packets=True)
         self.assertTrue(sc.supports_discarded_packets)
         self.assertTrue(sc.discarded_packets_have_default_clock_snapshots)
 
+    def test_supports_discarded_packets_raises_without_packet_support(self):
+        with self.assertRaises(ValueError):
+            sc = self._tc.create_stream_class(default_clock_class=self._cc,
+                                              supports_discarded_packets=True)
+
     def test_supports_discarded_packets_raises_type_error(self):
         with self.assertRaises(TypeError):
             sc = self._tc.create_stream_class(default_clock_class=self._cc,
-                                              supports_discarded_packets=23)
+                                              supports_discarded_packets=23,
+                                              supports_packets=True)
 
     def test_discarded_packets_have_default_cs_raises_type_error(self):
         with self.assertRaises(TypeError):
             sc = self._tc.create_stream_class(default_clock_class=self._cc,
-                                              discarded_packets_have_default_clock_snapshots=23)
+                                              discarded_packets_have_default_clock_snapshots=23,
+                                              supports_packets=True)
 
     def test_does_not_support_discarded_packets_raises_with_cs(self):
         with self.assertRaises(ValueError):
             sc = self._tc.create_stream_class(default_clock_class=self._cc,
-                                              discarded_packets_have_default_clock_snapshots=True)
+                                              discarded_packets_have_default_clock_snapshots=True,
+                                              supports_packets=True)
 
     def test_trace_class(self):
         sc = self._tc.create_stream_class()
This page took 0.025001 seconds and 4 git commands to generate.