Freeze event classes as they are added to a stream class
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 13 Mar 2015 05:06:03 +0000 (01:06 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 13 Mar 2015 05:17:44 +0000 (01:17 -0400)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
formats/ctf/ir/stream-class.c
include/babeltrace/ctf-ir/stream-class.h
tests/lib/test_ctf_writer.c

index 116befab0b6e3444bdfe925415ece33e4fe54296..b1941415f9295981a2fb43e8ed0704cd7addbef3 100644 (file)
@@ -246,6 +246,7 @@ int bt_ctf_stream_class_add_event_class(
 
        bt_ctf_event_class_get(event_class);
        g_ptr_array_add(stream_class->event_classes, event_class);
+       bt_ctf_event_class_freeze(event_class);
 end:
        return ret;
 }
index d7089ccb938254c4ebe5a771776ccb47ff72d255..bf5f577c3c99140b21f43c694bc13aae3830b91f 100644 (file)
@@ -144,7 +144,8 @@ extern int bt_ctf_stream_class_set_id(
  * The stream class will share the ownership of "event_class" by incrementing
  * its reference count.
  *
- * Note that an event class may only be added to one stream class.
+ * Note that an event class may only be added to one stream class. It
+ * also becomes immutable.
  *
  * @param stream_class Stream class.
  * @param event_class Event class to add to the provided stream class.
index b22daaec1c75259ac083aa31d661273fb2468699..3a56a558d44102ec94e6f90198ecfe3b20e5c73b 100644 (file)
@@ -454,8 +454,28 @@ void append_simple_event(struct bt_ctf_stream_class *stream_class,
                "integer_field");
        bt_ctf_event_class_add_field(simple_event_class, float_type,
                "float_field");
-       bt_ctf_stream_class_add_event_class(stream_class,
-               simple_event_class);
+
+       /* Set an event context type which will contain a single integer*/
+       ok(!bt_ctf_field_type_structure_add_field(event_context_type, uint_12_type,
+               "event_specific_context"),
+               "Add event specific context field");
+       ok(bt_ctf_event_class_get_context_type(NULL) == NULL,
+               "bt_ctf_event_class_get_context_type handles NULL correctly");
+       ok(bt_ctf_event_class_get_context_type(simple_event_class) == NULL,
+               "bt_ctf_event_class_get_context_type returns NULL when no event context type is set");
+
+       ok(bt_ctf_event_class_set_context_type(simple_event_class, NULL) < 0,
+               "bt_ctf_event_class_set_context_type handles a NULL context type correctly");
+       ok(bt_ctf_event_class_set_context_type(NULL, event_context_type) < 0,
+               "bt_ctf_event_class_set_context_type handles a NULL event class correctly");
+       ok(!bt_ctf_event_class_set_context_type(simple_event_class, event_context_type),
+               "Set an event class' context type successfully");
+       returned_type = bt_ctf_event_class_get_context_type(simple_event_class);
+       ok(returned_type == event_context_type,
+               "bt_ctf_event_class_get_context_type returns the appropriate type");
+       bt_ctf_field_type_put(returned_type);
+
+       bt_ctf_stream_class_add_event_class(stream_class, simple_event_class);
 
        ok(bt_ctf_stream_class_get_event_class_count(NULL) < 0,
                "bt_ctf_stream_class_get_event_class_count handles NULL correctly");
@@ -481,25 +501,6 @@ void append_simple_event(struct bt_ctf_stream_class *stream_class,
                "bt_ctf_stream_class_get_event_class_by_name returns a correct event class");
        bt_ctf_event_class_put(ret_event_class);
 
-       /* Set an event context type which will contain a single integer*/
-       ok(!bt_ctf_field_type_structure_add_field(event_context_type, uint_12_type,
-               "event_specific_context"),
-               "Add event specific context field");
-       ok(bt_ctf_event_class_get_context_type(NULL) == NULL,
-               "bt_ctf_event_class_get_context_type handles NULL correctly");
-       ok(bt_ctf_event_class_get_context_type(simple_event_class) == NULL,
-               "bt_ctf_event_class_get_context_type returns NULL when no event context type is set");
-       ok(bt_ctf_event_class_set_context_type(simple_event_class, NULL) < 0,
-               "bt_ctf_event_class_set_context_type handles a NULL context type correctly");
-       ok(bt_ctf_event_class_set_context_type(NULL, event_context_type) < 0,
-               "bt_ctf_event_class_set_context_type handles a NULL event class correctly");
-       ok(!bt_ctf_event_class_set_context_type(simple_event_class, event_context_type),
-               "Set an event class' context type successfully");
-       returned_type = bt_ctf_event_class_get_context_type(simple_event_class);
-       ok(returned_type == event_context_type,
-               "bt_ctf_event_class_get_context_type returns the appropriate type");
-       bt_ctf_field_type_put(returned_type);
-
        simple_event = bt_ctf_event_create(simple_event_class);
        ok(simple_event,
                "Instantiate an event containing a single integer field");
This page took 0.02892 seconds and 4 git commands to generate.