tests: make `runIn()` accept a MIP version
authorSimon Marchi <simon.marchi@efficios.com>
Wed, 1 May 2024 21:18:54 +0000 (17:18 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Wed, 9 Oct 2024 02:56:57 +0000 (22:56 -0400)
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 <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12780
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
tests/lib/conds/clk-cls-compat-postconds-triggers.cpp
tests/lib/conds/conds-triggers.cpp
tests/lib/conds/utils.hpp
tests/lib/test-fields-bin.cpp
tests/lib/utils/run-in.cpp
tests/lib/utils/run-in.hpp

index 5f5cbed032ea6e59371761cfe657c18d00844cc0..916b921b0c66e3c695cecdb6c2b3575cc7d1367b 100644 (file)
@@ -146,7 +146,7 @@ void addClkClsCompatTriggers(CondTriggers& triggers)
 
                 triggers.emplace_back(bt2s::make_unique<RunInCondTrigger<ClockClsCompatRunIn>>(
                     ClockClsCompatRunIn {msgType1, createClockCls1, msgType2, createClockCls2},
-                    CondTrigger::Type::Post, condId, fmt::format("{}-{}", msgType1, msgType2)));
+                    CondTrigger::Type::Post, condId, 0u, fmt::format("{}-{}", msgType1, msgType2)));
             }
         }
     };
index 02fe33cee929a8797a7659aaee497307ad0492cf..26b04b0015def25fbd2031759d3b10c4175ad1f6 100644 (file)
@@ -70,7 +70,7 @@ CondTrigger::UP makeRunInCompInitTrigger(OnCompInitFunc func, const CondTrigger:
                                          const bt2c::CStringView nameSuffix = {})
 {
     return bt2s::make_unique<RunInCondTrigger<RunInDelegator>>(
-        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)
index b9cb5f4206a9b7fbf0ada18f7edd751321fa6794..170d5edc16a79d1d912863a5b087d1c694a3ad8b 100644 (file)
@@ -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;
 };
 
 /*
index 3d2d9adef0246729ea3ea2f6db44c839f0016731..9c53b438fce5ba8253d66d47a0e34e14df3d1434 100644 (file)
@@ -51,7 +51,7 @@ int main()
     plan_tests(NR_TESTS);
 
     TestStringClear testStringClear;
-    runIn(testStringClear);
+    runIn(testStringClear, 0);
 
     return exit_status();
 }
index e31bbc58a26ab511e306c61b4eea9d5bd3fe9470..56f637abdc7b813b5d9ab1a292ad18dd0e23a0c3 100644 (file)
@@ -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<RunInSource>();
 
@@ -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<void(std::uint64_t)>& fn)
+{
+    for (std::uint64_t v = 0; v <= bt_get_maximal_mip_version(); ++v) {
+        fn(v);
+    }
+}
index 62770b5dee44122c013eabbf346ae512511c6eee..8067f438dff66b77c510f431464963d00ad5c145 100644 (file)
@@ -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<void(std::uint64_t)>& fn);
 
 #endif /* BABELTRACE_TESTS_LIB_UTILS_RUN_IN_HPP */
This page took 0.028355 seconds and 4 git commands to generate.