tests/lib: C++ify run-in and condition trigger code
authorSimon Marchi <simon.marchi@efficios.com>
Fri, 16 Feb 2024 04:19:15 +0000 (23:19 -0500)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 29 Feb 2024 23:46:23 +0000 (18:46 -0500)
commit5d7e57e846a27172cc3bc5d0fcf5b3e55551e289
treebc14d37974c6cbd45877514981f49c73b8c5d809
parent0133a2ba3063b5b8526990bf95f2f53ed212f6a6
tests/lib: C++ify run-in and condition trigger code

Change the design of the "run in" test util.

Currently, the util exposes separate functions taking a function pointer
(for all contexts where it's possible to run code in),

Change it to a single function accepting a reference to an object of
type `RunIn`, a class with virtual methods corresponding to each
context.  Clients are expected to define classes derived from `RunIn`
and override only the methods they need.

One advantage of this is that it allows a client to override multiple
methods in order to test a scenario that requires executing code in
multiple contexts.  And it allows it to keep some data in the derived
class to use across the callbacks.

Adjust `tests/lib/conds/utils.{cpp,hpp}`, which is based on `RunIn`.
Replace the open struct `cond_trigger` with:

 - a base class `CondTrigger`, with a virtual pure `operator()`.
 - an implementation `SimpleCondTrigger`, which executes a simple
   callback in `operator()`.
 - an implementation `RunInCondTrigger`, which calls `runIn` in
   `operator()`, with a user-provided `RunIn` object.

Update `conds-triggers.cpp`, which is based on `utils.{cpp,hpp}`.
Implement the condition triggers using the C++ bindings.

Do some more miscellaneous C++ification in `utils.cpp` and
`conds-triggers.cpp`.

Change-Id: I483dd1a49bc7fb1e1fc1b19e0fc01b97d4ea627f
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11795
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
tests/lib/conds/conds-triggers.cpp
tests/lib/conds/utils.cpp
tests/lib/conds/utils.hpp
tests/lib/test-fields-bin.cpp
tests/lib/utils/run-in.cpp
tests/lib/utils/run-in.hpp
This page took 0.025903 seconds and 4 git commands to generate.