tests/lib: use `sink.utils.dummy` in `utils/run-in.cpp`
authorSimon Marchi <simon.marchi@efficios.com>
Fri, 16 Feb 2024 20:52:59 +0000 (15:52 -0500)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 29 Feb 2024 23:46:23 +0000 (18:46 -0500)
Instead of implementing another dummy sink.

Note that when executed manually, test programs using the `runIn` util
(e.g. `test-fields-bin`) must be executed through
`tests/utils/run-in-py-env.sh`, for the `utils` plugin to be found.

Change-Id: Ib40480089c7dea35fddc7144b0c99873723f8fe8
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11824
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
tests/lib/Makefile.am
tests/lib/utils/run-in.cpp

index edb150d76d8316640b0bc2cb98cbc71a0fdd7867..e389f34b6693c467d087ef26c0cb8dcd1e1bb9ee 100644 (file)
@@ -20,6 +20,16 @@ test_fields_bin_LDADD = $(COMMON_TEST_LDADD) \
        $(top_builddir)/src/lib/libbabeltrace2.la \
        $(top_builddir)/src/cpp-common/vendor/fmt/libfmt.la
 
+if ENABLE_BUILT_IN_PLUGINS
+
+include $(top_srcdir)/src/Makefile.common.inc
+
+test_fields_bin_LDFLAGS = $(call pluginarchive,utils)
+test_fields_bin_LDADD += \
+       $(top_builddir)/src/plugins/common/param-validation/libparam-validation.la
+
+endif # ENABLE_BUILT_IN_PLUGINS
+
 test_bt_uuid_SOURCES = test-bt-uuid.c
 test_bt_uuid_LDADD = $(COMMON_TEST_LDADD)
 
index e1b9dee1a1a241719d861ca792595f75a959b9fe..a3391a93ea2e6ec5e2ff5396d961814ef7abe1f1 100644 (file)
 #include "cpp-common/bt2/component-class-dev.hpp"
 #include "cpp-common/bt2/component-class.hpp"
 #include "cpp-common/bt2/graph.hpp"
+#include "cpp-common/bt2/plugin-load.hpp"
+#include "cpp-common/bt2/plugin.hpp"
 #include "cpp-common/bt2/query-executor.hpp"
+#include "cpp-common/bt2c/call.hpp"
 
 #include "run-in.hpp"
 
@@ -80,31 +83,6 @@ private:
     const RunInData *_mRunInData;
 };
 
-class DummySink : public bt2::UserSinkComponent<DummySink>
-{
-public:
-    static constexpr auto name = "dummy";
-
-    explicit DummySink(const bt2::SelfSinkComponent self, bt2::ConstMapValue, void *) :
-        bt2::UserSinkComponent<DummySink>(self, "DUMMY-SINK")
-    {
-        this->_addInputPort("in");
-    }
-
-    void _graphIsConfigured()
-    {
-        _mMsgIter = this->_createMessageIterator(this->_inputPorts()["in"]);
-    }
-
-    bool _consume()
-    {
-        return _mMsgIter->next().has_value();
-    }
-
-private:
-    bt2::MessageIterator::Shared _mMsgIter;
-};
-
 } /* namespace */
 
 void runIn(RunInCompClsQueryFunc compClsCtxFunc, RunInCompClsInitFunc compCtxFunc,
@@ -123,8 +101,17 @@ void runIn(RunInCompClsQueryFunc compClsCtxFunc, RunInCompClsInitFunc compCtxFun
     const auto srcComp = graph->addComponent(*srcCompCls, "the-source", data);
 
     /* Add dummy sink component */
-    const auto sinkComp =
-        graph->addComponent(*bt2::SinkComponentClass::create<DummySink>(), "the-sink");
+    const auto sinkComp = bt2c::call([&] {
+        const auto utilsPlugin = bt2::findPlugin("utils");
+
+        BT_ASSERT(utilsPlugin);
+
+        const auto dummySinkCompCls = utilsPlugin->sinkComponentClasses()["dummy"];
+
+        BT_ASSERT(dummySinkCompCls);
+
+        return graph->addComponent(*dummySinkCompCls, "the-sink");
+    });
 
     /* Connect ports */
     const auto outPort = srcComp.outputPorts()["out"];
This page took 0.026454 seconds and 4 git commands to generate.