From: Simon Marchi Date: Wed, 1 May 2024 21:18:54 +0000 (-0400) Subject: tests: make `runIn()` accept a MIP version X-Git-Url: http://drtracing.org/?a=commitdiff_plain;h=2ec9f669a63fc1af65f1777e83c3697fcd4a3a35;p=babeltrace.git tests: make `runIn()` accept a MIP version Make `runIn()` and `RunInCondTrigger` accept a MIP version to use when creating the graph, instead of using 0. Update existing users to pass a hardcoded 0. Add a `forEachMipVersion()` utility function, which calls a callback once for each possible MIP version. This is intended to help code that wants to try testing variations of the same thing for all possible MIP version. Change-Id: Ic1d42d20b4eef872106f216fea9d2e883cb33775 Signed-off-by: Simon Marchi Reviewed-on: https://review.lttng.org/c/babeltrace/+/12780 Reviewed-by: Philippe Proulx Tested-by: jenkins --- diff --git a/tests/lib/conds/clk-cls-compat-postconds-triggers.cpp b/tests/lib/conds/clk-cls-compat-postconds-triggers.cpp index 5f5cbed0..916b921b 100644 --- a/tests/lib/conds/clk-cls-compat-postconds-triggers.cpp +++ b/tests/lib/conds/clk-cls-compat-postconds-triggers.cpp @@ -146,7 +146,7 @@ void addClkClsCompatTriggers(CondTriggers& triggers) triggers.emplace_back(bt2s::make_unique>( ClockClsCompatRunIn {msgType1, createClockCls1, msgType2, createClockCls2}, - CondTrigger::Type::Post, condId, fmt::format("{}-{}", msgType1, msgType2))); + CondTrigger::Type::Post, condId, 0u, fmt::format("{}-{}", msgType1, msgType2))); } } }; diff --git a/tests/lib/conds/conds-triggers.cpp b/tests/lib/conds/conds-triggers.cpp index 02fe33ce..26b04b00 100644 --- a/tests/lib/conds/conds-triggers.cpp +++ b/tests/lib/conds/conds-triggers.cpp @@ -70,7 +70,7 @@ CondTrigger::UP makeRunInCompInitTrigger(OnCompInitFunc func, const CondTrigger: const bt2c::CStringView nameSuffix = {}) { return bt2s::make_unique>( - RunInDelegator::makeOnCompInit(std::move(func)), type, condId, nameSuffix); + RunInDelegator::makeOnCompInit(std::move(func)), type, condId, 0u, nameSuffix); } bt2::IntegerFieldClass::Shared createUIntFc(const bt2::SelfComponent self) diff --git a/tests/lib/conds/utils.hpp b/tests/lib/conds/utils.hpp index b9cb5f42..170d5edc 100644 --- a/tests/lib/conds/utils.hpp +++ b/tests/lib/conds/utils.hpp @@ -115,9 +115,10 @@ class RunInCondTrigger : public CondTrigger { public: explicit RunInCondTrigger(RunInT runIn, const Type type, const std::string& condId, + const std::uint64_t graphMipVersion, const bt2c::CStringView nameSuffix = {}) : CondTrigger {type, condId, nameSuffix}, - _mRunIn {std::move(runIn)} + _mRunIn {std::move(runIn)}, _mGraphMipVersion {graphMipVersion} { } @@ -129,11 +130,12 @@ public: void operator()() noexcept override { - runIn(_mRunIn); + runIn(_mRunIn, _mGraphMipVersion); } private: RunInT _mRunIn; + std::uint64_t _mGraphMipVersion; }; /* diff --git a/tests/lib/test-fields-bin.cpp b/tests/lib/test-fields-bin.cpp index 3d2d9ade..9c53b438 100644 --- a/tests/lib/test-fields-bin.cpp +++ b/tests/lib/test-fields-bin.cpp @@ -51,7 +51,7 @@ int main() plan_tests(NR_TESTS); TestStringClear testStringClear; - runIn(testStringClear); + runIn(testStringClear, 0); return exit_status(); } diff --git a/tests/lib/utils/run-in.cpp b/tests/lib/utils/run-in.cpp index e31bbc58..56f637ab 100644 --- a/tests/lib/utils/run-in.cpp +++ b/tests/lib/utils/run-in.cpp @@ -86,7 +86,7 @@ private: } /* namespace */ -void runIn(RunIn& runIn) +void runIn(RunIn& runIn, const std::uint64_t graphMipVersion) { const auto srcCompCls = bt2::SourceComponentClass::create(); @@ -94,7 +94,7 @@ void runIn(RunIn& runIn) bt2::QueryExecutor::create(*srcCompCls, "object-name", runIn)->query(); /* Create graph */ - const auto graph = bt2::Graph::create(0); + const auto graph = bt2::Graph::create(graphMipVersion); /* Add custom source component (executes `compCtxFunc`) */ const auto srcComp = graph->addComponent(*srcCompCls, "the-source", runIn); @@ -124,3 +124,10 @@ void runIn(RunIn& runIn) /* Run graph (executes `msgIterCtxFunc`) */ graph->run(); } + +void forEachMipVersion(const std::function& fn) +{ + for (std::uint64_t v = 0; v <= bt_get_maximal_mip_version(); ++v) { + fn(v); + } +} diff --git a/tests/lib/utils/run-in.hpp b/tests/lib/utils/run-in.hpp index 62770b5d..8067f438 100644 --- a/tests/lib/utils/run-in.hpp +++ b/tests/lib/utils/run-in.hpp @@ -49,7 +49,14 @@ public: /* * Runs a simple graph (one source and one sink component), calling the * `on*()` methods of `runIn` along the way. + * + * Use `graphMipVersion` as the graph's MIP version. + */ +void runIn(RunIn& runIn, std::uint64_t graphMipVersion); + +/* + * Calls `fn` for each possible MIP version. */ -void runIn(RunIn& runIn); +void forEachMipVersion(const std::function& fn); #endif /* BABELTRACE_TESTS_LIB_UTILS_RUN_IN_HPP */