* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+#include <stdio.h>
#include "tap/tap.h"
-#include <babeltrace/babeltrace.h>
-#include <babeltrace/object-internal.h>
-#include <babeltrace/compat/stdlib-internal.h>
-#include <babeltrace/assert-internal.h>
+#include <babeltrace2/babeltrace.h>
+#include "lib/object.h"
+#include "compat/stdlib.h"
+#include "common/assert.h"
+#include <babeltrace2/ctf-writer/writer.h>
+#include <babeltrace2/ctf-writer/clock.h>
+#include <babeltrace2/ctf-writer/clock-class.h>
+#include <babeltrace2/ctf-writer/stream.h>
+#include <babeltrace2/ctf-writer/event.h>
+#include <babeltrace2/ctf-writer/event-types.h>
+#include <babeltrace2/ctf-writer/event-fields.h>
+#include <babeltrace2/ctf-writer/stream-class.h>
+#include <babeltrace2/ctf-writer/trace.h>
#include "common.h"
#define NR_TESTS 37
* - uint16_t payload_16;
* - uint32_t payload_32;
*/
-static bt_field_class *create_integer_struct(void)
+static bt_field_class *create_integer_struct(bt_trace_class *trace_class)
{
int ret;
bt_field_class *structure = NULL;
bt_field_class *ui8 = NULL, *ui16 = NULL, *ui32 = NULL;
- structure = bt_field_class_structure_create();
+ structure = bt_field_class_structure_create(trace_class);
BT_ASSERT(structure);
- ui8 = bt_field_class_unsigned_integer_create();
+ ui8 = bt_field_class_unsigned_integer_create(trace_class);
BT_ASSERT(ui8);
bt_field_class_integer_set_field_value_range(ui8, 8);
ret = bt_field_class_structure_append_member(structure,
"payload_8", ui8);
BT_ASSERT(ret == 0);
- ui16 = bt_field_class_unsigned_integer_create();
+ ui16 = bt_field_class_unsigned_integer_create(trace_class);
BT_ASSERT(ui16);
bt_field_class_integer_set_field_value_range(ui16, 16);
ret = bt_field_class_structure_append_member(structure,
"payload_16", ui16);
BT_ASSERT(ret == 0);
- ui32 = bt_field_class_unsigned_integer_create();
+ ui32 = bt_field_class_unsigned_integer_create(trace_class);
BT_ASSERT(ui32);
bt_field_class_integer_set_field_value_range(ui32, 32);
ret = bt_field_class_structure_append_member(structure,
BT_ASSERT(event);
ret = bt_event_class_set_name(event, name);
BT_ASSERT(ret == 0);
- payload = create_integer_struct();
+ payload = create_integer_struct(bt_stream_class_borrow_trace_class(sc));
BT_ASSERT(payload);
ret = bt_event_class_set_payload_field_class(event, payload);
BT_ASSERT(ret == 0);
* - uint16_t payload_16;
* - uint32_t payload_32;
*/
-static bt_event_class *create_complex_event(
- bt_stream_class *sc,
+static bt_event_class *create_complex_event(bt_stream_class *sc,
const char *name)
{
int ret;
bt_event_class *event = NULL;
bt_field_class *inner = NULL, *outer = NULL;
+ bt_trace_class *trace_class = bt_stream_class_borrow_trace_class(sc);
BT_ASSERT(name);
event = bt_event_class_create(sc);
BT_ASSERT(event);
ret = bt_event_class_set_name(event, name);
BT_ASSERT(ret == 0);
- outer = create_integer_struct();
+ outer = create_integer_struct(trace_class);
BT_ASSERT(outer);
- inner = create_integer_struct();
+ inner = create_integer_struct(trace_class);
BT_ASSERT(inner);
ret = bt_field_class_structure_append_member(outer,
"payload_struct", inner);
static void set_stream_class_field_classes(
bt_stream_class *stream_class)
{
+ bt_trace_class *trace_class =
+ bt_stream_class_borrow_trace_class(stream_class);
bt_field_class *packet_context_type;
- bt_field_class *event_header_type;
bt_field_class *fc;
int ret;
- packet_context_type = bt_field_class_structure_create();
+ packet_context_type = bt_field_class_structure_create(trace_class);
BT_ASSERT(packet_context_type);
- fc = bt_field_class_unsigned_integer_create();
+ fc = bt_field_class_unsigned_integer_create(trace_class);
BT_ASSERT(fc);
bt_field_class_integer_set_field_value_range(fc, 32);
ret = bt_field_class_structure_append_member(packet_context_type,
"packet_size", fc);
BT_ASSERT(ret == 0);
bt_field_class_put_ref(fc);
- fc = bt_field_class_unsigned_integer_create();
+ fc = bt_field_class_unsigned_integer_create(trace_class);
BT_ASSERT(fc);
bt_field_class_integer_set_field_value_range(fc, 32);
ret = bt_field_class_structure_append_member(packet_context_type,
"content_size", fc);
BT_ASSERT(ret == 0);
bt_field_class_put_ref(fc);
- event_header_type = bt_field_class_structure_create();
- BT_ASSERT(event_header_type);
- fc = bt_field_class_unsigned_integer_create();
- BT_ASSERT(fc);
- bt_field_class_integer_set_field_value_range(fc, 32);
- ret = bt_field_class_structure_append_member(event_header_type,
- "id", fc);
- BT_ASSERT(ret == 0);
- bt_field_class_put_ref(fc);
ret = bt_stream_class_set_packet_context_field_class(
stream_class, packet_context_type);
BT_ASSERT(ret == 0);
- ret = bt_stream_class_set_event_header_field_class(
- stream_class, event_header_type);
- BT_ASSERT(ret == 0);
bt_field_class_put_ref(packet_context_type);
- bt_field_class_put_ref(event_header_type);
}
static void create_sc1(bt_trace_class *trace_class)
BT_STREAM_CLASS_PUT_REF_AND_RESET(sc2);
}
-static void set_trace_packet_header(bt_trace_class *trace_class)
-{
- bt_field_class *packet_header_type;
- bt_field_class *fc;
- int ret;
-
- packet_header_type = bt_field_class_structure_create();
- BT_ASSERT(packet_header_type);
- fc = bt_field_class_unsigned_integer_create();
- BT_ASSERT(fc);
- bt_field_class_integer_set_field_value_range(fc, 32);
- ret = bt_field_class_structure_append_member(packet_header_type,
- "stream_id", fc);
- BT_ASSERT(ret == 0);
- bt_field_class_put_ref(fc);
- ret = bt_trace_class_set_packet_header_field_class(trace_class,
- packet_header_type);
- BT_ASSERT(ret == 0);
-
- bt_field_class_put_ref(packet_header_type);
-}
-
static bt_trace_class *create_tc1(bt_self_component_source *self_comp)
{
bt_trace_class *tc1 = NULL;
tc1 = bt_trace_class_create(
bt_self_component_source_as_self_component(self_comp));
BT_ASSERT(tc1);
- set_trace_packet_header(tc1);
create_sc1(tc1);
create_sc2(tc1);
return tc1;
BT_ASSERT(ret == 0);
graph = bt_graph_create();
ret = bt_graph_add_source_component(graph, comp_cls, "src-comp",
- NULL, NULL);
+ NULL, BT_LOGGING_LEVEL_NONE, NULL);
BT_ASSERT(ret == 0);
bt_graph_put_ref(graph);
bt_component_class_source_put_ref(comp_cls);