ir: move the stream event ctx field to the event
[babeltrace.git] / tests / lib / test_ctf_writer.c
index 8d8ffa915826313c5de2930009047e5770771254..1e7393a34a660aa281e870b0bfbd8f8ae0cbee75 100644 (file)
@@ -58,7 +58,7 @@
 #define DEFAULT_CLOCK_TIME 0
 #define DEFAULT_CLOCK_VALUE 0
 
-#define NR_TESTS 597
+#define NR_TESTS 591
 
 static int64_t current_time = 42;
 
@@ -695,7 +695,9 @@ void append_simple_event(struct bt_ctf_stream_class *stream_class,
        ok(bt_ctf_clock_set_time(clock, current_time) == 0, "Set clock time");
 
        /* Populate stream event context */
-       stream_event_context = bt_ctf_stream_get_event_context(stream);
+       stream_event_context =
+               bt_ctf_event_get_stream_event_context(simple_event);
+       assert(stream_event_context);
        stream_event_context_field = bt_ctf_field_structure_get_field(
                stream_event_context, "common_event_context");
        bt_ctf_field_unsigned_integer_set_value(stream_event_context_field, 42);
@@ -825,7 +827,8 @@ void append_complex_event(struct bt_ctf_stream_class *stream_class,
        struct bt_ctf_field *uint_35_field, *int_16_field, *a_string_field,
                *inner_structure_field, *complex_structure_field,
                *a_sequence_field, *enum_variant_field, *enum_container_field,
-               *variant_field, *an_array_field, *ret_field;
+               *variant_field, *an_array_field, *stream_event_ctx_field,
+               *stream_event_ctx_int_field, *ret_field;
        uint64_t ret_unsigned_int;
        int64_t ret_signed_int;
        const char *ret_string;
@@ -1307,6 +1310,14 @@ void append_complex_event(struct bt_ctf_stream_class *stream_class,
                bt_put(int_16_field);
        }
 
+       stream_event_ctx_field = bt_ctf_event_get_stream_event_context(event);
+       assert(stream_event_ctx_field);
+       stream_event_ctx_int_field = bt_ctf_field_structure_get_field(
+               stream_event_ctx_field, "common_event_context");
+       BT_PUT(stream_event_ctx_field);
+       bt_ctf_field_unsigned_integer_set_value(stream_event_ctx_int_field, 17);
+       BT_PUT(stream_event_ctx_int_field);
+
        bt_ctf_clock_set_time(clock, ++current_time);
        ok(bt_ctf_stream_append_event(stream, event) == 0,
                "Append a complex event to a stream");
@@ -2181,7 +2192,7 @@ void packet_resize_test(struct bt_ctf_stream_class *stream_class,
        uint64_t ret_uint64;
        int events_appended = 0;
        struct bt_ctf_field *packet_context = NULL,
-               *packet_context_field = NULL, *event_context = NULL;
+               *packet_context_field = NULL, *stream_event_context = NULL;
        struct bt_ctf_field_type *ep_field_1_type = NULL;
        struct bt_ctf_field_type *ep_a_string_type = NULL;
        struct bt_ctf_field_type *ep_type = NULL;
@@ -2224,22 +2235,6 @@ void packet_resize_test(struct bt_ctf_stream_class *stream_class,
                "bt_ctf_event_get_payload_by_index handles an invalid index correctly");
        bt_put(event);
 
-       ok(bt_ctf_stream_get_event_context(NULL) == NULL,
-               "bt_ctf_stream_get_event_context handles NULL correctly");
-       event_context = bt_ctf_stream_get_event_context(stream);
-       ok(event_context,
-               "bt_ctf_stream_get_event_context returns a stream event context");
-       ok(bt_ctf_stream_set_event_context(NULL, event_context) < 0,
-               "bt_ctf_stream_set_event_context handles a NULL stream correctly");
-       ok(bt_ctf_stream_set_event_context(stream, NULL) < 0,
-               "bt_ctf_stream_set_event_context handles a NULL stream event context correctly");
-       ok(!bt_ctf_stream_set_event_context(stream, event_context),
-               "bt_ctf_stream_set_event_context correctly set a stream event context");
-       ret_field = bt_ctf_field_create(ep_field_1_type);
-       ok(bt_ctf_stream_set_event_context(stream, ret_field) < 0,
-               "bt_ctf_stream_set_event_context rejects an event context of incorrect type");
-       bt_put(ret_field);
-
        for (i = 0; i < PACKET_RESIZE_TEST_LENGTH; i++) {
                event = bt_ctf_event_create(event_class);
                struct bt_ctf_field *integer =
@@ -2258,8 +2253,11 @@ void packet_resize_test(struct bt_ctf_stream_class *stream_class,
                bt_put(string);
 
                /* Populate stream event context */
-               integer = bt_ctf_field_structure_get_field(event_context,
+               stream_event_context =
+                       bt_ctf_event_get_stream_event_context(event);
+               integer = bt_ctf_field_structure_get_field(stream_event_context,
                        "common_event_context");
+               BT_PUT(stream_event_context);
                ret |= bt_ctf_field_unsigned_integer_set_value(integer,
                        i % 42);
                bt_put(integer);
@@ -2306,7 +2304,7 @@ end:
        bt_put(string_type);
        bt_put(packet_context);
        bt_put(packet_context_field);
-       bt_put(event_context);
+       bt_put(stream_event_context);
        bt_put(event_class);
        bt_put(ep_field_1_type);
        bt_put(ep_a_string_type);
This page took 0.025068 seconds and 4 git commands to generate.