Make bt_ctf_event_class_create() create an empty context FT
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Tue, 2 May 2017 19:19:34 +0000 (15:19 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Sun, 28 May 2017 16:57:42 +0000 (12:57 -0400)
This is in line with bt_ctf_trace_create() and
bt_ctf_stream_class_create_empty(). You can get the empty context FT
with bt_ctf_event_class_get_context_type() after creation and add fields
to it.

Update tests accordingly.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
include/babeltrace/ctf-ir/event-class.h
lib/ctf-ir/event-class.c
tests/lib/test_ctf_writer.c

index 5052f70fa551452ef09e745cf222b7f6e583e963..fec7aa875a6e29b8227a0153ea83bcd03ed2bada 100644 (file)
@@ -121,9 +121,11 @@ struct bt_ctf_stream_class;
 /**
 @brief Creates a default CTF IR event class named \p name­.
 
-The event class is created \em without an event context
-\link ctfirfieldtypes field type\endlink and with an empty event
-payload field type.
+On success, the context and payload field types are empty structure
+field types. You can modify those default field types after the
+event class is created with
+bt_ctf_event_class_set_context_type() and
+bt_ctf_event_class_set_payload_type().
 
 Upon creation, the event class's ID is <em>not set</em>. You
 can set it to a specific value with bt_ctf_event_class_set_id(). If it
index e37331f091ed5bcbf6987d781fbfbf7f738e3fb0..8dc4619de4a338d924b486c3907d284bb9f7e4a5 100644 (file)
@@ -66,6 +66,11 @@ struct bt_ctf_event_class *bt_ctf_event_class_create(const char *name)
                goto error;
        }
 
+       event_class->context = bt_ctf_field_type_structure_create();
+       if (!event_class->context) {
+               goto error;
+       }
+
        event_class->attributes = bt_ctf_attributes_create();
        if (!event_class->attributes) {
                goto error;
index 0d2b5839731bc8e344504463152ced49e15b64c9..80e49ca47a2f665ab685c1af64a91aa6cf4a39e7 100644 (file)
@@ -61,7 +61,7 @@
 #define DEFAULT_CLOCK_TIME 0
 #define DEFAULT_CLOCK_VALUE 0
 
-#define NR_TESTS 614
+#define NR_TESTS 612
 
 static int64_t current_time = 42;
 
@@ -371,8 +371,6 @@ void append_simple_event(struct bt_ctf_stream_class *stream_class,
                "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(NULL, event_context_type) < 0,
                "bt_ctf_event_class_set_context_type handles a NULL event class correctly");
@@ -3313,9 +3311,6 @@ int main(int argc, char **argv)
        /* Define a stream event context containing a my_integer field. */
        ok(bt_ctf_stream_class_get_event_context_type(NULL) == NULL,
                "bt_ctf_stream_class_get_event_context_type handles NULL correctly");
-       ok(bt_ctf_stream_class_get_event_context_type(
-               stream_class) == NULL,
-               "bt_ctf_stream_class_get_event_context_type returns NULL when no stream event context type was set.");
        stream_event_context_type = bt_ctf_field_type_structure_create();
        bt_ctf_field_type_structure_add_field(stream_event_context_type,
                integer_type, "common_event_context");
This page took 0.030659 seconds and 4 git commands to generate.