X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=blobdiff_plain;f=tests%2Flib%2Ftest_trace_ir_ref.c;h=d5dfa9cf94afd3289403154710ac3cdfa3e0b2ad;hp=f0f3961dcb6ec56d72d3a7844e5a85c28422f9ca;hb=0235b0db7de5bcacdb3650c92461f2ce5eb2143d;hpb=83ebb7f1751a20c7ba771442487f863331c754ef diff --git a/tests/lib/test_trace_ir_ref.c b/tests/lib/test_trace_ir_ref.c index f0f3961d..d5dfa9cf 100644 --- a/tests/lib/test_trace_ir_ref.c +++ b/tests/lib/test_trace_ir_ref.c @@ -1,29 +1,26 @@ /* - * test_trace_ir_ref.c + * SPDX-License-Identifier: GPL-2.0-only * - * Trace IR Reference Count test - * - * Copyright 2016 - Jérémie Galarneau - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; under version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * Copyright (C) 2016 Jérémie Galarneau * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Trace IR Reference Count test */ +#include #include "tap/tap.h" -#include -#include -#include -#include +#include +#include "lib/object.h" +#include "compat/stdlib.h" +#include "common/assert.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "common.h" #define NR_TESTS 37 @@ -71,19 +68,19 @@ static bt_field_class *create_integer_struct(bt_trace_class *trace_class) structure = bt_field_class_structure_create(trace_class); BT_ASSERT(structure); - ui8 = bt_field_class_unsigned_integer_create(trace_class); + ui8 = bt_field_class_integer_unsigned_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(trace_class); + ui16 = bt_field_class_integer_unsigned_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(trace_class); + ui32 = bt_field_class_integer_unsigned_create(trace_class); BT_ASSERT(ui32); bt_field_class_integer_set_field_value_range(ui32, 32); ret = bt_field_class_structure_append_member(structure, @@ -187,37 +184,6 @@ static bt_event_class *create_complex_event(bt_stream_class *sc, return event; } -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 *fc; - int ret; - - packet_context_type = bt_field_class_structure_create(trace_class); - BT_ASSERT(packet_context_type); - 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(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); - ret = bt_stream_class_set_packet_context_field_class( - stream_class, packet_context_type); - BT_ASSERT(ret == 0); - bt_field_class_put_ref(packet_context_type); -} - static void create_sc1(bt_trace_class *trace_class) { int ret; @@ -228,7 +194,6 @@ static void create_sc1(bt_trace_class *trace_class) BT_ASSERT(sc1); ret = bt_stream_class_set_name(sc1, "sc1"); BT_ASSERT(ret == 0); - set_stream_class_field_classes(sc1); ec1 = create_complex_event(sc1, "ec1"); BT_ASSERT(ec1); ec2 = create_simple_event(sc1, "ec2"); @@ -252,7 +217,6 @@ static void create_sc2(bt_trace_class *trace_class) BT_ASSERT(sc2); ret = bt_stream_class_set_name(sc2, "sc2"); BT_ASSERT(ret == 0); - set_stream_class_field_classes(sc2); ec3 = create_simple_event(sc2, "ec3"); ret_stream = bt_event_class_borrow_stream_class(ec3); ok(ret_stream == sc2, "Borrow parent stream SC2 from EC3"); @@ -432,39 +396,45 @@ static void test_example_scenario(bt_self_component_source *self_comp) } static -bt_self_component_status src_init( +bt_component_class_initialize_method_status src_init( bt_self_component_source *self_comp, + bt_self_component_source_configuration *config, const bt_value *params, void *init_method_data) { test_example_scenario(self_comp); - return BT_SELF_COMPONENT_STATUS_OK; + return BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_OK; } static -bt_self_message_iterator_status src_iter_next( +bt_message_iterator_class_next_method_status src_iter_next( bt_self_message_iterator *self_iterator, bt_message_array_const msgs, uint64_t capacity, uint64_t *count) { - return BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR; + return BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR; } static void test_example_scenario_in_graph(void) { + bt_message_iterator_class *msg_iter_cls; bt_component_class_source *comp_cls; bt_graph *graph; int ret; - comp_cls = bt_component_class_source_create("src", src_iter_next); + msg_iter_cls = bt_message_iterator_class_create(src_iter_next); + BT_ASSERT(msg_iter_cls); + + comp_cls = bt_component_class_source_create("src", msg_iter_cls); BT_ASSERT(comp_cls); - ret = bt_component_class_source_set_init_method(comp_cls, src_init); + ret = bt_component_class_source_set_initialize_method(comp_cls, src_init); BT_ASSERT(ret == 0); - graph = bt_graph_create(); + graph = bt_graph_create(0); 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); + bt_message_iterator_class_put_ref(msg_iter_cls); } static void create_writer_user_full(struct writer_user *user)