+ BT_ASSERT_POST_DEV(NEXT_METHOD_NAME,
+ "message-packet-is-expected",
+ actual_packet == expected_packet,
+ "Message's packet is not expected: %![stream-]s, %![iterator-]i, "
+ "%![message-]n, %![received-packet-]a, %![expected-packet-]a",
+ stream, iterator, msg, actual_packet, expected_packet);
+
+end:
+ return;
+}
+
+static
+void assert_post_dev_next(
+ struct bt_message_iterator *iterator,
+ bt_message_iterator_class_next_method_status status,
+ bt_message_array_const msgs, uint64_t msg_count)
+{
+ if (status == BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK) {
+ uint64_t i;
+
+ for (i = 0; i < msg_count; i++) {
+ assert_post_dev_expected_sequence(iterator, msgs[i]);
+ assert_post_dev_expected_packet(iterator, msgs[i]);
+ }
+ } else if (status == BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_END) {
+ GHashTableIter iter;
+
+ gpointer stream_v, stream_state_v;
+
+ g_hash_table_iter_init(&iter, iterator->per_stream_state);
+ while (g_hash_table_iter_next(&iter, &stream_v,
+ &stream_state_v)) {
+ struct bt_stream *stream = stream_v;
+ struct per_stream_state *stream_state = stream_state_v;
+
+ BT_ASSERT_POST_DEV(NEXT_METHOD_NAME,
+ "stream-is-ended",
+ stream_state->expected_msg_types == 0,
+ "Stream is not ended: %![stream-]s, "
+ "%![iterator-]i, expected-msg-types=%s",
+ stream, iterator,
+ message_types_to_string(
+ stream_state->expected_msg_types)->str);
+ }
+
+ }
+}
+#endif
+
+/*
+ * Call the `next` method of the iterator. Do some validation on the returned
+ * messages.
+ */
+
+static
+enum bt_message_iterator_class_next_method_status
+call_iterator_next_method(
+ struct bt_message_iterator *iterator,
+ bt_message_array_const msgs, uint64_t capacity, uint64_t *user_count)
+{
+ enum bt_message_iterator_class_next_method_status status;
+
+ BT_ASSERT_DBG(iterator->methods.next);
+ BT_LOGD_STR("Calling user's \"next\" method.");
+ status = iterator->methods.next(iterator, msgs, capacity, user_count);
+ BT_LOGD("User method returned: status=%s, msg-count=%" PRIu64,
+ bt_common_func_status_string(status), *user_count);
+
+ if (status == BT_FUNC_STATUS_OK) {
+ BT_ASSERT_POST_DEV(NEXT_METHOD_NAME,
+ "message-clock-classes-are-compatible",
+ clock_classes_are_compatible(iterator, msgs,
+ *user_count),
+ "Clocks are not compatible");
+ BT_ASSERT_POST_DEV(NEXT_METHOD_NAME,
+ "message-clock-snapshots-are-monotonic",
+ clock_snapshots_are_monotonic(iterator, msgs,
+ *user_count),
+ "Clock snapshots are not monotonic");
+ }
+
+#ifdef BT_DEV_MODE
+ assert_post_dev_next(iterator, status, msgs, *user_count);
+#endif
+
+ BT_ASSERT_POST_DEV_NO_ERROR_IF_NO_ERROR_STATUS(NEXT_METHOD_NAME,
+ status);
+
+ return status;
+}
+
+BT_EXPORT
+enum bt_message_iterator_next_status
+bt_message_iterator_next(
+ struct bt_message_iterator *iterator,
+ bt_message_array_const *msgs, uint64_t *user_count)
+{
+ enum bt_message_iterator_next_status status = BT_FUNC_STATUS_OK;
+
+ BT_ASSERT_PRE_DEV_NO_ERROR();
+ BT_ASSERT_PRE_DEV_MSG_ITER_NON_NULL(iterator);
+ BT_ASSERT_PRE_DEV_NON_NULL("message-array-output", msgs,
+ "Message array (output)");
+ BT_ASSERT_PRE_DEV_NON_NULL("user-count-output", user_count,
+ "Message count (output)");
+ BT_ASSERT_PRE_DEV("message-iterator-is-active",
+ iterator->state == BT_MESSAGE_ITERATOR_STATE_ACTIVE,
+ "Message iterator's \"next\" called, but "
+ "message iterator is in the wrong state: %!+i", iterator);
+ BT_ASSERT_DBG(iterator->upstream_component);
+ BT_ASSERT_DBG(iterator->upstream_component->class);
+ BT_ASSERT_PRE_DEV("graph-is-configured",
+ bt_component_borrow_graph(iterator->upstream_component)->config_state !=
+ BT_GRAPH_CONFIGURATION_STATE_CONFIGURING,
+ "Graph is not configured: %!+g",
+ bt_component_borrow_graph(iterator->upstream_component));
+ BT_LIB_LOGD("Getting next self component input port "
+ "message iterator's messages: %!+i, batch-size=%u",
+ iterator, MSG_BATCH_SIZE);
+