tests: add framework to run code in comp cls / comp / msg iter context
authorSimon Marchi <simon.marchi@efficios.com>
Tue, 23 May 2023 18:19:42 +0000 (14:19 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Wed, 31 May 2023 19:47:48 +0000 (15:47 -0400)
Add a little framework to make it easier to write tests that need a
bt_self_component_class, bt_self_component or bt_self_message_iterator.
This is inspired from what we have already in
tests/lib/conds/utils.{hpp,cpp}, but decoupled from the
pre/post-condition assertion tests.  A subsequent commit will change
this test to use the new framework.

The framework exposes the run_in function, which accepts three callbacks
that are executed at three different points in the graph's lifecycle,
providing access to all three contexts.  Each callback may be nullptr.

For convenience, there are also three functions to run code in each
individual context:

 - runInCompClsQuery
 - runInCompClsInitFunc
 - runInMsgIterClsInitFunc

If needed, some additional hook points can be added later, to access
other points of the graph's lifecycle.

The run_in function makes an end-to-end run:

 - creates a graph
 - creates a source component class
 - makes a query on that component class
 - adds a source component
 - adds a dummy sink component, connects the ports of the two components
 - runs the graph

Even for a test that only needs to run code in component class context,
for instance, we still run the whole enchilada.  This is a bit
inefficient, but given that this is just for testing, we don't really
care, as it still runs quick.

Change-Id: Ie532b316dc330758b60fd5f6fe9499f0555f8a8a
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10060
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>

No differences found
This page took 0.024486 seconds and 4 git commands to generate.