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)
commit484a30244f4297ce7f0ac0ea1c0c4d566b39c46e
treedd094241721b7383bd06aa7d7bbc50d08da7e689
parent4b4f3ca692cbc2b7ed3632bfd55412351275b013
tests: add framework to run code in comp cls / comp / msg iter context

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>
configure.ac
tests/lib/Makefile.am
tests/lib/utils/Makefile.am [new file with mode: 0644]
tests/lib/utils/run-in.cpp [new file with mode: 0644]
tests/lib/utils/run-in.hpp [new file with mode: 0644]
This page took 0.024599 seconds and 4 git commands to generate.