From: Simon Marchi Date: Tue, 13 Feb 2024 03:26:22 +0000 (-0500) Subject: tests/lib: pass C++ wrapper types to `RunIn` callbacks X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=5d15e4cab25bba8cf293e7edb6adf3c6b1c68958 tests/lib: pass C++ wrapper types to `RunIn` callbacks Pass C++ wrapper types to `RunInCompClsInitFunc`, `RunInCompClsQueryFunc` and `RunInMsgIterClsInitFunc` instead of C library types. Adjust callers and callees in a trivial way. Change-Id: I3d6fcee8e0239976483995affcd7e95fb5fa12ef Signed-off-by: Simon Marchi Reviewed-on: https://review.lttng.org/c/babeltrace/+/11796 Reviewed-by: Philippe Proulx Tested-by: jenkins --- diff --git a/tests/lib/conds/conds-triggers.cpp b/tests/lib/conds/conds-triggers.cpp index 83182f9a..55299737 100644 --- a/tests/lib/conds/conds-triggers.cpp +++ b/tests/lib/conds/conds-triggers.cpp @@ -26,17 +26,17 @@ static bt_field_class *get_uint_fc(bt_self_component *self_comp) return fc; } -static void trigger_fc_int_set_field_value_range_n_0(bt_self_component *self_comp) +static void trigger_fc_int_set_field_value_range_n_0(const bt2::SelfComponent self) { - bt_field_class_integer_set_field_value_range(get_uint_fc(self_comp), 0); + bt_field_class_integer_set_field_value_range(get_uint_fc(self.libObjPtr()), 0); } -static void trigger_fc_int_set_field_value_range_n_gt_64(bt_self_component *self_comp) +static void trigger_fc_int_set_field_value_range_n_gt_64(const bt2::SelfComponent self) { - bt_field_class_integer_set_field_value_range(get_uint_fc(self_comp), 65); + bt_field_class_integer_set_field_value_range(get_uint_fc(self.libObjPtr()), 65); } -static void trigger_fc_int_set_field_value_range_null(bt_self_component *) +static void trigger_fc_int_set_field_value_range_null(bt2::SelfComponent) { bt_field_class_integer_set_field_value_range(NULL, 23); } diff --git a/tests/lib/conds/utils.hpp b/tests/lib/conds/utils.hpp index 8d01efec..6ba7401f 100644 --- a/tests/lib/conds/utils.hpp +++ b/tests/lib/conds/utils.hpp @@ -9,6 +9,8 @@ #include +#include "cpp-common/bt2/self-component-port.hpp" + enum cond_trigger_func_type { COND_TRIGGER_FUNC_TYPE_BASIC, @@ -22,7 +24,7 @@ enum cond_trigger_type }; typedef void (*cond_trigger_basic_func)(void); -typedef void (*cond_trigger_run_in_comp_cls_init_func)(bt_self_component *); +typedef void (*cond_trigger_run_in_comp_cls_init_func)(bt2::SelfComponent); struct cond_trigger { diff --git a/tests/lib/test-fields-bin.cpp b/tests/lib/test-fields-bin.cpp index 0bc8bb3b..7f2c26d4 100644 --- a/tests/lib/test-fields-bin.cpp +++ b/tests/lib/test-fields-bin.cpp @@ -16,10 +16,10 @@ static const int NR_TESTS = 2; static void test_string_clear() { - runInMsgIterClsInit([](bt_self_message_iterator * const self) { + runInMsgIterClsInit([](const bt2::SelfMessageIterator self) { /* Boilerplate to get a string field */ const auto traceCls = - bt_trace_class_create(bt_self_message_iterator_borrow_component(self)); + bt_trace_class_create(bt_self_message_iterator_borrow_component(self.libObjPtr())); const auto streamCls = bt_stream_class_create(traceCls); const auto eventCls = bt_event_class_create(streamCls); const auto payloadCls = bt_field_class_structure_create(traceCls); @@ -39,7 +39,7 @@ static void test_string_clear() const auto trace = bt_trace_create(traceCls); const auto stream = bt_stream_create(streamCls, trace); - const auto msg = bt_message_event_create(self, eventCls, stream); + const auto msg = bt_message_event_create(self.libObjPtr(), eventCls, stream); const auto field = bt_field_structure_borrow_member_field_by_name( bt_event_borrow_payload_field(bt_message_event_borrow_event(msg)), "str"); diff --git a/tests/lib/utils/run-in.cpp b/tests/lib/utils/run-in.cpp index 01913872..3fef7d32 100644 --- a/tests/lib/utils/run-in.cpp +++ b/tests/lib/utils/run-in.cpp @@ -7,6 +7,7 @@ #include #include "common/assert.h" +#include "cpp-common/bt2/wrap.hpp" #include "run-in.hpp" @@ -37,7 +38,7 @@ bt_component_class_initialize_method_status compClsInit(bt_self_component_source auto& data = runInDataFromMethodData(initMethodData); if (data.compCtxFunc) { - data.compCtxFunc(bt_self_component_source_as_self_component(selfComp)); + data.compCtxFunc(bt2::wrap(bt_self_component_source_as_self_component(selfComp))); } return BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_OK; @@ -51,7 +52,8 @@ compClsQuery(bt_self_component_class_source * const selfCompCls, bt_private_quer auto& data = runInDataFromMethodData(methodData); if (data.compClsCtxFunc) { - data.compClsCtxFunc(bt_self_component_class_source_as_self_component_class(selfCompCls)); + data.compClsCtxFunc( + bt2::wrap(bt_self_component_class_source_as_self_component_class(selfCompCls))); } *result = bt_value_null; @@ -66,7 +68,7 @@ msgIterClsInit(bt_self_message_iterator * const selfMsgIter, bt_self_component_port_output_as_self_component_port(port))); if (data.msgIterCtxFunc) { - data.msgIterCtxFunc(selfMsgIter); + data.msgIterCtxFunc(bt2::wrap(selfMsgIter)); } return BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_OK; diff --git a/tests/lib/utils/run-in.hpp b/tests/lib/utils/run-in.hpp index 0855e05e..01774f90 100644 --- a/tests/lib/utils/run-in.hpp +++ b/tests/lib/utils/run-in.hpp @@ -11,9 +11,13 @@ #include -using RunInCompClsQueryFunc = std::function; -using RunInCompClsInitFunc = std::function; -using RunInMsgIterClsInitFunc = std::function; +#include "cpp-common/bt2/self-component-class.hpp" +#include "cpp-common/bt2/self-component-port.hpp" +#include "cpp-common/bt2/self-message-iterator.hpp" + +using RunInCompClsQueryFunc = std::function; +using RunInCompClsInitFunc = std::function; +using RunInMsgIterClsInitFunc = std::function; /* * Runs: