From 5602ef8155de326402dcb33f40ee4c7d5d693ca5 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Tue, 2 Apr 2019 14:03:30 -0400 Subject: [PATCH] bt2: Mass notification -> message rename As the "notification" concept has been renamed to "message", I decided to do a mass rename (including renaming files). It's quite straightforward and will reduce a little bit the noise in further patches. The changes were done mostly mechanically, but I verified them to make sure it didn't go too wild (like changing "notifier" to "msgier", which we wouldn't want). Signed-off-by: Simon Marchi Change-Id: I6e6dec1234864400a2570a4726c32a1398cf42c0 Reviewed-on: https://review.gerrithub.io/c/eepp/babeltrace/+/452232 Reviewed-by: Philippe Proulx Tested-by: Philippe Proulx --- .../babeltrace/reader_trace_collection.py | 4 +- bindings/python/bt2/Makefile.am | 6 +- bindings/python/bt2/bt2/__init__.py.in | 14 +- bindings/python/bt2/bt2/component.py | 30 +- bindings/python/bt2/bt2/connection.py | 16 +- .../bt2/bt2/{notification.py => message.py} | 180 ++++---- ...cation_iterator.py => message_iterator.py} | 48 +-- .../bt2/bt2/native_bt_component_class.i | 26 +- bindings/python/bt2/bt2/port.py | 18 +- ...y => trace_collection_message_iterator.py} | 22 +- tests/bindings/python/bt2/Makefile.am | 6 +- .../python/bt2/test_component_class.py | 32 +- tests/bindings/python/bt2/test_connection.py | 56 +-- tests/bindings/python/bt2/test_graph.py | 98 ++--- .../{test_notification.py => test_message.py} | 408 +++++++++--------- ...n_iterator.py => test_message_iterator.py} | 56 +-- tests/bindings/python/bt2/test_port.py | 108 ++--- ...test_trace_collection_message_iterator.py} | 70 +-- 18 files changed, 599 insertions(+), 599 deletions(-) rename bindings/python/bt2/bt2/{notification.py => message.py} (64%) rename bindings/python/bt2/bt2/{notification_iterator.py => message_iterator.py} (67%) rename bindings/python/bt2/bt2/{trace_collection_notification_iterator.py => trace_collection_message_iterator.py} (94%) rename tests/bindings/python/bt2/{test_notification.py => test_message.py} (51%) rename tests/bindings/python/bt2/{test_notification_iterator.py => test_message_iterator.py} (73%) rename tests/bindings/python/bt2/{test_trace_collection_notification_iterator.py => test_trace_collection_message_iterator.py} (60%) diff --git a/bindings/python/babeltrace/babeltrace/reader_trace_collection.py b/bindings/python/babeltrace/babeltrace/reader_trace_collection.py index 0ca484d7..e6544a82 100644 --- a/bindings/python/babeltrace/babeltrace/reader_trace_collection.py +++ b/bindings/python/babeltrace/babeltrace/reader_trace_collection.py @@ -169,11 +169,11 @@ class TraceCollection: specs = [bt2.ComponentSpec('ctf', 'fs', th.path) for th in self._trace_handles] try: - iter_cls = bt2.TraceCollectionNotificationIterator + iter_cls = bt2.TraceCollectionMessageIterator tc_iter = iter_cls(specs, stream_intersection_mode=self._intersect_mode, begin=begin_s, end=end_s, - notification_types=[bt2.EventNotification]) + message_types=[bt2.EventMessage]) return map(reader_event._create_event, tc_iter) except: raise ValueError diff --git a/bindings/python/bt2/Makefile.am b/bindings/python/bt2/Makefile.am index 5b1a9bbf..6003f238 100644 --- a/bindings/python/bt2/Makefile.am +++ b/bindings/python/bt2/Makefile.am @@ -45,8 +45,8 @@ STATIC_BINDINGS_DEPS = \ bt2/field_types.py \ bt2/graph.py \ bt2/logging.py \ - bt2/notification_iterator.py \ - bt2/notification.py \ + bt2/message_iterator.py \ + bt2/message.py \ bt2/object.py \ bt2/packet.py \ bt2/plugin.py \ @@ -56,7 +56,7 @@ STATIC_BINDINGS_DEPS = \ bt2/stream_class.py \ bt2/stream.py \ bt2/trace.py \ - bt2/trace_collection_notification_iterator.py \ + bt2/trace_collection_message_iterator.py \ bt2/utils.py \ bt2/values.py diff --git a/bindings/python/bt2/bt2/__init__.py.in b/bindings/python/bt2/bt2/__init__.py.in index dffc7f21..da102f19 100644 --- a/bindings/python/bt2/bt2/__init__.py.in +++ b/bindings/python/bt2/bt2/__init__.py.in @@ -57,11 +57,11 @@ from bt2.fields import _StructureField from bt2.fields import _VariantField from bt2.graph import * from bt2.logging import * -from bt2.notification import * -from bt2.notification import _DiscardedEventsNotification -from bt2.notification import _DiscardedPacketsNotification -from bt2.notification_iterator import * -from bt2.notification_iterator import _UserNotificationIterator +from bt2.message import * +from bt2.message import _DiscardedEventsMessage +from bt2.message import _DiscardedPacketsMessage +from bt2.message_iterator import * +from bt2.message_iterator import _UserMessageIterator from bt2.packet import _Packet from bt2.plugin import * from bt2.port import * @@ -76,7 +76,7 @@ from bt2.query_executor import * from bt2.stream import _Stream from bt2.stream_class import * from bt2.trace import * -from bt2.trace_collection_notification_iterator import * +from bt2.trace_collection_message_iterator import * from bt2.values import * from bt2.values import _Value @@ -137,7 +137,7 @@ class QueryExecutorCanceled(Exception): pass -class NotificationIteratorCanceled(Exception): +class MessageIteratorCanceled(Exception): pass diff --git a/bindings/python/bt2/bt2/component.py b/bindings/python/bt2/bt2/component.py index fc473984..34de5132 100644 --- a/bindings/python/bt2/bt2/component.py +++ b/bindings/python/bt2/bt2/component.py @@ -21,7 +21,7 @@ # THE SOFTWARE. from bt2 import native_bt, object, utils -import bt2.notification_iterator +import bt2.message_iterator import collections.abc import bt2.values import traceback @@ -329,24 +329,24 @@ def _trim_docstring(docstring): # finalized. # # User-defined source and filter component classes must use the -# `notification_iterator_class` class parameter to specify the -# notification iterator class to use for this component class: +# `message_iterator_class` class parameter to specify the +# message iterator class to use for this component class: # -# class MyNotificationIterator(bt2._UserNotificationIterator): +# class MyMessageIterator(bt2._UserMessageIterator): # ... # # class MySource(bt2._UserSourceComponent, -# notification_iterator_class=MyNotificationIterator): +# message_iterator_class=MyMessageIterator): # ... # -# This notification iterator class must inherit -# bt2._UserNotificationIterator, and it must define the _get() and -# _next() methods. The notification iterator class can also define an +# This message iterator class must inherit +# bt2._UserMessageIterator, and it must define the _get() and +# _next() methods. The message iterator class can also define an # __init__() method: this method has access to the original Python # component object which was used to create it as the `component` -# property. The notification iterator class can also define a +# property. The message iterator class can also define a # _finalize() method (again, do NOT use __del__()): this is called when -# the notification iterator is (really) destroyed. +# the message iterator is (really) destroyed. # # When the user-defined class is destroyed, this metaclass's __del__() # method is called: the native BT component class pointer is put (not @@ -388,7 +388,7 @@ class _UserComponentType(type): if len(lines) >= 3: comp_cls_help = '\n'.join(lines[2:]) - iter_cls = kwargs.get('notification_iterator_class') + iter_cls = kwargs.get('message_iterator_class') if _UserSourceComponent in bases: _UserComponentType._set_iterator_class(cls, iter_cls) @@ -441,13 +441,13 @@ class _UserComponentType(type): @staticmethod def _set_iterator_class(cls, iter_cls): if iter_cls is None: - raise bt2.IncompleteUserClass("cannot create component class '{}': missing notification iterator class".format(cls.__name__)) + raise bt2.IncompleteUserClass("cannot create component class '{}': missing message iterator class".format(cls.__name__)) - if not issubclass(iter_cls, bt2.notification_iterator._UserNotificationIterator): - raise bt2.IncompleteUserClass("cannot create component class '{}': notification iterator class does not inherit bt2._UserNotificationIterator".format(cls.__name__)) + if not issubclass(iter_cls, bt2.message_iterator._UserMessageIterator): + raise bt2.IncompleteUserClass("cannot create component class '{}': message iterator class does not inherit bt2._UserMessageIterator".format(cls.__name__)) if not hasattr(iter_cls, '__next__'): - raise bt2.IncompleteUserClass("cannot create component class '{}': notification iterator class is missing a __next__() method".format(cls.__name__)) + raise bt2.IncompleteUserClass("cannot create component class '{}': message iterator class is missing a __next__() method".format(cls.__name__)) cls._iter_cls = iter_cls diff --git a/bindings/python/bt2/bt2/connection.py b/bindings/python/bt2/bt2/connection.py index d430bc5b..90c63994 100644 --- a/bindings/python/bt2/bt2/connection.py +++ b/bindings/python/bt2/bt2/connection.py @@ -21,7 +21,7 @@ # THE SOFTWARE. from bt2 import native_bt, object, utils -import bt2.notification_iterator +import bt2.message_iterator import collections.abc import bt2.port import copy @@ -81,13 +81,13 @@ class _Connection(object._Object): class _PrivateConnection(object._PrivateObject, _Connection): - def create_notification_iterator(self, notification_types=None): - notif_types = bt2.notification._notif_types_from_notif_classes(notification_types) - status, notif_iter_ptr = native_bt.py3_create_priv_conn_notif_iter(int(self._ptr), - notif_types) - _handle_status(status, 'cannot create notification iterator object') - assert(notif_iter_ptr) - return bt2.notification_iterator._PrivateConnectionNotificationIterator._create_from_ptr(notif_iter_ptr) + def create_message_iterator(self, message_types=None): + msg_types = bt2.message._msg_types_from_msg_classes(message_types) + status, msg_iter_ptr = native_bt.py3_create_priv_conn_msg_iter(int(self._ptr), + msg_types) + _handle_status(status, 'cannot create message iterator object') + assert(msg_iter_ptr) + return bt2.message_iterator._PrivateConnectionMessageIterator._create_from_ptr(msg_iter_ptr) @property def is_ended(self): diff --git a/bindings/python/bt2/bt2/notification.py b/bindings/python/bt2/bt2/message.py similarity index 64% rename from bindings/python/bt2/bt2/notification.py rename to bindings/python/bt2/bt2/message.py index 6ec9f16a..272443c1 100644 --- a/bindings/python/bt2/bt2/notification.py +++ b/bindings/python/bt2/bt2/message.py @@ -32,33 +32,33 @@ import bt2 def _create_from_ptr(ptr): - notif_type = native_bt.notification_get_type(ptr) + msg_type = native_bt.message_get_type(ptr) cls = None - if notif_type not in _NOTIF_TYPE_TO_CLS: - raise bt2.Error('unknown notification type: {}'.format(notif_type)) + if msg_type not in _MESSAGE_TYPE_TO_CLS: + raise bt2.Error('unknown message type: {}'.format(msg_type)) - return _NOTIF_TYPE_TO_CLS[notif_type]._create_from_ptr(ptr) + return _MESSAGE_TYPE_TO_CLS[msg_type]._create_from_ptr(ptr) -def _notif_types_from_notif_classes(notification_types): - if notification_types is None: - notif_types = None +def _msg_types_from_msg_classes(message_types): + if message_types is None: + msg_types = None else: - for notif_cls in notification_types: - if notif_cls not in _NOTIF_TYPE_TO_CLS.values(): - raise ValueError("'{}' is not a notification class".format(notif_cls)) + for msg_cls in message_types: + if msg_cls not in _MESSAGE_TYPE_TO_CLS.values(): + raise ValueError("'{}' is not a message class".format(msg_cls)) - notif_types = [notif_cls._TYPE for notif_cls in notification_types] + msg_types = [msg_cls._TYPE for msg_cls in message_types] - return notif_types + return msg_types -class _Notification(object._Object): +class _Message(object._Object): pass -class _CopyableNotification(_Notification): +class _CopyableMessage(_Message): def __copy__(self): return self._copy(lambda obj: obj) @@ -68,7 +68,7 @@ class _CopyableNotification(_Notification): return cpy -class EventNotification(_CopyableNotification): +class EventMessage(_CopyableMessage): _TYPE = native_bt.MESSAGE_TYPE_EVENT def __init__(self, event, cc_prio_map=None): @@ -80,22 +80,22 @@ class EventNotification(_CopyableNotification): else: cc_prio_map_ptr = None - ptr = native_bt.notification_event_create(event._ptr, cc_prio_map_ptr) + ptr = native_bt.message_event_create(event._ptr, cc_prio_map_ptr) if ptr is None: - raise bt2.CreationError('cannot create event notification object') + raise bt2.CreationError('cannot create event message object') super().__init__(ptr) @property def event(self): - event_ptr = native_bt.notification_event_get_event(self._ptr) + event_ptr = native_bt.message_event_get_event(self._ptr) assert(event_ptr) return bt2.event._create_from_ptr(event_ptr) @property def clock_class_priority_map(self): - cc_prio_map_ptr = native_bt.notification_event_get_clock_class_priority_map(self._ptr) + cc_prio_map_ptr = native_bt.message_event_get_clock_class_priority_map(self._ptr) assert(cc_prio_map_ptr) return bt2.clock_class_priority_map.ClockClassPriorityMap._create_from_ptr(cc_prio_map_ptr) @@ -118,27 +118,27 @@ class EventNotification(_CopyableNotification): def _copy(self, copy_func): # We can always use references here because those properties are - # frozen anyway if they are part of a notification. Since the - # user cannot modify them after copying the notification, it's + # frozen anyway if they are part of a message. Since the + # user cannot modify them after copying the message, it's # useless to copy/deep-copy them. - return EventNotification(self.event, self.clock_class_priority_map) + return EventMessage(self.event, self.clock_class_priority_map) -class PacketBeginningNotification(_CopyableNotification): +class PacketBeginningMessage(_CopyableMessage): _TYPE = native_bt.MESSAGE_TYPE_PACKET_BEGINNING def __init__(self, packet): utils._check_type(packet, bt2.packet._Packet) - ptr = native_bt.notification_packet_begin_create(packet._ptr) + ptr = native_bt.message_packet_begin_create(packet._ptr) if ptr is None: - raise bt2.CreationError('cannot create packet beginning notification object') + raise bt2.CreationError('cannot create packet beginning message object') super().__init__(ptr) @property def packet(self): - packet_ptr = native_bt.notification_packet_begin_get_packet(self._ptr) + packet_ptr = native_bt.message_packet_begin_get_packet(self._ptr) assert(packet_ptr) return bt2.packet._Packet._create_from_ptr(packet_ptr) @@ -153,27 +153,27 @@ class PacketBeginningNotification(_CopyableNotification): def _copy(self, copy_func): # We can always use references here because those properties are - # frozen anyway if they are part of a notification. Since the - # user cannot modify them after copying the notification, it's + # frozen anyway if they are part of a message. Since the + # user cannot modify them after copying the message, it's # useless to copy/deep-copy them. - return PacketBeginningNotification(self.packet) + return PacketBeginningMessage(self.packet) -class PacketEndNotification(_CopyableNotification): +class PacketEndMessage(_CopyableMessage): _TYPE = native_bt.MESSAGE_TYPE_PACKET_END def __init__(self, packet): utils._check_type(packet, bt2.packet._Packet) - ptr = native_bt.notification_packet_end_create(packet._ptr) + ptr = native_bt.message_packet_end_create(packet._ptr) if ptr is None: - raise bt2.CreationError('cannot create packet end notification object') + raise bt2.CreationError('cannot create packet end message object') super().__init__(ptr) @property def packet(self): - packet_ptr = native_bt.notification_packet_end_get_packet(self._ptr) + packet_ptr = native_bt.message_packet_end_get_packet(self._ptr) assert(packet_ptr) return bt2.packet._Packet._create_from_ptr(packet_ptr) @@ -188,27 +188,27 @@ class PacketEndNotification(_CopyableNotification): def _copy(self, copy_func): # We can always use references here because those properties are - # frozen anyway if they are part of a notification. Since the - # user cannot modify them after copying the notification, it's + # frozen anyway if they are part of a message. Since the + # user cannot modify them after copying the message, it's # useless to copy/deep-copy them. - return PacketEndNotification(self.packet) + return PacketEndMessage(self.packet) -class StreamBeginningNotification(_CopyableNotification): +class StreamBeginningMessage(_CopyableMessage): _TYPE = native_bt.MESSAGE_TYPE_STREAM_BEGINNING def __init__(self, stream): utils._check_type(stream, bt2.stream._Stream) - ptr = native_bt.notification_stream_begin_create(stream._ptr) + ptr = native_bt.message_stream_begin_create(stream._ptr) if ptr is None: - raise bt2.CreationError('cannot create stream beginning notification object') + raise bt2.CreationError('cannot create stream beginning message object') super().__init__(ptr) @property def stream(self): - stream_ptr = native_bt.notification_stream_begin_get_stream(self._ptr) + stream_ptr = native_bt.message_stream_begin_get_stream(self._ptr) assert(stream_ptr) return bt2.stream._create_from_ptr(stream_ptr) @@ -223,27 +223,27 @@ class StreamBeginningNotification(_CopyableNotification): def _copy(self, copy_func): # We can always use references here because those properties are - # frozen anyway if they are part of a notification. Since the - # user cannot modify them after copying the notification, it's + # frozen anyway if they are part of a message. Since the + # user cannot modify them after copying the message, it's # useless to copy/deep-copy them. - return StreamBeginningNotification(self.stream) + return StreamBeginningMessage(self.stream) -class StreamEndNotification(_CopyableNotification): +class StreamEndMessage(_CopyableMessage): _TYPE = native_bt.MESSAGE_TYPE_STREAM_END def __init__(self, stream): utils._check_type(stream, bt2.stream._Stream) - ptr = native_bt.notification_stream_end_create(stream._ptr) + ptr = native_bt.message_stream_end_create(stream._ptr) if ptr is None: - raise bt2.CreationError('cannot create stream end notification object') + raise bt2.CreationError('cannot create stream end message object') super().__init__(ptr) @property def stream(self): - stream_ptr = native_bt.notification_stream_end_get_stream(self._ptr) + stream_ptr = native_bt.message_stream_end_get_stream(self._ptr) assert(stream_ptr) return bt2.stream._create_from_ptr(stream_ptr) @@ -258,16 +258,16 @@ class StreamEndNotification(_CopyableNotification): def _copy(self, copy_func): # We can always use references here because those properties are - # frozen anyway if they are part of a notification. Since the - # user cannot modify them after copying the notification, it's + # frozen anyway if they are part of a message. Since the + # user cannot modify them after copying the message, it's # useless to copy/deep-copy them. - return StreamEndNotification(self.stream) + return StreamEndMessage(self.stream) -class _InactivityNotificationClockValuesIterator(collections.abc.Iterator): - def __init__(self, notif_clock_values): - self._notif_clock_values = notif_clock_values - self._clock_classes = list(notif_clock_values._notif.clock_class_priority_map) +class _InactivityMessageClockValuesIterator(collections.abc.Iterator): + def __init__(self, msg_clock_values): + self._msg_clock_values = msg_clock_values + self._clock_classes = list(msg_clock_values._msg.clock_class_priority_map) self._at = 0 def __next__(self): @@ -278,13 +278,13 @@ class _InactivityNotificationClockValuesIterator(collections.abc.Iterator): return self._clock_classes[at] -class _InactivityNotificationClockValues(collections.abc.Mapping): - def __init__(self, notif): - self._notif = notif +class _InactivityMessageClockValues(collections.abc.Mapping): + def __init__(self, msg): + self._msg = msg def __getitem__(self, clock_class): utils._check_type(clock_class, bt2.ClockClass) - clock_value_ptr = native_bt.notification_inactivity_get_clock_value(self._notif._ptr, + clock_value_ptr = native_bt.message_inactivity_get_clock_value(self._msg._ptr, clock_class._ptr) if clock_value_ptr is None: @@ -295,18 +295,18 @@ class _InactivityNotificationClockValues(collections.abc.Mapping): def add(self, clock_value): utils._check_type(clock_value, bt2.clock_value._ClockValue) - ret = native_bt.notification_inactivity_set_clock_value(self._notif._ptr, + ret = native_bt.message_inactivity_set_clock_value(self._msg._ptr, clock_value._ptr) - utils._handle_ret(ret, "cannot set inactivity notification object's clock value") + utils._handle_ret(ret, "cannot set inactivity message object's clock value") def __len__(self): - return len(self._notif.clock_class_priority_map) + return len(self._msg.clock_class_priority_map) def __iter__(self): - return _InactivityNotificationClockValuesIterator(self) + return _InactivityMessageClockValuesIterator(self) -class InactivityNotification(_CopyableNotification): +class InactivityMessage(_CopyableMessage): _TYPE = native_bt.MESSAGE_TYPE_MESSAGE_ITERATOR_INACTIVITY def __init__(self, cc_prio_map=None): @@ -316,22 +316,22 @@ class InactivityNotification(_CopyableNotification): else: cc_prio_map_ptr = None - ptr = native_bt.notification_inactivity_create(cc_prio_map_ptr) + ptr = native_bt.message_inactivity_create(cc_prio_map_ptr) if ptr is None: - raise bt2.CreationError('cannot create inactivity notification object') + raise bt2.CreationError('cannot create inactivity message object') super().__init__(ptr) @property def clock_class_priority_map(self): - cc_prio_map_ptr = native_bt.notification_inactivity_get_clock_class_priority_map(self._ptr) + cc_prio_map_ptr = native_bt.message_inactivity_get_clock_class_priority_map(self._ptr) assert(cc_prio_map_ptr) return bt2.clock_class_priority_map.ClockClassPriorityMap._create_from_ptr(cc_prio_map_ptr) @property def clock_values(self): - return _InactivityNotificationClockValues(self) + return _InactivityMessageClockValues(self) def _get_clock_values(self): clock_values = {} @@ -362,7 +362,7 @@ class InactivityNotification(_CopyableNotification): return self_props == other_props def __copy__(self): - cpy = InactivityNotification(self.clock_class_priority_map) + cpy = InactivityMessage(self.clock_class_priority_map) for clock_class, clock_value in self.clock_values.items(): if clock_value is None: @@ -374,7 +374,7 @@ class InactivityNotification(_CopyableNotification): def __deepcopy__(self, memo): cc_prio_map_cpy = copy.deepcopy(self.clock_class_priority_map) - cpy = InactivityNotification(cc_prio_map_cpy) + cpy = InactivityMessage(cc_prio_map_cpy) # copy clock values for orig_clock_class in self.clock_class_priority_map: @@ -391,14 +391,14 @@ class InactivityNotification(_CopyableNotification): # create copy of clock value from copied clock class clock_value_cpy = cpy_clock_class(orig_clock_value.cycles) - # set copied clock value in notification copy + # set copied clock value in message copy cpy.clock_values.add(clock_value_cpy) memo[id(self)] = cpy return cpy -class _DiscardedElementsNotification(_Notification): +class _DiscardedElementsMessage(_Message): def __eq__(self, other): if type(other) is not type(self): return False @@ -421,24 +421,24 @@ class _DiscardedElementsNotification(_Notification): return self_props == other_props -class _DiscardedPacketsNotification(_DiscardedElementsNotification): +class _DiscardedPacketsMessage(_DiscardedElementsMessage): _TYPE = native_bt.MESSAGE_TYPE_DISCARDED_PACKETS @property def count(self): - count = native_bt.notification_discarded_packets_get_count(self._ptr) + count = native_bt.message_discarded_packets_get_count(self._ptr) assert(count >= 0) return count @property def stream(self): - stream_ptr = native_bt.notification_discarded_packets_get_stream(self._ptr) + stream_ptr = native_bt.message_discarded_packets_get_stream(self._ptr) assert(stream_ptr) return bt2.stream._create_from_ptr(stream_ptr) @property def beginning_clock_value(self): - clock_value_ptr = native_bt.notification_discarded_packets_get_begin_clock_value(self._ptr) + clock_value_ptr = native_bt.message_discarded_packets_get_begin_clock_value(self._ptr) if clock_value_ptr is None: return @@ -448,7 +448,7 @@ class _DiscardedPacketsNotification(_DiscardedElementsNotification): @property def end_clock_value(self): - clock_value_ptr = native_bt.notification_discarded_packets_get_end_clock_value(self._ptr) + clock_value_ptr = native_bt.message_discarded_packets_get_end_clock_value(self._ptr) if clock_value_ptr is None: return @@ -457,24 +457,24 @@ class _DiscardedPacketsNotification(_DiscardedElementsNotification): return clock_value -class _DiscardedEventsNotification(_DiscardedElementsNotification): +class _DiscardedEventsMessage(_DiscardedElementsMessage): _TYPE = native_bt.MESSAGE_TYPE_DISCARDED_EVENTS @property def count(self): - count = native_bt.notification_discarded_events_get_count(self._ptr) + count = native_bt.message_discarded_events_get_count(self._ptr) assert(count >= 0) return count @property def stream(self): - stream_ptr = native_bt.notification_discarded_events_get_stream(self._ptr) + stream_ptr = native_bt.message_discarded_events_get_stream(self._ptr) assert(stream_ptr) return bt2.stream._create_from_ptr(stream_ptr) @property def beginning_clock_value(self): - clock_value_ptr = native_bt.notification_discarded_events_get_begin_clock_value(self._ptr) + clock_value_ptr = native_bt.message_discarded_events_get_begin_clock_value(self._ptr) if clock_value_ptr is None: return @@ -484,7 +484,7 @@ class _DiscardedEventsNotification(_DiscardedElementsNotification): @property def end_clock_value(self): - clock_value_ptr = native_bt.notification_discarded_events_get_end_clock_value(self._ptr) + clock_value_ptr = native_bt.message_discarded_events_get_end_clock_value(self._ptr) if clock_value_ptr is None: return @@ -493,13 +493,13 @@ class _DiscardedEventsNotification(_DiscardedElementsNotification): return clock_value -_NOTIF_TYPE_TO_CLS = { - native_bt.MESSAGE_TYPE_EVENT: EventNotification, - native_bt.MESSAGE_TYPE_PACKET_BEGINNING: PacketBeginningNotification, - native_bt.MESSAGE_TYPE_PACKET_END: PacketEndNotification, - native_bt.MESSAGE_TYPE_STREAM_BEGINNING: StreamBeginningNotification, - native_bt.MESSAGE_TYPE_STREAM_END: StreamEndNotification, - native_bt.MESSAGE_TYPE_MESSAGE_ITERATOR_INACTIVITY: InactivityNotification, - native_bt.MESSAGE_TYPE_DISCARDED_PACKETS: _DiscardedPacketsNotification, - native_bt.MESSAGE_TYPE_DISCARDED_EVENTS: _DiscardedEventsNotification, +_MESSAGE_TYPE_TO_CLS = { + native_bt.MESSAGE_TYPE_EVENT: EventMessage, + native_bt.MESSAGE_TYPE_PACKET_BEGINNING: PacketBeginningMessage, + native_bt.MESSAGE_TYPE_PACKET_END: PacketEndMessage, + native_bt.MESSAGE_TYPE_STREAM_BEGINNING: StreamBeginningMessage, + native_bt.MESSAGE_TYPE_STREAM_END: StreamEndMessage, + native_bt.MESSAGE_TYPE_MESSAGE_ITERATOR_INACTIVITY: InactivityMessage, + native_bt.MESSAGE_TYPE_DISCARDED_PACKETS: _DiscardedPacketsMessage, + native_bt.MESSAGE_TYPE_DISCARDED_EVENTS: _DiscardedEventsMessage, } diff --git a/bindings/python/bt2/bt2/notification_iterator.py b/bindings/python/bt2/bt2/message_iterator.py similarity index 67% rename from bindings/python/bt2/bt2/notification_iterator.py rename to bindings/python/bt2/bt2/message_iterator.py index 363f62d2..69b1c4f6 100644 --- a/bindings/python/bt2/bt2/notification_iterator.py +++ b/bindings/python/bt2/bt2/message_iterator.py @@ -21,21 +21,21 @@ # THE SOFTWARE. from bt2 import native_bt, object, utils -import bt2.notification +import bt2.message import collections.abc import bt2.component import bt2 -class _NotificationIterator(collections.abc.Iterator): +class _MessageIterator(collections.abc.Iterator): def _handle_status(self, status, gen_error_msg): - if status == native_bt.NOTIFICATION_ITERATOR_STATUS_CANCELED: - raise bt2.NotificationIteratorCanceled - elif status == native_bt.NOTIFICATION_ITERATOR_STATUS_AGAIN: + if status == native_bt.MESSAGE_ITERATOR_STATUS_CANCELED: + raise bt2.MessageIteratorCanceled + elif status == native_bt.MESSAGE_ITERATOR_STATUS_AGAIN: raise bt2.TryAgain - elif status == native_bt.NOTIFICATION_ITERATOR_STATUS_END: + elif status == native_bt.MESSAGE_ITERATOR_STATUS_END: raise bt2.Stop - elif status == native_bt.NOTIFICATION_ITERATOR_STATUS_UNSUPPORTED: + elif status == native_bt.MESSAGE_ITERATOR_STATUS_UNSUPPORTED: raise bt2.UnsupportedFeature elif status < 0: raise bt2.Error(gen_error_msg) @@ -44,35 +44,35 @@ class _NotificationIterator(collections.abc.Iterator): raise NotImplementedError -class _GenericNotificationIterator(object._Object, _NotificationIterator): - def _get_notif(self): - notif_ptr = native_bt.notification_iterator_get_notification(self._ptr) - utils._handle_ptr(notif_ptr, "cannot get notification iterator object's current notification object") - return bt2.notification._create_from_ptr(notif_ptr) +class _GenericMessageIterator(object._Object, _MessageIterator): + def _get_msg(self): + msg_ptr = native_bt.message_iterator_get_message(self._ptr) + utils._handle_ptr(msg_ptr, "cannot get message iterator object's current message object") + return bt2.message._create_from_ptr(msg_ptr) def _next(self): - status = native_bt.notification_iterator_next(self._ptr) + status = native_bt.message_iterator_next(self._ptr) self._handle_status(status, - 'unexpected error: cannot advance the notification iterator') + 'unexpected error: cannot advance the message iterator') def __next__(self): self._next() - return self._get_notif() + return self._get_msg() -class _PrivateConnectionNotificationIterator(_GenericNotificationIterator): +class _PrivateConnectionMessageIterator(_GenericMessageIterator): @property def component(self): - comp_ptr = native_bt.private_connection_notification_iterator_get_component(self._ptr) + comp_ptr = native_bt.private_connection_message_iterator_get_component(self._ptr) assert(comp_ptr) return bt2.component._create_generic_component_from_ptr(comp_ptr) -class _OutputPortNotificationIterator(_GenericNotificationIterator): +class _OutputPortMessageIterator(_GenericMessageIterator): pass -class _UserNotificationIterator(_NotificationIterator): +class _UserMessageIterator(_MessageIterator): def __new__(cls, ptr): # User iterator objects are always created by the native side, # that is, never instantiated directly by Python code. @@ -93,7 +93,7 @@ class _UserNotificationIterator(_NotificationIterator): @property def _component(self): - return native_bt.py3_get_user_component_from_user_notif_iter(self._ptr) + return native_bt.py3_get_user_component_from_user_msg_iter(self._ptr) @property def addr(self): @@ -108,14 +108,14 @@ class _UserNotificationIterator(_NotificationIterator): def _next_from_native(self): # this can raise anything: it's catched by the native part try: - notif = next(self) + msg = next(self) except StopIteration: raise bt2.Stop except: raise - utils._check_type(notif, bt2.notification._Notification) + utils._check_type(msg, bt2.message._Message) # take a new reference for the native part - notif._get() - return int(notif._ptr) + msg._get() + return int(msg._ptr) diff --git a/bindings/python/bt2/bt2/native_bt_component_class.i b/bindings/python/bt2/bt2/native_bt_component_class.i index b9c7b13a..47a446de 100644 --- a/bindings/python/bt2/bt2/native_bt_component_class.i +++ b/bindings/python/bt2/bt2/native_bt_component_class.i @@ -520,7 +520,7 @@ static PyObject *py_mod_bt2_exc_error_type = NULL; static PyObject *py_mod_bt2_exc_try_again_type = NULL; static PyObject *py_mod_bt2_exc_stop_type = NULL; static PyObject *py_mod_bt2_exc_port_connection_refused_type = NULL; -static PyObject *py_mod_bt2_exc_notif_iter_canceled_type = NULL; +static PyObject *py_mod_bt2_exc_msg_iter_canceled_type = NULL; static PyObject *py_mod_bt2_exc_invalid_query_object_type = NULL; static PyObject *py_mod_bt2_exc_invalid_query_params_type = NULL; @@ -576,7 +576,7 @@ static void bt_py3_cc_exit_handler(void) Py_XDECREF(py_mod_bt2_exc_try_again_type); Py_XDECREF(py_mod_bt2_exc_stop_type); Py_XDECREF(py_mod_bt2_exc_port_connection_refused_type); - Py_XDECREF(py_mod_bt2_exc_notif_iter_canceled_type); + Py_XDECREF(py_mod_bt2_exc_msg_iter_canceled_type); Py_XDECREF(py_mod_bt2_exc_invalid_query_object_type); Py_XDECREF(py_mod_bt2_exc_invalid_query_params_type); } @@ -1346,7 +1346,7 @@ bt_py3_component_class_message_iterator_init( py_comp = bt_self_component_get_data(self_component); - /* Find user's Python notification iterator class */ + /* Find user's Python message iterator class */ py_comp_cls = PyObject_GetAttrString(py_comp, "__class__"); if (!py_comp_cls) { BT_LOGE_STR("Cannot get Python object's `__class__` attribute."); @@ -1367,7 +1367,7 @@ bt_py3_component_class_message_iterator_init( } /* - * Create object with borrowed native notification iterator + * Create object with borrowed native message iterator * reference: * * py_iter = py_iter_cls.__new__(py_iter_cls, py_iter_ptr) @@ -1400,20 +1400,20 @@ bt_py3_component_class_message_iterator_init( /* * Since the Python code can never instantiate a user-defined - * notification iterator class, the native notification iterator - * object does NOT belong to a user Python notification iterator + * message iterator class, the native message iterator + * object does NOT belong to a user Python message iterator * object (borrowed reference). However this Python object is - * owned by this native notification iterator object. + * owned by this native message iterator object. * - * In the Python world, the lifetime of the native notification - * iterator is managed by a _GenericNotificationIterator + * In the Python world, the lifetime of the native message + * iterator is managed by a _GenericMessageIterator * instance: * - * _GenericNotificationIterator instance: - * owns a native bt_notification_iterator object (iter) + * _GenericMessageIterator instance: + * owns a native bt_message_iterator object (iter) * owns a _UserMessageIterator instance (py_iter) * self._ptr is a borrowed reference to the - * native bt_private_connection_private_notification_iterator + * native bt_private_connection_private_message_iterator * object (iter) */ bt_self_message_iterator_set_data(self_message_iterator, py_iter); @@ -1516,7 +1516,7 @@ bt_py3_component_class_message_iterator_next( /* * The returned object, on success, is an integer object - * (PyLong) containing the address of a native notification + * (PyLong) containing the address of a native message * object (which is now ours). */ msgs[0] = diff --git a/bindings/python/bt2/bt2/port.py b/bindings/python/bt2/bt2/port.py index f5bc3ef7..68039a43 100644 --- a/bindings/python/bt2/bt2/port.py +++ b/bindings/python/bt2/bt2/port.py @@ -24,8 +24,8 @@ from bt2 import native_bt, object, utils import collections.abc import bt2.component import bt2.connection -import bt2.notification_iterator -import bt2.notification +import bt2.message_iterator +import bt2.message import copy import bt2 @@ -114,21 +114,21 @@ class _InputPort(_Port): class _OutputPort(_Port): - def create_notification_iterator(self, notification_types=None, + def create_message_iterator(self, message_types=None, colander_component_name=None): - notif_types = bt2.notification._notif_types_from_notif_classes(notification_types) + msg_types = bt2.message._msg_types_from_msg_classes(message_types) if colander_component_name is not None: utils._check_str(colander_component_name) - notif_iter_ptr = native_bt.py3_create_output_port_notif_iter(int(self._ptr), + msg_iter_ptr = native_bt.py3_create_output_port_msg_iter(int(self._ptr), colander_component_name, - notif_types) + msg_types) - if notif_iter_ptr is None: - raise bt2.CreationError('cannot create output port notification iterator') + if msg_iter_ptr is None: + raise bt2.CreationError('cannot create output port message iterator') - return bt2.notification_iterator._OutputPortNotificationIterator._create_from_ptr(notif_iter_ptr) + return bt2.message_iterator._OutputPortMessageIterator._create_from_ptr(msg_iter_ptr) class _PrivatePort(object._PrivateObject, _Port): diff --git a/bindings/python/bt2/bt2/trace_collection_notification_iterator.py b/bindings/python/bt2/bt2/trace_collection_message_iterator.py similarity index 94% rename from bindings/python/bt2/bt2/trace_collection_notification_iterator.py rename to bindings/python/bt2/bt2/trace_collection_message_iterator.py index a2343673..3a08964b 100644 --- a/bindings/python/bt2/bt2/trace_collection_notification_iterator.py +++ b/bindings/python/bt2/bt2/trace_collection_message_iterator.py @@ -23,7 +23,7 @@ from bt2 import utils import bt2 import itertools -import bt2.notification_iterator +import bt2.message_iterator import datetime import collections.abc from collections import namedtuple @@ -81,15 +81,15 @@ class _CompClsType: FILTER = 1 -class TraceCollectionNotificationIterator(bt2.notification_iterator._NotificationIterator): +class TraceCollectionMessageIterator(bt2.message_iterator._MessageIterator): def __init__(self, source_component_specs, filter_component_specs=None, - notification_types=None, stream_intersection_mode=False, + message_types=None, stream_intersection_mode=False, begin=None, end=None): utils._check_bool(stream_intersection_mode) self._stream_intersection_mode = stream_intersection_mode self._begin_ns = _get_ns(begin) self._end_ns = _get_ns(end) - self._notification_types = notification_types + self._message_types = message_types if type(source_component_specs) is ComponentSpec: source_component_specs = [source_component_specs] @@ -118,7 +118,7 @@ class TraceCollectionNotificationIterator(bt2.notification_iterator._Notificatio raise TypeError('"{}" object is not a ComponentSpec'.format(type(comp_spec))) def __next__(self): - return next(self._notif_iter) + return next(self._msg_iter) def _create_stream_intersection_trimmer(self, port): # find the original parameters specified by the user to create @@ -274,9 +274,9 @@ class TraceCollectionNotificationIterator(bt2.notification_iterator._Notificatio self._end_ns, 'trimmer') self._graph.connect_ports(self._muxer_comp.output_ports['out'], trimmer_comp.input_ports['in']) - notif_iter_port = trimmer_comp.output_ports['out'] + msg_iter_port = trimmer_comp.output_ports['out'] else: - notif_iter_port = self._muxer_comp.output_ports['out'] + msg_iter_port = self._muxer_comp.output_ports['out'] # create extra filter components (chained) for comp_spec in self._flt_comp_specs: @@ -287,8 +287,8 @@ class TraceCollectionNotificationIterator(bt2.notification_iterator._Notificatio for comp_and_spec in self._flt_comps_and_specs: in_port = list(comp_and_spec.comp.input_ports.values())[0] out_port = list(comp_and_spec.comp.output_ports.values())[0] - self._graph.connect_ports(notif_iter_port, in_port) - notif_iter_port = out_port + self._graph.connect_ports(msg_iter_port, in_port) + msg_iter_port = out_port # Here we create the components, self._graph_port_added() is # called when they add ports, but the callback returns early @@ -317,5 +317,5 @@ class TraceCollectionNotificationIterator(bt2.notification_iterator._Notificatio self._connect_src_comp_port(out_port) - # create this trace collection iterator's notification iterator - self._notif_iter = notif_iter_port.create_notification_iterator(self._notification_types) + # create this trace collection iterator's message iterator + self._msg_iter = msg_iter_port.create_message_iterator(self._message_types) diff --git a/tests/bindings/python/bt2/Makefile.am b/tests/bindings/python/bt2/Makefile.am index e966da9c..ad74e25b 100644 --- a/tests/bindings/python/bt2/Makefile.am +++ b/tests/bindings/python/bt2/Makefile.am @@ -10,14 +10,14 @@ EXTRA_DIST = \ test_field_types.py \ test_fields.py \ test_graph.py \ - test_notification.py \ - test_notification_iterator.py \ + test_message.py \ + test_message_iterator.py \ test_packet.py \ test_plugin.py \ test_port.py \ test_stream.py \ test_stream_class.py \ test_trace.py \ - test_trace_collection_notification_iterator.py \ + test_trace_collection_message_iterator.py \ test_values.py \ .coveragerc diff --git a/tests/bindings/python/bt2/test_component_class.py b/tests/bindings/python/bt2/test_component_class.py index e1d6b665..a4b7e05d 100644 --- a/tests/bindings/python/bt2/test_component_class.py +++ b/tests/bindings/python/bt2/test_component_class.py @@ -11,23 +11,23 @@ class UserComponentClassTestCase(unittest.TestCase): cls() def test_no_init_source(self): - class MyIter(bt2._UserNotificationIterator): + class MyIter(bt2._UserMessageIterator): def __next__(self): raise bt2.Stop class MySource(bt2._UserSourceComponent, - notification_iterator_class=MyIter): + message_iterator_class=MyIter): pass self._test_no_init(MySource) def test_no_init_filter(self): - class MyIter(bt2._UserNotificationIterator): + class MyIter(bt2._UserMessageIterator): def __next__(self): raise bt2.Stop class MyFilter(bt2._UserFilterComponent, - notification_iterator_class=MyIter): + message_iterator_class=MyIter): pass self._test_no_init(MyFilter) @@ -39,25 +39,25 @@ class UserComponentClassTestCase(unittest.TestCase): self._test_no_init(MySink) - def test_incomplete_source_no_notif_iter_cls(self): - class MyIter(bt2._UserNotificationIterator): + def test_incomplete_source_no_msg_iter_cls(self): + class MyIter(bt2._UserMessageIterator): pass with self.assertRaises(bt2.IncompleteUserClass): class MySource(bt2._UserSourceComponent): pass - def test_incomplete_source_wrong_notif_iter_cls_type(self): - class MyIter(bt2._UserNotificationIterator): + def test_incomplete_source_wrong_msg_iter_cls_type(self): + class MyIter(bt2._UserMessageIterator): pass with self.assertRaises(bt2.IncompleteUserClass): class MySource(bt2._UserSourceComponent, - notification_iterator_class=int): + message_iterator_class=int): pass - def test_incomplete_filter_no_notif_iter_cls(self): - class MyIter(bt2._UserNotificationIterator): + def test_incomplete_filter_no_msg_iter_cls(self): + class MyIter(bt2._UserMessageIterator): pass with self.assertRaises(bt2.IncompleteUserClass): @@ -65,7 +65,7 @@ class UserComponentClassTestCase(unittest.TestCase): pass def test_incomplete_sink_no_consume_method(self): - class MyIter(bt2._UserNotificationIterator): + class MyIter(bt2._UserMessageIterator): pass with self.assertRaises(bt2.IncompleteUserClass): @@ -73,19 +73,19 @@ class UserComponentClassTestCase(unittest.TestCase): pass def test_minimal_source(self): - class MyIter(bt2._UserNotificationIterator): + class MyIter(bt2._UserMessageIterator): pass class MySource(bt2._UserSourceComponent, - notification_iterator_class=MyIter): + message_iterator_class=MyIter): pass def test_minimal_filter(self): - class MyIter(bt2._UserNotificationIterator): + class MyIter(bt2._UserMessageIterator): pass class MyFilter(bt2._UserFilterComponent, - notification_iterator_class=MyIter): + message_iterator_class=MyIter): pass def test_minimal_sink(self): diff --git a/tests/bindings/python/bt2/test_connection.py b/tests/bindings/python/bt2/test_connection.py index bccdf2fe..163e067e 100644 --- a/tests/bindings/python/bt2/test_connection.py +++ b/tests/bindings/python/bt2/test_connection.py @@ -7,12 +7,12 @@ import bt2 @unittest.skip("this is broken") class ConnectionTestCase(unittest.TestCase): def test_create(self): - class MyIter(bt2._UserNotificationIterator): + class MyIter(bt2._UserMessageIterator): def __next__(self): raise bt2.Stop class MySource(bt2._UserSourceComponent, - notification_iterator_class=MyIter): + message_iterator_class=MyIter): def __init__(self, params): self._add_output_port('out') @@ -32,12 +32,12 @@ class ConnectionTestCase(unittest.TestCase): self.assertNotIsInstance(conn, bt2._PrivateConnection) def test_is_ended_false(self): - class MyIter(bt2._UserNotificationIterator): + class MyIter(bt2._UserMessageIterator): def __next__(self): raise bt2.Stop class MySource(bt2._UserSourceComponent, - notification_iterator_class=MyIter): + message_iterator_class=MyIter): def __init__(self, params): self._add_output_port('out') @@ -56,12 +56,12 @@ class ConnectionTestCase(unittest.TestCase): self.assertFalse(conn.is_ended) def test_is_ended_true(self): - class MyIter(bt2._UserNotificationIterator): + class MyIter(bt2._UserMessageIterator): def __next__(self): raise bt2.Stop class MySource(bt2._UserSourceComponent, - notification_iterator_class=MyIter): + message_iterator_class=MyIter): def __init__(self, params): self._add_output_port('out') @@ -81,12 +81,12 @@ class ConnectionTestCase(unittest.TestCase): self.assertTrue(conn.is_ended) def test_downstream_port(self): - class MyIter(bt2._UserNotificationIterator): + class MyIter(bt2._UserMessageIterator): def __next__(self): raise bt2.Stop class MySource(bt2._UserSourceComponent, - notification_iterator_class=MyIter): + message_iterator_class=MyIter): def __init__(self, params): self._add_output_port('out') @@ -105,12 +105,12 @@ class ConnectionTestCase(unittest.TestCase): self.assertEqual(conn.downstream_port.addr, sink.input_ports['in'].addr) def test_upstream_port(self): - class MyIter(bt2._UserNotificationIterator): + class MyIter(bt2._UserMessageIterator): def __next__(self): raise bt2.Stop class MySource(bt2._UserSourceComponent, - notification_iterator_class=MyIter): + message_iterator_class=MyIter): def __init__(self, params): self._add_output_port('out') @@ -129,12 +129,12 @@ class ConnectionTestCase(unittest.TestCase): self.assertEqual(conn.upstream_port.addr, src.output_ports['out'].addr) def test_eq(self): - class MyIter(bt2._UserNotificationIterator): + class MyIter(bt2._UserMessageIterator): def __next__(self): raise bt2.Stop class MySource(bt2._UserSourceComponent, - notification_iterator_class=MyIter): + message_iterator_class=MyIter): def __init__(self, params): self._add_output_port('out') @@ -153,12 +153,12 @@ class ConnectionTestCase(unittest.TestCase): self.assertEqual(conn, conn) def test_eq_invalid(self): - class MyIter(bt2._UserNotificationIterator): + class MyIter(bt2._UserMessageIterator): def __next__(self): raise bt2.Stop class MySource(bt2._UserSourceComponent, - notification_iterator_class=MyIter): + message_iterator_class=MyIter): def __init__(self, params): self._add_output_port('out') @@ -180,12 +180,12 @@ class ConnectionTestCase(unittest.TestCase): @unittest.skip("this is broken") class PrivateConnectionTestCase(unittest.TestCase): def test_create(self): - class MyIter(bt2._UserNotificationIterator): + class MyIter(bt2._UserMessageIterator): def __next__(self): raise bt2.Stop class MySource(bt2._UserSourceComponent, - notification_iterator_class=MyIter): + message_iterator_class=MyIter): def __init__(self, params): self._add_output_port('out') @@ -211,12 +211,12 @@ class PrivateConnectionTestCase(unittest.TestCase): del priv_conn def test_is_ended_false(self): - class MyIter(bt2._UserNotificationIterator): + class MyIter(bt2._UserMessageIterator): def __next__(self): raise bt2.Stop class MySource(bt2._UserSourceComponent, - notification_iterator_class=MyIter): + message_iterator_class=MyIter): def __init__(self, params): self._add_output_port('out') @@ -241,12 +241,12 @@ class PrivateConnectionTestCase(unittest.TestCase): del priv_conn def test_is_ended_true(self): - class MyIter(bt2._UserNotificationIterator): + class MyIter(bt2._UserMessageIterator): def __next__(self): raise bt2.Stop class MySource(bt2._UserSourceComponent, - notification_iterator_class=MyIter): + message_iterator_class=MyIter): def __init__(self, params): self._add_output_port('out') @@ -272,12 +272,12 @@ class PrivateConnectionTestCase(unittest.TestCase): del priv_conn def test_downstream_port(self): - class MyIter(bt2._UserNotificationIterator): + class MyIter(bt2._UserMessageIterator): def __next__(self): raise bt2.Stop class MySource(bt2._UserSourceComponent, - notification_iterator_class=MyIter): + message_iterator_class=MyIter): def __init__(self, params): self._add_output_port('out') @@ -303,12 +303,12 @@ class PrivateConnectionTestCase(unittest.TestCase): del priv_port def test_upstream_port(self): - class MyIter(bt2._UserNotificationIterator): + class MyIter(bt2._UserMessageIterator): def __next__(self): raise bt2.Stop class MySource(bt2._UserSourceComponent, - notification_iterator_class=MyIter): + message_iterator_class=MyIter): def __init__(self, params): self._add_output_port('out') @@ -334,12 +334,12 @@ class PrivateConnectionTestCase(unittest.TestCase): del priv_port def test_eq(self): - class MyIter(bt2._UserNotificationIterator): + class MyIter(bt2._UserMessageIterator): def __next__(self): raise bt2.Stop class MySource(bt2._UserSourceComponent, - notification_iterator_class=MyIter): + message_iterator_class=MyIter): def __init__(self, params): self._add_output_port('out') @@ -364,12 +364,12 @@ class PrivateConnectionTestCase(unittest.TestCase): del priv_conn def test_eq_invalid(self): - class MyIter(bt2._UserNotificationIterator): + class MyIter(bt2._UserMessageIterator): def __next__(self): raise bt2.Stop class MySource(bt2._UserSourceComponent, - notification_iterator_class=MyIter): + message_iterator_class=MyIter): def __init__(self, params): self._add_output_port('out') diff --git a/tests/bindings/python/bt2/test_graph.py b/tests/bindings/python/bt2/test_graph.py index d00ca9ef..6d8bf590 100644 --- a/tests/bindings/python/bt2/test_graph.py +++ b/tests/bindings/python/bt2/test_graph.py @@ -55,12 +55,12 @@ class GraphTestCase(unittest.TestCase): self._graph.add_component(int, 'salut') def test_connect_ports(self): - class MyIter(bt2._UserNotificationIterator): + class MyIter(bt2._UserMessageIterator): def __next__(self): raise bt2.Stop class MySource(bt2._UserSourceComponent, - notification_iterator_class=MyIter): + message_iterator_class=MyIter): def __init__(self, params): self._add_output_port('out') @@ -81,12 +81,12 @@ class GraphTestCase(unittest.TestCase): self.assertEqual(sink.input_ports['in'].connection, conn) def test_connect_ports_invalid_direction(self): - class MyIter(bt2._UserNotificationIterator): + class MyIter(bt2._UserMessageIterator): def __next__(self): raise bt2.Stop class MySource(bt2._UserSourceComponent, - notification_iterator_class=MyIter): + message_iterator_class=MyIter): def __init__(self, params): self._add_output_port('out') @@ -105,12 +105,12 @@ class GraphTestCase(unittest.TestCase): src.output_ports['out']) def test_connect_ports_refused(self): - class MyIter(bt2._UserNotificationIterator): + class MyIter(bt2._UserMessageIterator): def __next__(self): raise bt2.Stop class MySource(bt2._UserSourceComponent, - notification_iterator_class=MyIter): + message_iterator_class=MyIter): def __init__(self, params): self._add_output_port('out') @@ -132,12 +132,12 @@ class GraphTestCase(unittest.TestCase): sink.input_ports['in']) def test_connect_ports_canceled(self): - class MyIter(bt2._UserNotificationIterator): + class MyIter(bt2._UserMessageIterator): def __next__(self): raise bt2.Stop class MySource(bt2._UserSourceComponent, - notification_iterator_class=MyIter): + message_iterator_class=MyIter): def __init__(self, params): self._add_output_port('out') @@ -157,12 +157,12 @@ class GraphTestCase(unittest.TestCase): sink.input_ports['in']) def test_connect_ports_cannot_consume_accept(self): - class MyIter(bt2._UserNotificationIterator): + class MyIter(bt2._UserMessageIterator): def __next__(self): raise bt2.Stop class MySource(bt2._UserSourceComponent, - notification_iterator_class=MyIter): + message_iterator_class=MyIter): def __init__(self, params): self._add_output_port('out') @@ -191,12 +191,12 @@ class GraphTestCase(unittest.TestCase): self.assertIs(type(exc), bt2.CannotConsumeGraph) def test_connect_ports_cannot_consume_connected(self): - class MyIter(bt2._UserNotificationIterator): + class MyIter(bt2._UserMessageIterator): def __next__(self): raise bt2.Stop class MySource(bt2._UserSourceComponent, - notification_iterator_class=MyIter): + message_iterator_class=MyIter): def __init__(self, params): self._add_output_port('out') @@ -231,7 +231,7 @@ class GraphTestCase(unittest.TestCase): self.assertTrue(self._graph.is_canceled) def test_run(self): - class MyIter(bt2._UserNotificationIterator): + class MyIter(bt2._UserMessageIterator): def __init__(self): self._build_meta() self._at = 0 @@ -260,12 +260,12 @@ class GraphTestCase(unittest.TestCase): if self._at == 5: raise bt2.Stop - notif = bt2.EventNotification(self._create_event(self._at * 3)) + msg = bt2.EventMessage(self._create_event(self._at * 3)) self._at += 1 - return notif + return msg class MySource(bt2._UserSourceComponent, - notification_iterator_class=MyIter): + message_iterator_class=MyIter): def __init__(self, params): self._add_output_port('out') @@ -275,26 +275,26 @@ class GraphTestCase(unittest.TestCase): self._at = 0 def _consume(comp_self): - notif = next(comp_self._notif_iter) + msg = next(comp_self._msg_iter) if comp_self._at == 0: - self.assertIsInstance(notif, bt2.StreamBeginningNotification) + self.assertIsInstance(msg, bt2.StreamBeginningMessage) elif comp_self._at == 1: - self.assertIsInstance(notif, bt2.PacketBeginningNotification) + self.assertIsInstance(msg, bt2.PacketBeginningMessage) elif comp_self._at >= 2 and comp_self._at <= 6: - self.assertIsInstance(notif, bt2.EventNotification) - self.assertEqual(notif.event.event_class.name, 'salut') - field = notif.event.payload_field['my_int'] + self.assertIsInstance(msg, bt2.EventMessage) + self.assertEqual(msg.event.event_class.name, 'salut') + field = msg.event.payload_field['my_int'] self.assertEqual(field, (comp_self._at - 2) * 3) elif comp_self._at == 7: - self.assertIsInstance(notif, bt2.PacketEndNotification) + self.assertIsInstance(msg, bt2.PacketEndMessage) elif comp_self._at == 8: - self.assertIsInstance(notif, bt2.StreamEndNotification) + self.assertIsInstance(msg, bt2.StreamEndMessage) comp_self._at += 1 def _port_connected(self, port, other_port): - self._notif_iter = port.connection.create_notification_iterator() + self._msg_iter = port.connection.create_message_iterator() src = self._graph.add_component(MySource, 'src') sink = self._graph.add_component(MySink, 'sink') @@ -303,7 +303,7 @@ class GraphTestCase(unittest.TestCase): self._graph.run() def test_run_again(self): - class MyIter(bt2._UserNotificationIterator): + class MyIter(bt2._UserMessageIterator): def __init__(self): self._build_meta() self._at = 0 @@ -332,12 +332,12 @@ class GraphTestCase(unittest.TestCase): if self._at == 1: raise bt2.TryAgain - notif = bt2.EventNotification(self._create_event(self._at * 3)) + msg = bt2.EventMessage(self._create_event(self._at * 3)) self._at += 1 - return notif + return msg class MySource(bt2._UserSourceComponent, - notification_iterator_class=MyIter): + message_iterator_class=MyIter): def __init__(self, params): self._add_output_port('out') @@ -348,19 +348,19 @@ class GraphTestCase(unittest.TestCase): def _consume(comp_self): if comp_self._at == 0: - notif = next(comp_self._notif_iter) - self.assertIsInstance(notif, bt2.EventNotification) + msg = next(comp_self._msg_iter) + self.assertIsInstance(msg, bt2.EventMessage) elif comp_self._at == 1: with self.assertRaises(bt2.TryAgain): - notif = next(comp_self._notif_iter) + msg = next(comp_self._msg_iter) raise bt2.TryAgain comp_self._at += 1 def _port_connected(self, port, other_port): - types = [bt2.EventNotification] - self._notif_iter = port.connection.create_notification_iterator(types) + types = [bt2.EventMessage] + self._msg_iter = port.connection.create_message_iterator(types) src = self._graph.add_component(MySource, 'src') sink = self._graph.add_component(MySink, 'sink') @@ -371,16 +371,16 @@ class GraphTestCase(unittest.TestCase): self._graph.run() def test_run_no_sink(self): - class MyIter(bt2._UserNotificationIterator): + class MyIter(bt2._UserMessageIterator): pass class MySource(bt2._UserSourceComponent, - notification_iterator_class=MyIter): + message_iterator_class=MyIter): def __init__(self, params): self._add_output_port('out') class MyFilter(bt2._UserFilterComponent, - notification_iterator_class=MyIter): + message_iterator_class=MyIter): def __init__(self, params): self._add_output_port('out') self._add_input_port('in') @@ -394,7 +394,7 @@ class GraphTestCase(unittest.TestCase): self._graph.run() def test_run_error(self): - class MyIter(bt2._UserNotificationIterator): + class MyIter(bt2._UserMessageIterator): def __init__(self): self._build_meta() self._at = 0 @@ -423,12 +423,12 @@ class GraphTestCase(unittest.TestCase): if self._at == 1: raise bt2.TryAgain - notif = bt2.EventNotification(self._create_event(self._at * 3)) + msg = bt2.EventMessage(self._create_event(self._at * 3)) self._at += 1 - return notif + return msg class MySource(bt2._UserSourceComponent, - notification_iterator_class=MyIter): + message_iterator_class=MyIter): def __init__(self, params): self._add_output_port('out') @@ -439,16 +439,16 @@ class GraphTestCase(unittest.TestCase): def _consume(comp_self): if comp_self._at == 0: - notif = next(comp_self._notif_iter) - self.assertIsInstance(notif, bt2.EventNotification) + msg = next(comp_self._msg_iter) + self.assertIsInstance(msg, bt2.EventMessage) elif comp_self._at == 1: raise RuntimeError('error!') comp_self._at += 1 def _port_connected(self, port, other_port): - types = [bt2.EventNotification] - self._notif_iter = port.connection.create_notification_iterator(types) + types = [bt2.EventMessage] + self._msg_iter = port.connection.create_message_iterator(types) src = self._graph.add_component(MySource, 'src') sink = self._graph.add_component(MySink, 'sink') @@ -459,11 +459,11 @@ class GraphTestCase(unittest.TestCase): self._graph.run() def test_run_cannot_consume(self): - class MyIter(bt2._UserNotificationIterator): + class MyIter(bt2._UserMessageIterator): pass class MySource(bt2._UserSourceComponent, - notification_iterator_class=MyIter): + message_iterator_class=MyIter): def __init__(self, params): self._add_output_port('out') @@ -493,12 +493,12 @@ class GraphTestCase(unittest.TestCase): self.assertIs(type(exc), bt2.CannotConsumeGraph) def test_listeners(self): - class MyIter(bt2._UserNotificationIterator): + class MyIter(bt2._UserMessageIterator): def __next__(self): raise bt2.Stop class MySource(bt2._UserSourceComponent, - notification_iterator_class=MyIter): + message_iterator_class=MyIter): def __init__(self, params): self._add_output_port('out') self._add_output_port('zero') diff --git a/tests/bindings/python/bt2/test_notification.py b/tests/bindings/python/bt2/test_message.py similarity index 51% rename from tests/bindings/python/bt2/test_notification.py rename to tests/bindings/python/bt2/test_message.py index 4d16e31a..6a61189e 100644 --- a/tests/bindings/python/bt2/test_notification.py +++ b/tests/bindings/python/bt2/test_message.py @@ -5,7 +5,7 @@ import copy import bt2 -class _NotificationTestCase(unittest.TestCase): +class _MessageTestCase(unittest.TestCase): def setUp(self): self._trace = bt2.Trace() self._sc = bt2.StreamClass() @@ -46,196 +46,196 @@ class _NotificationTestCase(unittest.TestCase): @unittest.skip("this is broken") -class EventNotificationTestCase(_NotificationTestCase): +class EventMessageTestCase(_MessageTestCase): def test_create_no_cc_prio_map(self): - notif = bt2.EventNotification(self._event) - self.assertEqual(notif.event.addr, self._event.addr) - self.assertEqual(len(notif.clock_class_priority_map), 0) + msg = bt2.EventMessage(self._event) + self.assertEqual(msg.event.addr, self._event.addr) + self.assertEqual(len(msg.clock_class_priority_map), 0) def test_create_with_cc_prio_map(self): - notif = bt2.EventNotification(self._event, self._cc_prio_map) - self.assertEqual(notif.event.addr, self._event.addr) - self.assertEqual(len(notif.clock_class_priority_map), 1) - self.assertEqual(notif.clock_class_priority_map.highest_priority_clock_class.addr, + msg = bt2.EventMessage(self._event, self._cc_prio_map) + self.assertEqual(msg.event.addr, self._event.addr) + self.assertEqual(len(msg.clock_class_priority_map), 1) + self.assertEqual(msg.clock_class_priority_map.highest_priority_clock_class.addr, self._clock_class.addr) - self.assertEqual(notif.clock_class_priority_map[self._clock_class], 231) + self.assertEqual(msg.clock_class_priority_map[self._clock_class], 231) def test_eq(self): - notif = bt2.EventNotification(self._event, self._cc_prio_map) + msg = bt2.EventMessage(self._event, self._cc_prio_map) event_copy = copy.copy(self._event) event_copy.packet = self._packet cc_prio_map_copy = copy.copy(self._cc_prio_map) - notif2 = bt2.EventNotification(event_copy, cc_prio_map_copy) - self.assertEqual(notif, notif2) + msg2 = bt2.EventMessage(event_copy, cc_prio_map_copy) + self.assertEqual(msg, msg2) def test_ne_event(self): - notif = bt2.EventNotification(self._event, self._cc_prio_map) + msg = bt2.EventMessage(self._event, self._cc_prio_map) event_copy = copy.copy(self._event) event_copy.payload_field['my_int'] = 17 event_copy.packet = self._packet cc_prio_map_copy = copy.copy(self._cc_prio_map) - notif2 = bt2.EventNotification(event_copy, cc_prio_map_copy) - self.assertNotEqual(notif, notif2) + msg2 = bt2.EventMessage(event_copy, cc_prio_map_copy) + self.assertNotEqual(msg, msg2) def test_ne_cc_prio_map(self): - notif = bt2.EventNotification(self._event) + msg = bt2.EventMessage(self._event) event_copy = copy.copy(self._event) event_copy.packet = self._packet cc_prio_map_copy = copy.copy(self._cc_prio_map) - notif2 = bt2.EventNotification(event_copy, cc_prio_map_copy) - self.assertNotEqual(notif, notif2) + msg2 = bt2.EventMessage(event_copy, cc_prio_map_copy) + self.assertNotEqual(msg, msg2) def test_eq_invalid(self): - notif = bt2.EventNotification(self._event) - self.assertNotEqual(notif, 23) + msg = bt2.EventMessage(self._event) + self.assertNotEqual(msg, 23) def test_copy(self): - notif = bt2.EventNotification(self._event, self._cc_prio_map) - notif2 = copy.copy(notif) - self.assertEqual(notif, notif2) + msg = bt2.EventMessage(self._event, self._cc_prio_map) + msg2 = copy.copy(msg) + self.assertEqual(msg, msg2) def test_deepcopy(self): - notif = bt2.EventNotification(self._event, self._cc_prio_map) - notif2 = copy.deepcopy(notif) - self.assertEqual(notif, notif2) + msg = bt2.EventMessage(self._event, self._cc_prio_map) + msg2 = copy.deepcopy(msg) + self.assertEqual(msg, msg2) @unittest.skip("this is broken") -class PacketBeginningNotificationTestCase(_NotificationTestCase): +class PacketBeginningMessageTestCase(_MessageTestCase): def test_create(self): - notif = bt2.PacketBeginningNotification(self._packet) - self.assertEqual(notif.packet.addr, self._packet.addr) + msg = bt2.PacketBeginningMessage(self._packet) + self.assertEqual(msg.packet.addr, self._packet.addr) def test_eq(self): - notif = bt2.PacketBeginningNotification(self._packet) + msg = bt2.PacketBeginningMessage(self._packet) packet_copy = copy.copy(self._packet) - notif2 = bt2.PacketBeginningNotification(packet_copy) - self.assertEqual(notif, notif2) + msg2 = bt2.PacketBeginningMessage(packet_copy) + self.assertEqual(msg, msg2) def test_ne_packet(self): - notif = bt2.PacketBeginningNotification(self._packet) + msg = bt2.PacketBeginningMessage(self._packet) packet_copy = copy.copy(self._packet) packet_copy.header_field['hello'] = 1847 - notif2 = bt2.PacketBeginningNotification(packet_copy) - self.assertNotEqual(notif, notif2) + msg2 = bt2.PacketBeginningMessage(packet_copy) + self.assertNotEqual(msg, msg2) def test_eq_invalid(self): - notif = bt2.PacketBeginningNotification(self._packet) - self.assertNotEqual(notif, 23) + msg = bt2.PacketBeginningMessage(self._packet) + self.assertNotEqual(msg, 23) def test_copy(self): - notif = bt2.PacketBeginningNotification(self._packet) - notif2 = copy.copy(notif) - self.assertEqual(notif, notif2) + msg = bt2.PacketBeginningMessage(self._packet) + msg2 = copy.copy(msg) + self.assertEqual(msg, msg2) def test_deepcopy(self): - notif = bt2.PacketBeginningNotification(self._packet) - notif2 = copy.deepcopy(notif) - self.assertEqual(notif, notif2) + msg = bt2.PacketBeginningMessage(self._packet) + msg2 = copy.deepcopy(msg) + self.assertEqual(msg, msg2) @unittest.skip("this is broken") -class PacketEndNotificationTestCase(_NotificationTestCase): +class PacketEndMessageTestCase(_MessageTestCase): def test_create(self): - notif = bt2.PacketEndNotification(self._packet) - self.assertEqual(notif.packet.addr, self._packet.addr) + msg = bt2.PacketEndMessage(self._packet) + self.assertEqual(msg.packet.addr, self._packet.addr) def test_eq(self): - notif = bt2.PacketEndNotification(self._packet) + msg = bt2.PacketEndMessage(self._packet) packet_copy = copy.copy(self._packet) - notif2 = bt2.PacketEndNotification(packet_copy) - self.assertEqual(notif, notif2) + msg2 = bt2.PacketEndMessage(packet_copy) + self.assertEqual(msg, msg2) def test_ne_packet(self): - notif = bt2.PacketEndNotification(self._packet) + msg = bt2.PacketEndMessage(self._packet) packet_copy = copy.copy(self._packet) packet_copy.header_field['hello'] = 1847 - notif2 = bt2.PacketEndNotification(packet_copy) - self.assertNotEqual(notif, notif2) + msg2 = bt2.PacketEndMessage(packet_copy) + self.assertNotEqual(msg, msg2) def test_eq_invalid(self): - notif = bt2.PacketEndNotification(self._packet) - self.assertNotEqual(notif, 23) + msg = bt2.PacketEndMessage(self._packet) + self.assertNotEqual(msg, 23) def test_copy(self): - notif = bt2.PacketEndNotification(self._packet) - notif2 = copy.copy(notif) - self.assertEqual(notif, notif2) + msg = bt2.PacketEndMessage(self._packet) + msg2 = copy.copy(msg) + self.assertEqual(msg, msg2) def test_deepcopy(self): - notif = bt2.PacketEndNotification(self._packet) - notif2 = copy.deepcopy(notif) - self.assertEqual(notif, notif2) + msg = bt2.PacketEndMessage(self._packet) + msg2 = copy.deepcopy(msg) + self.assertEqual(msg, msg2) @unittest.skip("this is broken") -class StreamBeginningNotificationTestCase(_NotificationTestCase): +class StreamBeginningMessageTestCase(_MessageTestCase): def test_create(self): - notif = bt2.StreamBeginningNotification(self._stream) - self.assertEqual(notif.stream.addr, self._stream.addr) + msg = bt2.StreamBeginningMessage(self._stream) + self.assertEqual(msg.stream.addr, self._stream.addr) def test_eq(self): - notif = bt2.StreamBeginningNotification(self._stream) + msg = bt2.StreamBeginningMessage(self._stream) stream_copy = copy.copy(self._stream) - notif2 = bt2.StreamBeginningNotification(stream_copy) - self.assertEqual(notif, notif2) + msg2 = bt2.StreamBeginningMessage(stream_copy) + self.assertEqual(msg, msg2) def test_ne_stream(self): - notif = bt2.StreamBeginningNotification(self._stream) + msg = bt2.StreamBeginningMessage(self._stream) stream_copy = self._sc(name='salut') - notif2 = bt2.StreamBeginningNotification(stream_copy) - self.assertNotEqual(notif, notif2) + msg2 = bt2.StreamBeginningMessage(stream_copy) + self.assertNotEqual(msg, msg2) def test_eq_invalid(self): - notif = bt2.StreamBeginningNotification(self._stream) - self.assertNotEqual(notif, 23) + msg = bt2.StreamBeginningMessage(self._stream) + self.assertNotEqual(msg, 23) def test_copy(self): - notif = bt2.StreamBeginningNotification(self._stream) - notif2 = copy.copy(notif) - self.assertEqual(notif, notif2) + msg = bt2.StreamBeginningMessage(self._stream) + msg2 = copy.copy(msg) + self.assertEqual(msg, msg2) def test_deepcopy(self): - notif = bt2.StreamBeginningNotification(self._stream) - notif2 = copy.deepcopy(notif) - self.assertEqual(notif, notif2) + msg = bt2.StreamBeginningMessage(self._stream) + msg2 = copy.deepcopy(msg) + self.assertEqual(msg, msg2) @unittest.skip("this is broken") -class StreamEndNotificationTestCase(_NotificationTestCase): +class StreamEndMessageTestCase(_MessageTestCase): def test_create(self): - notif = bt2.StreamEndNotification(self._stream) - self.assertEqual(notif.stream.addr, self._stream.addr) + msg = bt2.StreamEndMessage(self._stream) + self.assertEqual(msg.stream.addr, self._stream.addr) def test_eq(self): - notif = bt2.StreamEndNotification(self._stream) + msg = bt2.StreamEndMessage(self._stream) stream_copy = copy.copy(self._stream) - notif2 = bt2.StreamEndNotification(stream_copy) - self.assertEqual(notif, notif2) + msg2 = bt2.StreamEndMessage(stream_copy) + self.assertEqual(msg, msg2) def test_ne_stream(self): - notif = bt2.StreamEndNotification(self._stream) + msg = bt2.StreamEndMessage(self._stream) stream_copy = self._sc(name='salut') - notif2 = bt2.StreamEndNotification(stream_copy) - self.assertNotEqual(notif, notif2) + msg2 = bt2.StreamEndMessage(stream_copy) + self.assertNotEqual(msg, msg2) def test_eq_invalid(self): - notif = bt2.StreamEndNotification(self._stream) - self.assertNotEqual(notif, 23) + msg = bt2.StreamEndMessage(self._stream) + self.assertNotEqual(msg, 23) def test_copy(self): - notif = bt2.StreamEndNotification(self._stream) - notif2 = copy.copy(notif) - self.assertEqual(notif, notif2) + msg = bt2.StreamEndMessage(self._stream) + msg2 = copy.copy(msg) + self.assertEqual(msg, msg2) def test_deepcopy(self): - notif = bt2.StreamEndNotification(self._stream) - notif2 = copy.deepcopy(notif) - self.assertEqual(notif, notif2) + msg = bt2.StreamEndMessage(self._stream) + msg2 = copy.deepcopy(msg) + self.assertEqual(msg, msg2) @unittest.skip("this is broken") -class InactivityNotificationTestCase(unittest.TestCase): +class InactivityMessageTestCase(unittest.TestCase): def setUp(self): self._cc1 = bt2.ClockClass('cc1', 1000) self._cc2 = bt2.ClockClass('cc2', 2000) @@ -249,83 +249,83 @@ class InactivityNotificationTestCase(unittest.TestCase): del self._cc_prio_map def test_create_no_cc_prio_map(self): - notif = bt2.InactivityNotification() - self.assertEqual(len(notif.clock_class_priority_map), 0) + msg = bt2.InactivityMessage() + self.assertEqual(len(msg.clock_class_priority_map), 0) def test_create_with_cc_prio_map(self): - notif = bt2.InactivityNotification(self._cc_prio_map) - notif.clock_values.add(self._cc1(123)) - notif.clock_values.add(self._cc2(19487)) - self.assertEqual(len(notif.clock_class_priority_map), 2) - self.assertEqual(notif.clock_class_priority_map, self._cc_prio_map) - self.assertEqual(notif.clock_values[self._cc1], 123) - self.assertEqual(notif.clock_values[self._cc2], 19487) + msg = bt2.InactivityMessage(self._cc_prio_map) + msg.clock_values.add(self._cc1(123)) + msg.clock_values.add(self._cc2(19487)) + self.assertEqual(len(msg.clock_class_priority_map), 2) + self.assertEqual(msg.clock_class_priority_map, self._cc_prio_map) + self.assertEqual(msg.clock_values[self._cc1], 123) + self.assertEqual(msg.clock_values[self._cc2], 19487) def test_eq(self): - notif = bt2.InactivityNotification(self._cc_prio_map) - notif.clock_values.add(self._cc1(123)) - notif.clock_values.add(self._cc2(19487)) + msg = bt2.InactivityMessage(self._cc_prio_map) + msg.clock_values.add(self._cc1(123)) + msg.clock_values.add(self._cc2(19487)) cc_prio_map_copy = copy.copy(self._cc_prio_map) - notif2 = bt2.InactivityNotification(cc_prio_map_copy) - notif2.clock_values.add(self._cc1(123)) - notif2.clock_values.add(self._cc2(19487)) - self.assertEqual(notif, notif2) + msg2 = bt2.InactivityMessage(cc_prio_map_copy) + msg2.clock_values.add(self._cc1(123)) + msg2.clock_values.add(self._cc2(19487)) + self.assertEqual(msg, msg2) def test_ne_cc_prio_map(self): - notif = bt2.InactivityNotification(self._cc_prio_map) - notif.clock_values.add(self._cc1(123)) - notif.clock_values.add(self._cc2(19487)) + msg = bt2.InactivityMessage(self._cc_prio_map) + msg.clock_values.add(self._cc1(123)) + msg.clock_values.add(self._cc2(19487)) cc_prio_map_copy = copy.copy(self._cc_prio_map) cc_prio_map_copy[self._cc2] = 23 - notif2 = bt2.InactivityNotification(cc_prio_map_copy) - self.assertNotEqual(notif, notif2) + msg2 = bt2.InactivityMessage(cc_prio_map_copy) + self.assertNotEqual(msg, msg2) def test_ne_clock_value(self): - notif = bt2.InactivityNotification(self._cc_prio_map) - notif.clock_values.add(self._cc1(123)) - notif.clock_values.add(self._cc2(19487)) - notif2 = bt2.InactivityNotification(self._cc_prio_map) - notif.clock_values.add(self._cc1(123)) - notif.clock_values.add(self._cc2(1847)) - self.assertNotEqual(notif, notif2) + msg = bt2.InactivityMessage(self._cc_prio_map) + msg.clock_values.add(self._cc1(123)) + msg.clock_values.add(self._cc2(19487)) + msg2 = bt2.InactivityMessage(self._cc_prio_map) + msg.clock_values.add(self._cc1(123)) + msg.clock_values.add(self._cc2(1847)) + self.assertNotEqual(msg, msg2) def test_eq_invalid(self): - notif = bt2.InactivityNotification(self._cc_prio_map) - self.assertNotEqual(notif, 23) + msg = bt2.InactivityMessage(self._cc_prio_map) + self.assertNotEqual(msg, 23) def test_copy(self): - notif = bt2.InactivityNotification(self._cc_prio_map) - notif.clock_values.add(self._cc1(123)) - notif.clock_values.add(self._cc2(19487)) - notif_copy = copy.copy(notif) - self.assertEqual(notif, notif_copy) - self.assertNotEqual(notif.addr, notif_copy.addr) - self.assertEqual(notif.clock_class_priority_map.addr, - notif_copy.clock_class_priority_map.addr) - self.assertEqual(notif_copy.clock_values[self._cc1], 123) - self.assertEqual(notif_copy.clock_values[self._cc2], 19487) + msg = bt2.InactivityMessage(self._cc_prio_map) + msg.clock_values.add(self._cc1(123)) + msg.clock_values.add(self._cc2(19487)) + msg_copy = copy.copy(msg) + self.assertEqual(msg, msg_copy) + self.assertNotEqual(msg.addr, msg_copy.addr) + self.assertEqual(msg.clock_class_priority_map.addr, + msg_copy.clock_class_priority_map.addr) + self.assertEqual(msg_copy.clock_values[self._cc1], 123) + self.assertEqual(msg_copy.clock_values[self._cc2], 19487) def test_deepcopy(self): - notif = bt2.InactivityNotification(self._cc_prio_map) - notif.clock_values.add(self._cc1(123)) - notif.clock_values.add(self._cc2(19487)) - notif_copy = copy.deepcopy(notif) - self.assertEqual(notif, notif_copy) - self.assertNotEqual(notif.addr, notif_copy.addr) - self.assertNotEqual(notif.clock_class_priority_map.addr, - notif_copy.clock_class_priority_map.addr) - self.assertEqual(notif.clock_class_priority_map, - notif_copy.clock_class_priority_map) - self.assertNotEqual(list(notif.clock_class_priority_map)[0].addr, - list(notif_copy.clock_class_priority_map)[0].addr) - self.assertIsNone(notif_copy.clock_values[self._cc1]) - self.assertIsNone(notif_copy.clock_values[self._cc2]) - self.assertEqual(notif_copy.clock_values[list(notif_copy.clock_class_priority_map)[0]], 123) - self.assertEqual(notif_copy.clock_values[list(notif_copy.clock_class_priority_map)[1]], 19487) + msg = bt2.InactivityMessage(self._cc_prio_map) + msg.clock_values.add(self._cc1(123)) + msg.clock_values.add(self._cc2(19487)) + msg_copy = copy.deepcopy(msg) + self.assertEqual(msg, msg_copy) + self.assertNotEqual(msg.addr, msg_copy.addr) + self.assertNotEqual(msg.clock_class_priority_map.addr, + msg_copy.clock_class_priority_map.addr) + self.assertEqual(msg.clock_class_priority_map, + msg_copy.clock_class_priority_map) + self.assertNotEqual(list(msg.clock_class_priority_map)[0].addr, + list(msg_copy.clock_class_priority_map)[0].addr) + self.assertIsNone(msg_copy.clock_values[self._cc1]) + self.assertIsNone(msg_copy.clock_values[self._cc2]) + self.assertEqual(msg_copy.clock_values[list(msg_copy.clock_class_priority_map)[0]], 123) + self.assertEqual(msg_copy.clock_values[list(msg_copy.clock_class_priority_map)[1]], 19487) @unittest.skip("this is broken") -class DiscardedPacketsNotificationTestCase(unittest.TestCase): +class DiscardedPacketsMessageTestCase(unittest.TestCase): def setUp(self): self._trace = bt2.Trace() self._sc = bt2.StreamClass() @@ -363,8 +363,8 @@ class DiscardedPacketsNotificationTestCase(unittest.TestCase): event.packet = packet return event - def _get_notif(self): - class MyIter(bt2._UserNotificationIterator): + def _get_msg(self): + class MyIter(bt2._UserMessageIterator): def __init__(iter_self): packet1 = self._stream.create_packet() packet1.context_field['packet_seq_num'] = 0 @@ -380,17 +380,17 @@ class DiscardedPacketsNotificationTestCase(unittest.TestCase): def __next__(self): if self._at == 0: - notif = bt2.EventNotification(self._ev1) + msg = bt2.EventMessage(self._ev1) elif self._at == 1: - notif = bt2.EventNotification(self._ev2) + msg = bt2.EventMessage(self._ev2) else: raise bt2.Stop self._at += 1 - return notif + return msg class MySource(bt2._UserSourceComponent, - notification_iterator_class=MyIter): + message_iterator_class=MyIter): def __init__(self, params): self._add_output_port('out') @@ -399,58 +399,58 @@ class DiscardedPacketsNotificationTestCase(unittest.TestCase): self._add_input_port('in') def _consume(comp_self): - nonlocal the_notif - notif = next(comp_self._notif_iter) + nonlocal the_msg + msg = next(comp_self._msg_iter) - if type(notif) is bt2._DiscardedPacketsNotification: - the_notif = notif + if type(msg) is bt2._DiscardedPacketsMessage: + the_msg = msg raise bt2.Stop def _port_connected(self, port, other_port): - self._notif_iter = port.connection.create_notification_iterator() + self._msg_iter = port.connection.create_message_iterator() - the_notif = None + the_msg = None graph = bt2.Graph() src = graph.add_component(MySource, 'src') sink = graph.add_component(MySink, 'sink') conn = graph.connect_ports(src.output_ports['out'], sink.input_ports['in']) graph.run() - return the_notif + return the_msg def test_create(self): - self.assertIsInstance(self._get_notif(), bt2._DiscardedPacketsNotification) + self.assertIsInstance(self._get_msg(), bt2._DiscardedPacketsMessage) def test_count(self): - self.assertEqual(self._get_notif().count, 4) + self.assertEqual(self._get_msg().count, 4) def test_stream(self): - self.assertEqual(self._get_notif().stream.addr, self._stream.addr) + self.assertEqual(self._get_msg().stream.addr, self._stream.addr) def test_beginning_clock_value(self): - notif = self._get_notif() - beginning_clock_value = notif.beginning_clock_value + msg = self._get_msg() + beginning_clock_value = msg.beginning_clock_value self.assertEqual(beginning_clock_value.clock_class, self._clock_class) self.assertEqual(beginning_clock_value, 6) def test_end_clock_value(self): - notif = self._get_notif() - end_clock_value = notif.end_clock_value + msg = self._get_msg() + end_clock_value = msg.end_clock_value self.assertEqual(end_clock_value.clock_class, self._clock_class) self.assertEqual(end_clock_value, 7) def test_eq(self): - notif1 = self._get_notif() - notif2 = self._get_notif() - self.assertEqual(notif1, notif2) + msg1 = self._get_msg() + msg2 = self._get_msg() + self.assertEqual(msg1, msg2) def test_eq_invalid(self): - notif1 = self._get_notif() - self.assertNotEqual(notif1, 23) + msg1 = self._get_msg() + self.assertNotEqual(msg1, 23) @unittest.skip("this is broken") -class DiscardedEventsNotificationTestCase(unittest.TestCase): +class DiscardedEventsMessageTestCase(unittest.TestCase): def setUp(self): self._trace = bt2.Trace() self._sc = bt2.StreamClass() @@ -488,8 +488,8 @@ class DiscardedEventsNotificationTestCase(unittest.TestCase): event.packet = packet return event - def _get_notif(self): - class MyIter(bt2._UserNotificationIterator): + def _get_msg(self): + class MyIter(bt2._UserMessageIterator): def __init__(iter_self): packet1 = self._stream.create_packet() packet1.context_field['events_discarded'] = 0 @@ -505,17 +505,17 @@ class DiscardedEventsNotificationTestCase(unittest.TestCase): def __next__(self): if self._at == 0: - notif = bt2.EventNotification(self._ev1) + msg = bt2.EventMessage(self._ev1) elif self._at == 1: - notif = bt2.EventNotification(self._ev2) + msg = bt2.EventMessage(self._ev2) else: raise bt2.Stop self._at += 1 - return notif + return msg class MySource(bt2._UserSourceComponent, - notification_iterator_class=MyIter): + message_iterator_class=MyIter): def __init__(self, params): self._add_output_port('out') @@ -524,51 +524,51 @@ class DiscardedEventsNotificationTestCase(unittest.TestCase): self._add_input_port('in') def _consume(comp_self): - nonlocal the_notif - notif = next(comp_self._notif_iter) + nonlocal the_msg + msg = next(comp_self._msg_iter) - if type(notif) is bt2._DiscardedEventsNotification: - the_notif = notif + if type(msg) is bt2._DiscardedEventsMessage: + the_msg = msg raise bt2.Stop def _port_connected(self, port, other_port): - self._notif_iter = port.connection.create_notification_iterator() + self._msg_iter = port.connection.create_message_iterator() - the_notif = None + the_msg = None graph = bt2.Graph() src = graph.add_component(MySource, 'src') sink = graph.add_component(MySink, 'sink') conn = graph.connect_ports(src.output_ports['out'], sink.input_ports['in']) graph.run() - return the_notif + return the_msg def test_create(self): - self.assertIsInstance(self._get_notif(), bt2._DiscardedEventsNotification) + self.assertIsInstance(self._get_msg(), bt2._DiscardedEventsMessage) def test_count(self): - self.assertEqual(self._get_notif().count, 10) + self.assertEqual(self._get_msg().count, 10) def test_stream(self): - self.assertEqual(self._get_notif().stream.addr, self._stream.addr) + self.assertEqual(self._get_msg().stream.addr, self._stream.addr) def test_beginning_clock_value(self): - notif = self._get_notif() - beginning_clock_value = notif.beginning_clock_value + msg = self._get_msg() + beginning_clock_value = msg.beginning_clock_value self.assertEqual(beginning_clock_value.clock_class, self._clock_class) self.assertEqual(beginning_clock_value, 6) def test_end_clock_value(self): - notif = self._get_notif() - end_clock_value = notif.end_clock_value + msg = self._get_msg() + end_clock_value = msg.end_clock_value self.assertEqual(end_clock_value.clock_class, self._clock_class) self.assertEqual(end_clock_value, 10) def test_eq(self): - notif1 = self._get_notif() - notif2 = self._get_notif() - self.assertEqual(notif1, notif2) + msg1 = self._get_msg() + msg2 = self._get_msg() + self.assertEqual(msg1, msg2) def test_eq_invalid(self): - notif1 = self._get_notif() - self.assertNotEqual(notif1, 23) + msg1 = self._get_msg() + self.assertNotEqual(msg1, 23) diff --git a/tests/bindings/python/bt2/test_notification_iterator.py b/tests/bindings/python/bt2/test_message_iterator.py similarity index 73% rename from tests/bindings/python/bt2/test_notification_iterator.py rename to tests/bindings/python/bt2/test_message_iterator.py index 7cb67c4b..44561260 100644 --- a/tests/bindings/python/bt2/test_notification_iterator.py +++ b/tests/bindings/python/bt2/test_message_iterator.py @@ -6,7 +6,7 @@ import bt2 @unittest.skip("this is broken") -class UserNotificationIteratorTestCase(unittest.TestCase): +class UserMessageIteratorTestCase(unittest.TestCase): @staticmethod def _create_graph(src_comp_cls): class MySink(bt2._UserSinkComponent): @@ -14,10 +14,10 @@ class UserNotificationIteratorTestCase(unittest.TestCase): self._add_input_port('in') def _consume(self): - next(self._notif_iter) + next(self._msg_iter) def _port_connected(self, port, other_port): - self._notif_iter = port.connection.create_notification_iterator() + self._msg_iter = port.connection.create_message_iterator() graph = bt2.Graph() src_comp = graph.add_component(src_comp_cls, 'src') @@ -27,13 +27,13 @@ class UserNotificationIteratorTestCase(unittest.TestCase): return graph def test_init(self): - class MyIter(bt2._UserNotificationIterator): + class MyIter(bt2._UserMessageIterator): def __init__(self): nonlocal initialized initialized = True class MySource(bt2._UserSourceComponent, - notification_iterator_class=MyIter): + message_iterator_class=MyIter): def __init__(self, params): self._add_output_port('out') @@ -42,13 +42,13 @@ class UserNotificationIteratorTestCase(unittest.TestCase): self.assertTrue(initialized) def test_finalize(self): - class MyIter(bt2._UserNotificationIterator): + class MyIter(bt2._UserMessageIterator): def _finalize(self): nonlocal finalized finalized = True class MySource(bt2._UserSourceComponent, - notification_iterator_class=MyIter): + message_iterator_class=MyIter): def __init__(self, params): self._add_output_port('out') @@ -58,13 +58,13 @@ class UserNotificationIteratorTestCase(unittest.TestCase): self.assertTrue(finalized) def test_component(self): - class MyIter(bt2._UserNotificationIterator): + class MyIter(bt2._UserMessageIterator): def __init__(self): nonlocal salut salut = self._component._salut class MySource(bt2._UserSourceComponent, - notification_iterator_class=MyIter): + message_iterator_class=MyIter): def __init__(self, params): self._add_output_port('out') self._salut = 23 @@ -74,13 +74,13 @@ class UserNotificationIteratorTestCase(unittest.TestCase): self.assertEqual(salut, 23) def test_addr(self): - class MyIter(bt2._UserNotificationIterator): + class MyIter(bt2._UserMessageIterator): def __init__(self): nonlocal addr addr = self.addr class MySource(bt2._UserSourceComponent, - notification_iterator_class=MyIter): + message_iterator_class=MyIter): def __init__(self, params): self._add_output_port('out') @@ -91,13 +91,13 @@ class UserNotificationIteratorTestCase(unittest.TestCase): @unittest.skip("this is broken") -class PrivateConnectionNotificationIteratorTestCase(unittest.TestCase): +class PrivateConnectionMessageIteratorTestCase(unittest.TestCase): def test_component(self): - class MyIter(bt2._UserNotificationIterator): + class MyIter(bt2._UserMessageIterator): pass class MySource(bt2._UserSourceComponent, - notification_iterator_class=MyIter): + message_iterator_class=MyIter): def __init__(self, params): self._add_output_port('out') @@ -106,12 +106,12 @@ class PrivateConnectionNotificationIteratorTestCase(unittest.TestCase): self._add_input_port('in') def _consume(self): - next(self._notif_iter) + next(self._msg_iter) def _port_connected(self, port, other_port): nonlocal upstream_comp - self._notif_iter = port.connection.create_notification_iterator() - upstream_comp = self._notif_iter.component + self._msg_iter = port.connection.create_message_iterator() + upstream_comp = self._msg_iter.component upstream_comp = None graph = bt2.Graph() @@ -124,9 +124,9 @@ class PrivateConnectionNotificationIteratorTestCase(unittest.TestCase): @unittest.skip("this is broken") -class OutputPortNotificationIteratorTestCase(unittest.TestCase): +class OutputPortMessageIteratorTestCase(unittest.TestCase): def test_component(self): - class MyIter(bt2._UserNotificationIterator): + class MyIter(bt2._UserMessageIterator): def __init__(self): self._build_meta() self._at = 0 @@ -155,22 +155,22 @@ class OutputPortNotificationIteratorTestCase(unittest.TestCase): if self._at == 5: raise bt2.Stop - notif = bt2.EventNotification(self._create_event(self._at * 3)) + msg = bt2.EventMessage(self._create_event(self._at * 3)) self._at += 1 - return notif + return msg class MySource(bt2._UserSourceComponent, - notification_iterator_class=MyIter): + message_iterator_class=MyIter): def __init__(self, params): self._add_output_port('out') graph = bt2.Graph() src = graph.add_component(MySource, 'src') - types = [bt2.EventNotification] - notif_iter = src.output_ports['out'].create_notification_iterator(types) + types = [bt2.EventMessage] + msg_iter = src.output_ports['out'].create_message_iterator(types) - for at, notif in enumerate(notif_iter): - self.assertIsInstance(notif, bt2.EventNotification) - self.assertEqual(notif.event.event_class.name, 'salut') - field = notif.event.payload_field['my_int'] + for at, msg in enumerate(msg_iter): + self.assertIsInstance(msg, bt2.EventMessage) + self.assertEqual(msg.event.event_class.name, 'salut') + field = msg.event.payload_field['my_int'] self.assertEqual(field, at * 3) diff --git a/tests/bindings/python/bt2/test_port.py b/tests/bindings/python/bt2/test_port.py index 942e4044..93b9ab12 100644 --- a/tests/bindings/python/bt2/test_port.py +++ b/tests/bindings/python/bt2/test_port.py @@ -16,12 +16,12 @@ class PortTestCase(unittest.TestCase): return graph.add_component(comp_cls, name) def test_src_add_output_port(self): - class MyIter(bt2._UserNotificationIterator): + class MyIter(bt2._UserMessageIterator): def __next__(self): raise bt2.Stop class MySource(bt2._UserSourceComponent, - notification_iterator_class=MyIter): + message_iterator_class=MyIter): def __init__(comp_self, params): port = comp_self._add_output_port('out') self.assertEqual(port.name, 'out') @@ -31,12 +31,12 @@ class PortTestCase(unittest.TestCase): def test_flt_add_output_port(self): - class MyIter(bt2._UserNotificationIterator): + class MyIter(bt2._UserMessageIterator): def __next__(self): raise bt2.Stop class MyFilter(bt2._UserFilterComponent, - notification_iterator_class=MyIter): + message_iterator_class=MyIter): def __init__(comp_self, params): port = comp_self._add_output_port('out') self.assertEqual(port.name, 'out') @@ -45,12 +45,12 @@ class PortTestCase(unittest.TestCase): self.assertEqual(len(comp.output_ports), 1) def test_flt_add_input_port(self): - class MyIter(bt2._UserNotificationIterator): + class MyIter(bt2._UserMessageIterator): def __next__(self): raise bt2.Stop class MyFilter(bt2._UserFilterComponent, - notification_iterator_class=MyIter): + message_iterator_class=MyIter): def __init__(comp_self, params): port = comp_self._add_input_port('in') self.assertEqual(port.name, 'in') @@ -71,12 +71,12 @@ class PortTestCase(unittest.TestCase): self.assertEqual(len(comp.input_ports), 1) def test_user_src_output_ports_getitem(self): - class MyIter(bt2._UserNotificationIterator): + class MyIter(bt2._UserMessageIterator): def __next__(self): raise bt2.Stop class MySource(bt2._UserSourceComponent, - notification_iterator_class=MyIter): + message_iterator_class=MyIter): def __init__(comp_self, params): port1 = comp_self._add_output_port('clear') port2 = comp_self._add_output_port('print') @@ -88,12 +88,12 @@ class PortTestCase(unittest.TestCase): comp = self._create_comp(MySource) def test_user_flt_output_ports_getitem(self): - class MyIter(bt2._UserNotificationIterator): + class MyIter(bt2._UserMessageIterator): def __next__(self): raise bt2.Stop class MyFilter(bt2._UserFilterComponent, - notification_iterator_class=MyIter): + message_iterator_class=MyIter): def __init__(comp_self, params): port1 = comp_self._add_output_port('clear') port2 = comp_self._add_output_port('print') @@ -105,12 +105,12 @@ class PortTestCase(unittest.TestCase): comp = self._create_comp(MyFilter) def test_user_flt_input_ports_getitem(self): - class MyIter(bt2._UserNotificationIterator): + class MyIter(bt2._UserMessageIterator): def __next__(self): raise bt2.Stop class MyFilter(bt2._UserFilterComponent, - notification_iterator_class=MyIter): + message_iterator_class=MyIter): def __init__(comp_self, params): port1 = comp_self._add_input_port('clear') port2 = comp_self._add_input_port('print') @@ -137,12 +137,12 @@ class PortTestCase(unittest.TestCase): comp = self._create_comp(MySink) def test_user_src_output_ports_getitem_invalid_key(self): - class MyIter(bt2._UserNotificationIterator): + class MyIter(bt2._UserMessageIterator): def __next__(self): raise bt2.Stop class MySource(bt2._UserSourceComponent, - notification_iterator_class=MyIter): + message_iterator_class=MyIter): def __init__(comp_self, params): comp_self._add_output_port('clear') comp_self._add_output_port('print') @@ -154,12 +154,12 @@ class PortTestCase(unittest.TestCase): comp = self._create_comp(MySource) def test_user_flt_output_ports_getitem_invalid_key(self): - class MyIter(bt2._UserNotificationIterator): + class MyIter(bt2._UserMessageIterator): def __next__(self): raise bt2.Stop class MyFilter(bt2._UserFilterComponent, - notification_iterator_class=MyIter): + message_iterator_class=MyIter): def __init__(comp_self, params): comp_self._add_output_port('clear') comp_self._add_output_port('print') @@ -171,12 +171,12 @@ class PortTestCase(unittest.TestCase): comp = self._create_comp(MyFilter) def test_user_flt_input_ports_getitem_invalid_key(self): - class MyIter(bt2._UserNotificationIterator): + class MyIter(bt2._UserMessageIterator): def __next__(self): raise bt2.Stop class MyFilter(bt2._UserFilterComponent, - notification_iterator_class=MyIter): + message_iterator_class=MyIter): def __init__(comp_self, params): comp_self._add_input_port('clear') comp_self._add_input_port('print') @@ -203,12 +203,12 @@ class PortTestCase(unittest.TestCase): comp = self._create_comp(MySink) def test_user_src_output_ports_len(self): - class MyIter(bt2._UserNotificationIterator): + class MyIter(bt2._UserMessageIterator): def __next__(self): raise bt2.Stop class MySource(bt2._UserSourceComponent, - notification_iterator_class=MyIter): + message_iterator_class=MyIter): def __init__(comp_self, params): comp_self._add_output_port('clear') comp_self._add_output_port('print') @@ -218,12 +218,12 @@ class PortTestCase(unittest.TestCase): comp = self._create_comp(MySource) def test_user_flt_output_ports_len(self): - class MyIter(bt2._UserNotificationIterator): + class MyIter(bt2._UserMessageIterator): def __next__(self): raise bt2.Stop class MyFilter(bt2._UserFilterComponent, - notification_iterator_class=MyIter): + message_iterator_class=MyIter): def __init__(comp_self, params): comp_self._add_output_port('clear') comp_self._add_output_port('print') @@ -233,12 +233,12 @@ class PortTestCase(unittest.TestCase): comp = self._create_comp(MyFilter) def test_user_flt_input_ports_len(self): - class MyIter(bt2._UserNotificationIterator): + class MyIter(bt2._UserMessageIterator): def __next__(self): raise bt2.Stop class MyFilter(bt2._UserFilterComponent, - notification_iterator_class=MyIter): + message_iterator_class=MyIter): def __init__(comp_self, params): comp_self._add_input_port('clear') comp_self._add_input_port('print') @@ -261,12 +261,12 @@ class PortTestCase(unittest.TestCase): comp = self._create_comp(MySink) def test_user_src_output_ports_iter(self): - class MyIter(bt2._UserNotificationIterator): + class MyIter(bt2._UserMessageIterator): def __next__(self): raise bt2.Stop class MySource(bt2._UserSourceComponent, - notification_iterator_class=MyIter): + message_iterator_class=MyIter): def __init__(comp_self, params): port1 = comp_self._add_output_port('clear') port2 = comp_self._add_output_port('print') @@ -286,12 +286,12 @@ class PortTestCase(unittest.TestCase): comp = self._create_comp(MySource) def test_user_flt_output_ports_iter(self): - class MyIter(bt2._UserNotificationIterator): + class MyIter(bt2._UserMessageIterator): def __next__(self): raise bt2.Stop class MyFilter(bt2._UserFilterComponent, - notification_iterator_class=MyIter): + message_iterator_class=MyIter): def __init__(comp_self, params): port1 = comp_self._add_output_port('clear') port2 = comp_self._add_output_port('print') @@ -311,12 +311,12 @@ class PortTestCase(unittest.TestCase): comp = self._create_comp(MyFilter) def test_user_flt_input_ports_iter(self): - class MyIter(bt2._UserNotificationIterator): + class MyIter(bt2._UserMessageIterator): def __next__(self): raise bt2.Stop class MyFilter(bt2._UserFilterComponent, - notification_iterator_class=MyIter): + message_iterator_class=MyIter): def __init__(comp_self, params): port1 = comp_self._add_input_port('clear') port2 = comp_self._add_input_port('print') @@ -359,7 +359,7 @@ class PortTestCase(unittest.TestCase): comp = self._create_comp(MySink) def test_gen_src_output_ports_getitem(self): - class MyIter(bt2._UserNotificationIterator): + class MyIter(bt2._UserMessageIterator): def __next__(self): raise bt2.Stop @@ -368,7 +368,7 @@ class PortTestCase(unittest.TestCase): port3 = None class MySource(bt2._UserSourceComponent, - notification_iterator_class=MyIter): + message_iterator_class=MyIter): def __init__(comp_self, params): nonlocal port1, port2, port3 port1 = comp_self._add_output_port('clear') @@ -384,7 +384,7 @@ class PortTestCase(unittest.TestCase): del port3 def test_gen_flt_output_ports_getitem(self): - class MyIter(bt2._UserNotificationIterator): + class MyIter(bt2._UserMessageIterator): def __next__(self): raise bt2.Stop @@ -393,7 +393,7 @@ class PortTestCase(unittest.TestCase): port3 = None class MyFilter(bt2._UserFilterComponent, - notification_iterator_class=MyIter): + message_iterator_class=MyIter): def __init__(comp_self, params): nonlocal port1, port2, port3 port1 = comp_self._add_output_port('clear') @@ -409,7 +409,7 @@ class PortTestCase(unittest.TestCase): del port3 def test_gen_flt_input_ports_getitem(self): - class MyIter(bt2._UserNotificationIterator): + class MyIter(bt2._UserMessageIterator): def __next__(self): raise bt2.Stop @@ -418,7 +418,7 @@ class PortTestCase(unittest.TestCase): port3 = None class MyFilter(bt2._UserFilterComponent, - notification_iterator_class=MyIter): + message_iterator_class=MyIter): def __init__(comp_self, params): nonlocal port1, port2, port3 port1 = comp_self._add_input_port('clear') @@ -457,12 +457,12 @@ class PortTestCase(unittest.TestCase): del port3 def test_gen_src_output_ports_getitem_invalid_key(self): - class MyIter(bt2._UserNotificationIterator): + class MyIter(bt2._UserMessageIterator): def __next__(self): raise bt2.Stop class MySource(bt2._UserSourceComponent, - notification_iterator_class=MyIter): + message_iterator_class=MyIter): def __init__(comp_self, params): comp_self._add_output_port('clear') comp_self._add_output_port('print') @@ -474,12 +474,12 @@ class PortTestCase(unittest.TestCase): comp.output_ports['hello'] def test_gen_flt_output_ports_getitem_invalid_key(self): - class MyIter(bt2._UserNotificationIterator): + class MyIter(bt2._UserMessageIterator): def __next__(self): raise bt2.Stop class MyFilter(bt2._UserFilterComponent, - notification_iterator_class=MyIter): + message_iterator_class=MyIter): def __init__(comp_self, params): comp_self._add_output_port('clear') comp_self._add_output_port('print') @@ -491,12 +491,12 @@ class PortTestCase(unittest.TestCase): comp.output_ports['hello'] def test_gen_flt_input_ports_getitem_invalid_key(self): - class MyIter(bt2._UserNotificationIterator): + class MyIter(bt2._UserMessageIterator): def __next__(self): raise bt2.Stop class MyFilter(bt2._UserFilterComponent, - notification_iterator_class=MyIter): + message_iterator_class=MyIter): def __init__(comp_self, params): comp_self._add_input_port('clear') comp_self._add_input_port('print') @@ -526,12 +526,12 @@ class PortTestCase(unittest.TestCase): comp.input_ports['hello'] def test_gen_src_output_ports_len(self): - class MyIter(bt2._UserNotificationIterator): + class MyIter(bt2._UserMessageIterator): def __next__(self): raise bt2.Stop class MySource(bt2._UserSourceComponent, - notification_iterator_class=MyIter): + message_iterator_class=MyIter): def __init__(comp_self, params): comp_self._add_output_port('clear') comp_self._add_output_port('print') @@ -541,12 +541,12 @@ class PortTestCase(unittest.TestCase): self.assertEqual(len(comp.output_ports), 3) def test_gen_flt_output_ports_len(self): - class MyIter(bt2._UserNotificationIterator): + class MyIter(bt2._UserMessageIterator): def __next__(self): raise bt2.Stop class MyFilter(bt2._UserFilterComponent, - notification_iterator_class=MyIter): + message_iterator_class=MyIter): def __init__(comp_self, params): comp_self._add_output_port('clear') comp_self._add_output_port('print') @@ -556,12 +556,12 @@ class PortTestCase(unittest.TestCase): self.assertEqual(len(comp.output_ports), 3) def test_gen_flt_input_ports_len(self): - class MyIter(bt2._UserNotificationIterator): + class MyIter(bt2._UserMessageIterator): def __next__(self): raise bt2.Stop class MyFilter(bt2._UserFilterComponent, - notification_iterator_class=MyIter): + message_iterator_class=MyIter): def __init__(comp_self, params): comp_self._add_input_port('clear') comp_self._add_input_port('print') @@ -584,7 +584,7 @@ class PortTestCase(unittest.TestCase): self.assertEqual(len(comp.input_ports), 3) def test_gen_src_output_ports_iter(self): - class MyIter(bt2._UserNotificationIterator): + class MyIter(bt2._UserMessageIterator): def __next__(self): raise bt2.Stop @@ -593,7 +593,7 @@ class PortTestCase(unittest.TestCase): port3 = None class MySource(bt2._UserSourceComponent, - notification_iterator_class=MyIter): + message_iterator_class=MyIter): def __init__(comp_self, params): nonlocal port1, port2, port3 port1 = comp_self._add_output_port('clear') @@ -617,7 +617,7 @@ class PortTestCase(unittest.TestCase): del port3 def test_gen_flt_output_ports_iter(self): - class MyIter(bt2._UserNotificationIterator): + class MyIter(bt2._UserMessageIterator): def __next__(self): raise bt2.Stop @@ -626,7 +626,7 @@ class PortTestCase(unittest.TestCase): port3 = None class MyFilter(bt2._UserFilterComponent, - notification_iterator_class=MyIter): + message_iterator_class=MyIter): def __init__(comp_self, params): nonlocal port1, port2, port3 port1 = comp_self._add_output_port('clear') @@ -650,7 +650,7 @@ class PortTestCase(unittest.TestCase): del port3 def test_gen_flt_input_ports_iter(self): - class MyIter(bt2._UserNotificationIterator): + class MyIter(bt2._UserMessageIterator): def __next__(self): raise bt2.Stop @@ -659,7 +659,7 @@ class PortTestCase(unittest.TestCase): port3 = None class MyFilter(bt2._UserFilterComponent, - notification_iterator_class=MyIter): + message_iterator_class=MyIter): def __init__(comp_self, params): nonlocal port1, port2, port3 port1 = comp_self._add_input_port('clear') diff --git a/tests/bindings/python/bt2/test_trace_collection_notification_iterator.py b/tests/bindings/python/bt2/test_trace_collection_message_iterator.py similarity index 60% rename from tests/bindings/python/bt2/test_trace_collection_notification_iterator.py rename to tests/bindings/python/bt2/test_trace_collection_message_iterator.py index 787336ad..12492740 100644 --- a/tests/bindings/python/bt2/test_trace_collection_notification_iterator.py +++ b/tests/bindings/python/bt2/test_trace_collection_message_iterator.py @@ -39,107 +39,107 @@ class ComponentSpecTestCase(unittest.TestCase): @unittest.skip("this is broken") -class TraceCollectionNotificationIteratorTestCase(unittest.TestCase): +class TraceCollectionMessageIteratorTestCase(unittest.TestCase): def test_create_wrong_stream_intersection_mode_type(self): specs = [bt2.ComponentSpec('ctf', 'fs', _3EVENTS_INTERSECT_TRACE_PATH)] with self.assertRaises(TypeError): - notif_iter = bt2.TraceCollectionNotificationIterator(specs, stream_intersection_mode=23) + msg_iter = bt2.TraceCollectionMessageIterator(specs, stream_intersection_mode=23) def test_create_wrong_begin_type(self): specs = [bt2.ComponentSpec('ctf', 'fs', _3EVENTS_INTERSECT_TRACE_PATH)] with self.assertRaises(TypeError): - notif_iter = bt2.TraceCollectionNotificationIterator(specs, begin='hi') + msg_iter = bt2.TraceCollectionMessageIterator(specs, begin='hi') def test_create_wrong_end_type(self): specs = [bt2.ComponentSpec('ctf', 'fs', _3EVENTS_INTERSECT_TRACE_PATH)] with self.assertRaises(TypeError): - notif_iter = bt2.TraceCollectionNotificationIterator(specs, begin='lel') + msg_iter = bt2.TraceCollectionMessageIterator(specs, begin='lel') def test_create_no_such_plugin(self): specs = [bt2.ComponentSpec('77', '101', _3EVENTS_INTERSECT_TRACE_PATH)] with self.assertRaises(bt2.Error): - notif_iter = bt2.TraceCollectionNotificationIterator(specs) + msg_iter = bt2.TraceCollectionMessageIterator(specs) def test_create_begin_s(self): specs = [bt2.ComponentSpec('ctf', 'fs', _3EVENTS_INTERSECT_TRACE_PATH)] - notif_iter = bt2.TraceCollectionNotificationIterator(specs, begin=19457.918232) + msg_iter = bt2.TraceCollectionMessageIterator(specs, begin=19457.918232) def test_create_end_s(self): specs = [bt2.ComponentSpec('ctf', 'fs', _3EVENTS_INTERSECT_TRACE_PATH)] - notif_iter = bt2.TraceCollectionNotificationIterator(specs, end=123.12312) + msg_iter = bt2.TraceCollectionMessageIterator(specs, end=123.12312) def test_create_begin_datetime(self): specs = [bt2.ComponentSpec('ctf', 'fs', _3EVENTS_INTERSECT_TRACE_PATH)] - notif_iter = bt2.TraceCollectionNotificationIterator(specs, begin=datetime.datetime.now()) + msg_iter = bt2.TraceCollectionMessageIterator(specs, begin=datetime.datetime.now()) def test_create_end_datetime(self): specs = [bt2.ComponentSpec('ctf', 'fs', _3EVENTS_INTERSECT_TRACE_PATH)] - notif_iter = bt2.TraceCollectionNotificationIterator(specs, end=datetime.datetime.now()) + msg_iter = bt2.TraceCollectionMessageIterator(specs, end=datetime.datetime.now()) def test_iter_no_intersection(self): specs = [bt2.ComponentSpec('ctf', 'fs', _3EVENTS_INTERSECT_TRACE_PATH)] - notif_iter = bt2.TraceCollectionNotificationIterator(specs) - self.assertEqual(len(list(notif_iter)), 28) + msg_iter = bt2.TraceCollectionMessageIterator(specs) + self.assertEqual(len(list(msg_iter)), 28) def test_iter_no_intersection_subscribe(self): specs = [bt2.ComponentSpec('ctf', 'fs', _3EVENTS_INTERSECT_TRACE_PATH)] - notif_iter = bt2.TraceCollectionNotificationIterator(specs, - notification_types=[bt2.EventNotification]) - self.assertEqual(len(list(notif_iter)), 8) + msg_iter = bt2.TraceCollectionMessageIterator(specs, + message_types=[bt2.EventMessage]) + self.assertEqual(len(list(msg_iter)), 8) def test_iter_specs_not_list(self): spec = bt2.ComponentSpec('ctf', 'fs', _3EVENTS_INTERSECT_TRACE_PATH) - notif_iter = bt2.TraceCollectionNotificationIterator(spec, - notification_types=[bt2.EventNotification]) - self.assertEqual(len(list(notif_iter)), 8) + msg_iter = bt2.TraceCollectionMessageIterator(spec, + message_types=[bt2.EventMessage]) + self.assertEqual(len(list(msg_iter)), 8) def test_iter_custom_filter(self): src_spec = bt2.ComponentSpec('ctf', 'fs', _3EVENTS_INTERSECT_TRACE_PATH) flt_spec = bt2.ComponentSpec('utils', 'trimmer', { 'end': 13515309000000075, }) - notif_iter = bt2.TraceCollectionNotificationIterator(src_spec, flt_spec, - notification_types=[bt2.EventNotification]) - self.assertEqual(len(list(notif_iter)), 5) + msg_iter = bt2.TraceCollectionMessageIterator(src_spec, flt_spec, + message_types=[bt2.EventMessage]) + self.assertEqual(len(list(msg_iter)), 5) def test_iter_intersection(self): specs = [bt2.ComponentSpec('ctf', 'fs', _3EVENTS_INTERSECT_TRACE_PATH)] - notif_iter = bt2.TraceCollectionNotificationIterator(specs, stream_intersection_mode=True) - self.assertEqual(len(list(notif_iter)), 15) + msg_iter = bt2.TraceCollectionMessageIterator(specs, stream_intersection_mode=True) + self.assertEqual(len(list(msg_iter)), 15) def test_iter_intersection_subscribe(self): specs = [bt2.ComponentSpec('ctf', 'fs', _3EVENTS_INTERSECT_TRACE_PATH)] - notif_iter = bt2.TraceCollectionNotificationIterator(specs, stream_intersection_mode=True, - notification_types=[bt2.EventNotification]) - self.assertEqual(len(list(notif_iter)), 3) + msg_iter = bt2.TraceCollectionMessageIterator(specs, stream_intersection_mode=True, + message_types=[bt2.EventMessage]) + self.assertEqual(len(list(msg_iter)), 3) def test_iter_intersection_no_path_param(self): specs = [bt2.ComponentSpec('text', 'dmesg', {'read-from-stdin': True})] with self.assertRaises(bt2.Error): - notif_iter = bt2.TraceCollectionNotificationIterator(specs, stream_intersection_mode=True, - notification_types=[bt2.EventNotification]) + msg_iter = bt2.TraceCollectionMessageIterator(specs, stream_intersection_mode=True, + message_types=[bt2.EventMessage]) def test_iter_no_intersection_two_traces(self): spec = bt2.ComponentSpec('ctf', 'fs', _3EVENTS_INTERSECT_TRACE_PATH) specs = [spec, spec] - notif_iter = bt2.TraceCollectionNotificationIterator(specs) - self.assertEqual(len(list(notif_iter)), 56) + msg_iter = bt2.TraceCollectionMessageIterator(specs) + self.assertEqual(len(list(msg_iter)), 56) def test_iter_no_intersection_begin(self): specs = [bt2.ComponentSpec('ctf', 'fs', _3EVENTS_INTERSECT_TRACE_PATH)] - notif_iter = bt2.TraceCollectionNotificationIterator(specs, - notification_types=[bt2.EventNotification], + msg_iter = bt2.TraceCollectionMessageIterator(specs, + message_types=[bt2.EventMessage], begin=13515309.000000023) - self.assertEqual(len(list(notif_iter)), 6) + self.assertEqual(len(list(msg_iter)), 6) def test_iter_no_intersection_end(self): specs = [bt2.ComponentSpec('ctf', 'fs', _3EVENTS_INTERSECT_TRACE_PATH)] - notif_iter = bt2.TraceCollectionNotificationIterator(specs, - notification_types=[bt2.EventNotification], + msg_iter = bt2.TraceCollectionMessageIterator(specs, + message_types=[bt2.EventMessage], end=13515309.000000075) - self.assertEqual(len(list(notif_iter)), 5) + self.assertEqual(len(list(msg_iter)), 5) -- 2.34.1