Fix: tests: free message iterator class in test_graph_topo.c
[babeltrace.git] / tests / lib / test_graph_topo.c
index 91e12760f12b503b6c203c5ee88e8b50698366aa..c31f7c8be4a309deee02787099caa580512cb1eb 100644 (file)
@@ -1,20 +1,7 @@
 /*
- * test_graph_topo.c
+ * SPDX-License-Identifier: GPL-2.0-only
  *
- * Copyright 2017 - Philippe Proulx <pproulx@efficios.com>
- *
- * 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.
- *
- * 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.
+ * Copyright (C) 2017 Philippe Proulx <pproulx@efficios.com>
  */
 
 #include <babeltrace2/babeltrace.h>
@@ -72,6 +59,7 @@ struct event {
 };
 
 static GArray *events;
+static bt_message_iterator_class *msg_iter_class;
 static bt_component_class_source *src_comp_class;
 static bt_component_class_sink *sink_comp_class;
 static enum test current_test;
@@ -190,12 +178,12 @@ size_t event_pos(struct event *event)
 }
 
 static
-bt_component_class_message_iterator_next_method_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_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR;
+       return BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR;
 }
 
 static
@@ -339,8 +327,11 @@ void init_test(void)
 {
        int ret;
 
+       msg_iter_class = bt_message_iterator_class_create(src_iter_next);
+       BT_ASSERT(msg_iter_class);
+
        src_comp_class = bt_component_class_source_create(
-               "src", src_iter_next);
+               "src", msg_iter_class);
        BT_ASSERT(src_comp_class);
        ret = bt_component_class_source_set_initialize_method(
                src_comp_class, src_init);
@@ -367,6 +358,7 @@ void fini_test(void)
        bt_component_class_source_put_ref(src_comp_class);
        bt_component_class_sink_put_ref(sink_comp_class);
        g_array_free(events, TRUE);
+       BT_MESSAGE_ITERATOR_CLASS_PUT_REF_AND_RESET(msg_iter_class);
 }
 
 static
@@ -501,8 +493,6 @@ void test_src_adds_port_in_port_connected(void)
        ok(src_port_connected_pos < graph_port_added_src_pos,
                "event order is good");
 
-       bt_component_source_put_ref(src);
-       bt_component_sink_put_ref(sink);
        bt_graph_put_ref(graph);
 }
 
@@ -569,9 +559,7 @@ void test_simple(void)
        event.data.sink_comp_input_port_connected.other_port = gsrc_def_port;
        ok(has_event(&event), "got the expected sink's port connected event");
 
-       bt_component_sink_put_ref(sink);
        bt_graph_put_ref(graph);
-       bt_component_source_put_ref(src);
 }
 
 static
@@ -635,9 +623,6 @@ void test_src_port_connected_error(void)
        ok(has_event(&event), "got the expected source's port connected event");
 
        bt_graph_put_ref(graph);
-       bt_component_sink_put_ref(sink);
-       bt_component_source_put_ref(src);
-       bt_connection_put_ref(conn);
 }
 
 static
@@ -707,10 +692,7 @@ void test_sink_port_connected_error(void)
        event.data.sink_comp_input_port_connected.other_port = gsrc_def_port;
        ok(has_event(&event), "got the expected sink's port connected event");
 
-       bt_connection_put_ref(conn);
        bt_graph_put_ref(graph);
-       bt_component_sink_put_ref(sink);
-       bt_component_source_put_ref(src);
 }
 
 static
This page took 0.024568 seconds and 4 git commands to generate.