tap-driver.sh: flush stdout after each test result
[babeltrace.git] / plugins / utils / trimmer / trimmer.c
index 4d52e22e08b394d09fe14b615583d757b38cfc93..1227dc50d7616384e01f5789d2bf4c311cbd8310 100644 (file)
 #define BT_LOG_TAG "PLUGIN-UTILS-TRIMMER-FLT"
 #include "logging.h"
 
-#include <babeltrace/compat/utc-internal.h>
-#include <babeltrace/compat/time-internal.h>
-#include <babeltrace/babeltrace.h>
-#include <babeltrace/common-internal.h>
+#include <babeltrace2/compat/utc-internal.h>
+#include <babeltrace2/compat/time-internal.h>
+#include <babeltrace2/babeltrace.h>
+#include <babeltrace2/common-internal.h>
 #include <plugins-common.h>
-#include <babeltrace/assert-internal.h>
+#include <babeltrace2/assert-internal.h>
 #include <stdint.h>
 #include <inttypes.h>
 #include <glib.h>
@@ -669,7 +669,7 @@ int get_msg_ns_from_origin(const bt_message *msg, int64_t *ns_from_origin,
                        goto error;
                }
 
-               clock_snapshot = bt_message_discarded_events_borrow_default_beginning_clock_snapshot_const(
+               clock_snapshot = bt_message_discarded_events_borrow_beginning_default_clock_snapshot_const(
                        msg);
                break;
        case BT_MESSAGE_TYPE_DISCARDED_PACKETS:
@@ -680,7 +680,7 @@ int get_msg_ns_from_origin(const bt_message *msg, int64_t *ns_from_origin,
                        goto error;
                }
 
-               clock_snapshot = bt_message_discarded_packets_borrow_default_beginning_clock_snapshot_const(
+               clock_snapshot = bt_message_discarded_packets_borrow_beginning_default_clock_snapshot_const(
                        msg);
                break;
        case BT_MESSAGE_TYPE_STREAM_ACTIVITY_BEGINNING:
@@ -1424,7 +1424,7 @@ bt_self_message_iterator_status handle_message_with_stream_state(
                         * know there's a default clock and it's always
                         * known.
                         */
-                       end_cs = bt_message_discarded_events_borrow_default_end_clock_snapshot_const(
+                       end_cs = bt_message_discarded_events_borrow_end_default_clock_snapshot_const(
                                msg);
                } else {
                        /*
@@ -1432,7 +1432,7 @@ bt_self_message_iterator_status handle_message_with_stream_state(
                         * know there's a default clock and it's always
                         * known.
                         */
-                       end_cs = bt_message_discarded_packets_borrow_default_end_clock_snapshot_const(
+                       end_cs = bt_message_discarded_packets_borrow_end_default_clock_snapshot_const(
                                msg);
                }
 
@@ -1475,7 +1475,7 @@ bt_self_message_iterator_status handle_message_with_stream_state(
                        }
 
                        if (msg_type == BT_MESSAGE_TYPE_DISCARDED_EVENTS) {
-                               begin_cs = bt_message_discarded_events_borrow_default_beginning_clock_snapshot_const(
+                               begin_cs = bt_message_discarded_events_borrow_beginning_default_clock_snapshot_const(
                                        msg);
                                new_msg = bt_message_discarded_events_create_with_default_clock_snapshots(
                                        trimmer_it->self_msg_iter,
@@ -1483,7 +1483,7 @@ bt_self_message_iterator_status handle_message_with_stream_state(
                                        bt_clock_snapshot_get_value(begin_cs),
                                        end_raw_value);
                        } else {
-                               begin_cs = bt_message_discarded_packets_borrow_default_beginning_clock_snapshot_const(
+                               begin_cs = bt_message_discarded_packets_borrow_beginning_default_clock_snapshot_const(
                                        msg);
                                new_msg = bt_message_discarded_packets_create_with_default_clock_snapshots(
                                        trimmer_it->self_msg_iter,
@@ -1733,6 +1733,65 @@ bt_self_message_iterator_status handle_message(
                                goto end;
                        }
 
+                       /*
+                        * Temporary: make sure packet beginning, packet
+                        * end, discarded events, and discarded packets
+                        * messages have default clock snapshots until
+                        * the support for not having them is
+                        * implemented.
+                        */
+                       if (!bt_stream_class_packets_have_beginning_default_clock_snapshot(
+                                       sc)) {
+                               BT_LOGE("Unsupported stream: packets have "
+                                       "no beginning clock snapshot: "
+                                       "stream-addr=%p, "
+                                       "stream-id=%" PRIu64 ", "
+                                       "stream-name=\"%s\"",
+                                       stream, bt_stream_get_id(stream),
+                                       bt_stream_get_name(stream));
+                               status = BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR;
+                               goto end;
+                       }
+
+                       if (!bt_stream_class_packets_have_end_default_clock_snapshot(
+                                       sc)) {
+                               BT_LOGE("Unsupported stream: packets have "
+                                       "no end clock snapshot: "
+                                       "stream-addr=%p, "
+                                       "stream-id=%" PRIu64 ", "
+                                       "stream-name=\"%s\"",
+                                       stream, bt_stream_get_id(stream),
+                                       bt_stream_get_name(stream));
+                               status = BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR;
+                               goto end;
+                       }
+
+                       if (bt_stream_class_supports_discarded_events(sc) &&
+                                       !bt_stream_class_discarded_events_have_default_clock_snapshots(sc)) {
+                               BT_LOGE("Unsupported stream: discarded events "
+                                       "have no clock snapshots: "
+                                       "stream-addr=%p, "
+                                       "stream-id=%" PRIu64 ", "
+                                       "stream-name=\"%s\"",
+                                       stream, bt_stream_get_id(stream),
+                                       bt_stream_get_name(stream));
+                               status = BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR;
+                               goto end;
+                       }
+
+                       if (bt_stream_class_supports_discarded_packets(sc) &&
+                                       !bt_stream_class_discarded_packets_have_default_clock_snapshots(sc)) {
+                               BT_LOGE("Unsupported stream: discarded packets "
+                                       "have no clock snapshots: "
+                                       "stream-addr=%p, "
+                                       "stream-id=%" PRIu64 ", "
+                                       "stream-name=\"%s\"",
+                                       stream, bt_stream_get_id(stream),
+                                       bt_stream_get_name(stream));
+                               status = BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR;
+                               goto end;
+                       }
+
                        sstate = g_new0(struct trimmer_iterator_stream_state,
                                1);
                        if (!sstate) {
This page took 0.04002 seconds and 4 git commands to generate.