Philippe Proulx [Tue, 12 Mar 2024 20:01:23 +0000 (16:01 -0400)]
cpp-common/bt2/wrap.hpp: add a few missing wrap() overloads
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ie06e54e2be2ed7732903c6e6d274aa21801696c6
Philippe Proulx [Tue, 12 Mar 2024 17:06:53 +0000 (13:06 -0400)]
Fix: bt2::CommonOptionField::hasField(): has_value() not available
I forgot this in
ca61ecbc0 ("cpp-common/bt2: use
`bt2::OptionalBorrowedObject` where possible").
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Icb522b0e5a8a73c1899035f820e5d332d6b123d8
Philippe Proulx [Tue, 12 Mar 2024 01:10:01 +0000 (21:10 -0400)]
bt2/clock-class.hpp: "clock class offset" -> "clock offset"
It really is the offset a clock (clock class instance).
Also, "offset" -> "offset from origin".
This is in preparation of CTF 2 support (including libbabeltrace2
changes), where the concept of origin is more defined.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Id623085ae2194a452d2b9b07a8be17395324a5d5
Philippe Proulx [Tue, 12 Mar 2024 01:03:05 +0000 (21:03 -0400)]
cpp-common/bt2c: add bt2c::contains()
This new function template returns whether or not some STL container
contains some value instead of using the awkward find() and end()
methods each time.
Similar to new STL contains() methods of C++20.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Idea480f9001272dfaf1dc0df60251983be8f3962
Philippe Proulx [Mon, 4 Mar 2024 22:53:38 +0000 (17:53 -0500)]
README.adoc: update string_view link
Not using `string_view` Standalone anymore.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ib3f0ab3ae289218c713d59c99f523c54c46df696
Michael Jeanson [Mon, 4 Mar 2024 19:15:59 +0000 (14:15 -0500)]
cpp-common: replace bstd::string_view with nonstd::string_view
This patch replaces the underlying implementation of string_view wrapped
by `bt2s::string_view` with string-view-lite [1] from the same author as
the other nonstd classes we already use.
string view lite is an implementation of `std::string_view` [2] for
C++98 and up.
This change is motivated by a desire to standardise on one provider for
'nonstd' header libraries and the fact that the current implementation
we use fails to build on SLES12 and it's easier to replace it with a
working and maintained implementation than it is to debug it.
[1]: https://github.com/martinmoene/string-view-lite
[2]: https://en.cppreference.com/w/cpp/header/string_view
Change-Id: I1f9a9d62f3de35d939f514a47898a5d1b3ff0099
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12002
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Michael Jeanson [Mon, 4 Mar 2024 16:21:34 +0000 (11:21 -0500)]
tests: fix readonly variables error with bash 4.4
Local variables are always visible to child functions, when they are
declared readonly and the same variable name is reused this results in
an error with bash 4.4.
As a workaround, rename the affected variables to fix the following
errors:
./tests/utils/utils.sh: line 222: args: readonly variable
./tests/utils/utils.sh: line 303: extra_details_args: readonly variable
Change-Id: I7321a9940a2e69bede363acddbd5f0465a3b1433
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12000
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Michael Jeanson [Mon, 4 Mar 2024 15:57:21 +0000 (10:57 -0500)]
tests: fix unbound variables in env.sh
When running a bash test script manually, the '_set_var_def' function
expands the variables using their simple form resulting in an unbound
variable error if they are undefined. Use the Default values form
instead in the eval to fix these errors:
tests/utils/env.sh: line 12: BT_TESTS_AWK_BIN: unbound variable
tests/utils/env.sh: line 12: BT_TESTS_GREP_BIN: unbound variable
tests/utils/env.sh: line 12: BT_TESTS_PYTHON_BIN: unbound variable
tests/utils/env.sh: line 12: BT_TESTS_PYTHON_CONFIG_BIN: unbound variable
tests/utils/env.sh: line 12: BT_TESTS_SED_BIN: unbound variable
tests/utils/env.sh: line 12: BT_TESTS_CC_BIN: unbound variable
tests/utils/env.sh: line 12: BT_TESTS_ENABLE_ASAN: unbound variable
tests/utils/env.sh: line 12: BT_TESTS_ENABLE_PYTHON_PLUGINS: unbound variable
Change-Id: Ic4b2a3b97bd6a4d776ab6898959742ef77988332
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11999
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Philippe Proulx [Fri, 16 Feb 2024 21:30:33 +0000 (16:30 -0500)]
tests/lib/conds/utils.cpp: condMain(): unset `BABELTRACE_EXEC_ON_ABORT`
This test willingly makes libbabeltrace2 abort, therefore
`BABELTRACE_EXEC_ON_ABORT` gets executed each time, and we don't want
that in the testing context.
condMain() is the closest to where the abort occurs: this means you may
run `tests/lib/conds/conds-triggers` directly and
`BABELTRACE_EXEC_ON_ABORT` won't impact the program.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I72f21cfcbe2ec8b1f48ec0703c42b3b1d710283c
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11818
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Simon Marchi [Fri, 16 Feb 2024 04:19:15 +0000 (23:19 -0500)]
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>
Simon Marchi [Fri, 16 Feb 2024 20:52:59 +0000 (15:52 -0500)]
tests/lib: use `sink.utils.dummy` in `utils/run-in.cpp`
Instead of implementing another dummy sink.
Note that when executed manually, test programs using the `runIn` util
(e.g. `test-fields-bin`) must be executed through
`tests/utils/run-in-py-env.sh`, for the `utils` plugin to be found.
Change-Id: Ib40480089c7dea35fddc7144b0c99873723f8fe8
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11824
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Simon Marchi [Mon, 19 Feb 2024 20:18:35 +0000 (15:18 -0500)]
build: factor out `pluginarchive` function to `src/Makefile.common.inc`
A subsequent patch will need to bundle a plugin in a test executable,
requiring the same command line used by the CLI to bundle plugins in the
`babeltrace2` executable, when `--enable-built-in-plugins` is used.
Move the `pluginarchive` "function" and `PLUGINS_PATH` definition to a
new file, `src/Makefile.common.inc`, and include that file from
`src/cli/Makefile.am`.
Change-Id: I36a8d6191deb82e5bceab3f5b038f69626ecdfe2
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11830
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Michael Jeanson <mjeanson@efficios.com>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Simon Marchi [Fri, 16 Feb 2024 20:42:59 +0000 (15:42 -0500)]
cpp-common/bt2: add `findPlugin()`
Add the `findPlugin()` function, allowing one to find a plugin by name.
The default parameter values used are the same as those used in the
Python bindings.
Change-Id: I659b5b0f0ae18965bbcacdac3c4e0c146c7348e4
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11823
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Simon Marchi [Fri, 16 Feb 2024 19:33:07 +0000 (14:33 -0500)]
cpp-common/bt2: add C++ plugin bindings
Add C++ bindings around `bt_plugin`. There is only the const version
(`ConstPlugin`), because there is no need for a non-const plugin.
Get the scalar properties of a plugin using the `name`, `description`,
`author`, `license` and `path` methods.
Get the version of a plugin using the `version` method.
Get the component classes provided by the plugin using the
`sourceComponentClasses`, `filterComponentClasses` and
`sinkComponentClasses` methods. These methods return proxy objects that
can be iterated on. They also defined an `operator[]` method to access
component classes by name.
Change-Id: I5121c7c54a8058e5ca116618472ec8bb63f3a825
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11822
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Simon Marchi [Mon, 19 Feb 2024 18:20:44 +0000 (13:20 -0500)]
cpp-common/bt2: move findAllPluginsFromDir() to `plugin-load.hpp`
All "find plugin(s)" function will go in that file.
Change-Id: Ie81a35d8a253dafef2fd696c64341609b0e4960b
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11821
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Simon Marchi [Fri, 16 Feb 2024 19:31:12 +0000 (14:31 -0500)]
cpp-common/bt2: move `ConstPluginSet` to `plugin-set.hpp`
A subsequent patch will introduce `bt2::ConstPlugin`. It makes more
sense to have `bt2::ConstPluginSet` in `plugin-set.hpp`.
Change-Id: I84996f34aec325eb2336335a73fdb5e857253c96
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11820
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Simon Marchi [Thu, 22 Feb 2024 02:23:03 +0000 (21:23 -0500)]
bt2: compile `native_bt.c` with `-Wno-undef`
As explained in the comment, work around a problem with SWIG 4.2.0.
Change-Id: Ia95fc1e4929591a0a16df48892b05f5e5df46be3
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11849
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Michael Jeanson <mjeanson@efficios.com>
Philippe Proulx [Thu, 22 Feb 2024 18:14:27 +0000 (13:14 -0500)]
CONTRIBUTING.adoc: update the "C++ usage" section
Add a subsection about `src/cpp-common` and its contents.
Improve "Coding convention" subsection following our latest convention.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ifa6eb57492b9434388889297b77e0835f9f98114
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11853
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Simon Marchi [Wed, 14 Feb 2024 17:16:16 +0000 (12:16 -0500)]
tests/lib: create and manipulate query executor using C++ bindings in `tests/run-in.cpp`
Change-Id: Ice0533691242cc584de24d60a212c740747c4a56
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11809
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Simon Marchi [Wed, 14 Feb 2024 16:12:07 +0000 (11:12 -0500)]
cpp-common/bt2: add C++ query executor bindings
Add C++ bindings for query executors.
Create a query executor with the `bt2::QueryExecutor::create()` static
methods (with or without query data).
Perform a query with the `bt2::QueryExecutor::query()` method.
Change-Id: I1db634dfd423b031be7577291d4de02b7fb0df5b
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11808
Tested-by: jenkins <jenkins@lttng.org>
Simon Marchi [Wed, 14 Feb 2024 17:15:16 +0000 (12:15 -0500)]
tests/lib: create and manipulate graph using C++ bindings in `utils/run-in.cpp`
Change-Id: I63852856cce4d68cb81ae56b8dab67029392dbac
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11807
Tested-by: jenkins <jenkins@lttng.org>
Simon Marchi [Wed, 14 Feb 2024 16:11:43 +0000 (11:11 -0500)]
cpp-common/bt2: add C++ graph bindings
Add C++ bindings to create and manipulate graphs.
Create `bt2::Graph` objects with the `bt2::Graph::create()` static
method.
Add components to graphs with the `bt2::Graph::addComponent()`
methods. There are overloads of this methods for sources, filters and
sinks, and with and without initialization data.
Connect ports with the `bt2::Graph::connectPorts()` method. The method
does not (yet) provide access to the connection object returned by the
lib.
Run a graph with `bt2::Graph::run()` or `bt2::Graph::run_once()`.
Change-Id: I92719f9dd6e8c77ded20d1bb4a5ddd2a03e8cf0d
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11806
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Simon Marchi [Wed, 14 Feb 2024 17:09:42 +0000 (12:09 -0500)]
tests/lib: create component classes using C++ bindings in `utils/run-in.cpp`
Change-Id: I449799599a5e0d3b1f4ad1864c027b5e60886cda
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11805
Tested-by: jenkins <jenkins@lttng.org>
Simon Marchi [Thu, 15 Feb 2024 21:19:17 +0000 (16:19 -0500)]
cpp-common/bt2: make `SinkCompClsBridge::userCompFromLibSelfCompPtr` public
`SinkCompClsBridge::userCompFromLibSelfCompPtr` needs to be public for
`CompClsBridgeWithInputPorts::inputPortConnected` to access it, for
instance.
Here's the error I got when trying to use `SinkCompClsBridge` in a
following patch, which lead to this fix:
CXX utils/run-in.lo
In file included from /home/smarchi/src/babeltrace/src/cpp-common/bt2/component-class.hpp:12,
from /home/smarchi/src/babeltrace/tests/lib/utils/run-in.cpp:10:
/home/smarchi/src/babeltrace/src/cpp-common/bt2/plugin-dev.hpp: In instantiation of 'static bt_component_class_port_connected_method_status bt2::internal::CompClsBridgeWithInputPorts<SpecCompClsBridgeT, LibTypesT>::inputPortConnected(typename LibTypesT::SelfComp*, bt_self_component_port_input*, const bt_port_output*) [with SpecCompClsBridgeT = bt2::internal::SinkCompClsBridge<{anonymous}::DummySink>; LibTypesT = bt2::internal::SinkCompClsLibTypes; bt_component_class_port_connected_method_status = bt_component_class_port_connected_method_status; typename LibTypesT::SelfComp = bt_self_component_sink; bt_self_component_port_input = bt_self_component_port_input; bt_port_output = bt_port_output]':
/home/smarchi/src/babeltrace/src/cpp-common/bt2/component-class.hpp:477:88: required from 'static bt2::internal::CommonSinkComponentClass<LibObjT>::Shared bt2::internal::CommonSinkComponentClass<LibObjT>::create() [with UserCompClsT = {anonymous}::DummySink; LibObjT = bt_component_class_sink; Shared = bt2::SharedObject<bt2::internal::CommonSinkComponentClass<bt_component_class_sink>, bt_component_class_sink, bt2::internal::SinkComponentClassRefFuncs>]'
/home/smarchi/src/babeltrace/tests/lib/utils/run-in.cpp:141:72: required from here
/home/smarchi/src/babeltrace/src/cpp-common/bt2/plugin-dev.hpp:160:59: error: 'static UserCompClsT& bt2::internal::CompClsBridge<UserCompClsT, LibTypesT>::userCompFromLibSelfCompPtr(_LibSelfCompPtr) [with UserCompClsT = {anonymous}::DummySink; LibTypesT = bt2::internal::SinkCompClsLibTypes; _LibSelfCompPtr = bt_self_component_sink*]' is inaccessible within this context
160 | SpecCompClsBridgeT::userCompFromLibSelfCompPtr(libSelfCompPtr)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
/home/smarchi/src/babeltrace/src/cpp-common/bt2/plugin-dev.hpp:62:26: note: declared here
62 | static UserCompClsT& userCompFromLibSelfCompPtr(const _LibSelfCompPtr libSelfCompPtr) noexcept
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
Change-Id: If7dabf6280f3d861854dd21fa92f785f7176bd5e
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11804
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Philippe Proulx [Fri, 16 Feb 2024 20:00:59 +0000 (15:00 -0500)]
cpp-common/bt2: add component class creation methods
Add `create()` methods to `CommonSourceComponentClass`,
`CommonFilterComponentClass` and `CommonSinkComponentClass`, allowing
the user to create component classes at run time from some class that
derives from `UserSourceComponent`, `UserFilterComponent` and
`UserSinkComponent`.
The user component class (`UserComponentT`) must provide a static member
`name` of type `const char *`. It can also provide static members named
`description` and `help`, also of type `const char *`.
Change-Id: I3bd550fd90a2a75d8154d29d00bf0bf4f9b1fd3e
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11817
Simon Marchi [Wed, 14 Feb 2024 16:09:27 +0000 (11:09 -0500)]
cpp-common/bt2: add C++ component class bindings
Add C++ bindings for component classes.
Similar to how C++ bindings for components work, the
`CommonComponentClass` type is implicitly constructible from the
specialized component class types, so that it's possible to pass a
`SourceComponentClass` to something expecting a `ComponentClass`, for
instance.
Get a component class' name, description or help with the methods of the
same name.
Change-Id: Ia6301f4b37f4f86036f6e09cc2aaf49d7028c6fc
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11803
Simon Marchi [Fri, 16 Feb 2024 03:53:01 +0000 (22:53 -0500)]
cpp-common/bt2: move user component class bases to `component-class-dev.hpp`
It will become possible to use these classes to create component classes
at runtime, not only in the context of plugins.
Change-Id: I3507a8025fa4e8af6bdb42f2be053dd43f3c2eaa
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11814
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Simon Marchi [Thu, 15 Feb 2024 21:17:55 +0000 (16:17 -0500)]
cpp-common/bt2: move component class bridges to `internal/comp-cls-bridge.hpp`
The bridges are going to be used when creating component classes at
runtime, not only in the context of plugins.
Change-Id: If6d04531ee660692d1a6eb84950a584530a23566
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11813
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Simon Marchi [Mon, 12 Feb 2024 22:07:35 +0000 (17:07 -0500)]
tests/lib: C++ify `conds/utils.cpp` a bit
Change `utils.cpp` to fit a bit more our C++ style.
- use an anonymous namespace
- use camel-case for functions
- use `bt2s::span` for the list of triggers
- declare functions as `noexcept`
I didn't update the contents of `utils.hpp`, because I expect this to
change in some following patches, while I expect `utils.cpp` to stay
pretty much as-is.
Change-Id: I9dc01a22b3e9ceb2d90cd35c9f6ca93d1afe248f
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11794
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Simon Marchi [Tue, 13 Feb 2024 03:46:02 +0000 (22:46 -0500)]
tests/lib: C++ify `conds/conds-triggers.cpp`
- use an anonymous namespace for local stuff
- use bt2 C++ bindings
- rename functions to camel case
- mark functions as `noexcept`
Change-Id: Id31e3703eb48662cc3090d57247fb16bcea0d7f8
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11797
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Simon Marchi [Tue, 13 Feb 2024 03:28:30 +0000 (22:28 -0500)]
tests/lib: C++ify `test-fields-bin.cpp`
- use the C++ bindings
- rename `test_string_clear` to `testStringClear`
- use an anonymous namespace
- declare testStringClear as `noexcept`
- use constexpr
I checked that the test still managed to catch the bug fixed in
0022a87819b0 ("Fix: clear_string_field(): set first character to 0").
Change-Id: I3631b22f9e70ea5db620ce0597d04e5035bfa91d
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11793
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Simon Marchi [Tue, 13 Feb 2024 03:26:22 +0000 (22:26 -0500)]
tests/lib: pass C++ wrapper types to `RunIn` callbacks
Pass C++ wrapper types to `RunInCompClsInitFunc`,
`RunInCompClsQueryFunc` and `RunInMsgIterClsInitFunc` instead of C
library types.
Adjust callers and callees in a trivial way.
Change-Id: I3d6fcee8e0239976483995affcd7e95fb5fa12ef
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11796
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Simon Marchi [Wed, 14 Feb 2024 16:14:07 +0000 (11:14 -0500)]
cpp-common/bt2: make `ConstComponentPorts::operator[](bt2c::CStringView)` return an `OptionalBorrowedObject`
The library functions that borrow ports by name return `NULL` when
no port with such name exist. Change
`ConstComponentPorts::operator[](bt2c::CStringView)` to return an
`OptionalBorrowedObject` to model that in C++.
Change-Id: I2fafb509622e324980b88b70735e7beeb25f7fb4
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11802
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Simon Marchi [Tue, 13 Feb 2024 16:00:46 +0000 (11:00 -0500)]
cpp-common/bt2: add const_cast when setting user data
If the user data type is specified as a const type,
`static_cast<void *>` will not work. Fix that by doing a static_cast to
`const void *` then a const_cast to `void *`.
Change-Id: Ic39c9c25da1899defe4edf8c8e800297fbf2fb2d
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11799
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Simon Marchi [Mon, 12 Feb 2024 21:17:51 +0000 (16:17 -0500)]
cpp-common/bt2: add missing return in `SelfComponentPort::data`
Change-Id: Ib381d8ee919206361f81721ca418b7fdba330c9c
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11792
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Simon Marchi [Wed, 14 Feb 2024 21:03:58 +0000 (16:03 -0500)]
cpp-common/bt2: add `SelfComponent::createClockClass`
Add the C++ binding to create a clock class from a self component.
Change-Id: I83bab751520458a7c39982df70a71ba214317428
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11810
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Simon Marchi [Mon, 12 Feb 2024 20:58:54 +0000 (15:58 -0500)]
cpp-common/bt2: add `SelfComponent::createTraceClass`
Add the C++ binding to create a trace class from a self component.
Change-Id: Iaa5ad98bb0dfce7ac8ab7d3c51446cf4ad387b29
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11791
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Simon Marchi [Mon, 12 Feb 2024 20:53:28 +0000 (15:53 -0500)]
cpp-common/bt2: add message creation methods to `SelfMessageIterator`
Add methods on `SelfMessageIterator` to create all possible kinds of
messages.
Change-Id: I44b5be4e0783affef619983530d8af619560569f
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11790
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Simon Marchi [Mon, 12 Feb 2024 20:39:59 +0000 (15:39 -0500)]
cpp-common/bt2: fix trivial-ish mistakes in plugin-dev.hpp
Fix a few problems that were found by exercising the `plugin-dev.hpp`
code a bit more.
⚾ Use public inheritance in `SinkCompClsBridge`.
⚾ Add return statement in happy path of
`SinkCompClsBridge::graphIsConfigured`.
⚾ Use `DataT&` as the parameter type to `_addOutputPort` and
`_addInputPort` methods, matching what
`Self*Component::add*Port` expects.
⚾ Call `_outputPortConnected` instead of `outputPortConnected` in
`UserSourceComponent::outputPortConnected`, which otherwise results
in infinite recursion.
Change-Id: Ieab12436c4b85b5a33195be0ea388b3f545f07cd
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11789
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Simon Marchi [Tue, 13 Feb 2024 17:13:01 +0000 (12:13 -0500)]
cpp-common/bt2: `User*Component`: pass query method data to user `_query` methods
Make `User*Component::query()` pass down the query method data down to
user methods.
Child classes of `UserSourceComponent`, `UserFilterComponent` and
`UserSinkComponent` can pass a template parameter to indicate the type
of query method data they wish to receive.
`UserComponent` defines a `QueryData` public member using the type
received as a template parameter. `CompClsBridge::query` uses this type
to cast the query method data, received from the lib as a `void *`, to
that type.
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Change-Id: If9f776dbaa723dd65391e3ea57c3067f53f52dc4
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11788
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Simon Marchi [Thu, 15 Feb 2024 03:12:39 +0000 (22:12 -0500)]
cpp-common/bt2: `CompClsBridge`: pass init method data to user component constructors
Make `CompClsBridge::init` pass the initialization method data (received
from the lib as a `void *`) down to the user component's constructor.
For convenience, user component classes can specify the type of the data
they expect to receive as a template parameter, sparing them of doing a
static_cast. This template parameter can be omitted, in which case it
defaults to `void`.
Change-Id: I6b64ea6d75d535d7f2f3b8d559bd2698c186f0ca
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11787
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Simon Marchi [Tue, 13 Feb 2024 16:50:10 +0000 (11:50 -0500)]
src/cpp-common: pass user message iterator class to `UserSourceComponent` and `UserFilterComponent`
🍎 Pass the user message iterator class type as template parameters to
`UserSourceComponent` and `UserFilterComponent`.
🍎 Make them set a public type `MessageIterator` with that.
🍎 Update the `BT_CPP_PLUGIN_*` macros to not take the message iterator
class type, but use `_userComponentClass::MessageIterator`
instead.
Change-Id: I7af3a1a088a61e5b83e4a4047f808435221352cc
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11800
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Simon Marchi [Mon, 12 Feb 2024 19:30:07 +0000 (14:30 -0500)]
cpp-common/bt2: add `CommonStringField::length` method
Add this method, which wraps `bt_field_string_get_length`.
Change-Id: Ie662e1fe84c56e6f3d48cadcd5f3c4d153ea108d
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11786
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Simon Marchi [Mon, 12 Feb 2024 19:29:15 +0000 (14:29 -0500)]
cpp-common: remove unused include
Remove some unused (according to clangd) includes. Add one IWYU pragma
to tell it to keep `fmt/format.h`, which is needed to make the
`format_as` function defined in that file work.
Change-Id: I9c4d716975e46bbfad0372aa7ede5f449868848f
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11782
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Simon Marchi [Mon, 12 Feb 2024 19:01:28 +0000 (14:01 -0500)]
tests/utils/python/tjson.py: print actual type when a type error occurs
Make `_check_type` output the actual type in addition to the expected
type. Example:
Before: # TypeError: `.[0]."cond-id"`: expecting a string value
After: # TypeError: `.[0]."cond-id"`: expecting a string value, got an array
Change-Id: I9615aa380b12fe5e7fd65b079840b779f9530f3a
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11781
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Simon Marchi [Mon, 12 Feb 2024 18:48:51 +0000 (13:48 -0500)]
tests/lib/conds/test.py: use `tjson`, add type annotations
Use `tests/utils/python/tjson.py` and add some types annotations to make
`tests/lib/conds/test.py` pyright-clean:
$ PYTHONPATH=/home/simark/src/babeltrace/tests/utils/python pyright tests/lib/conds/test.py
0 errors, 0 warnings, 0 informations
Change-Id: Ie7e233e51b5fef645f6ca2c23a66e8c81f00f2a8
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11780
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Simon Marchi [Thu, 15 Feb 2024 21:51:41 +0000 (16:51 -0500)]
common: remove unused things from common.{c,h}
All of these things appear to be unused in the project.
Change-Id: I6f6761a9679b067ec11f607311d7c7b6ee761485
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11812
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Simon Marchi [Sun, 11 Feb 2024 05:03:01 +0000 (00:03 -0500)]
tests/lib: remove some `Makefile.am`s
Move the content of all Makefiles under `tests/lib` to
`tests/lib/Makefile.am`.
Change-Id: I114ef3a534bafecd205f310891f2c90f3e40d334
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11779
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Simon Marchi [Thu, 8 Feb 2024 20:35:18 +0000 (15:35 -0500)]
flt.utils.muxer: remove msgTypeStr
Make {fmt} format the message type directly.
Change-Id: Id887079214992a346d13fcafbd048aa8af9d4457
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11768
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Philippe Proulx [Fri, 9 Feb 2024 19:32:50 +0000 (14:32 -0500)]
tests/utils/env.sh.in: remove `#!/bin/bash`, add a ShellCheck directive
`tests/utils/env.sh` is only meant to be sourced, never executed
directly, therefore the `#!/bin/bash` line is useless.
Add a ShellCheck shell directive to tell ShellCheck that this is (at
least) Bash code.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ieb9bd996e43e8609d1e3e7b7b3d614bd4db6f234
Simon Marchi [Thu, 8 Feb 2024 20:36:41 +0000 (15:36 -0500)]
cpp-common/bt2c: add `format_as` function for `bt2::MessageType`
Add a `format_as` that lets {fmt} format variables of type
`bt2::MessageType` directly. Re-use `bt_common_message_type_string` to
avoid duplicating that code.
Change-Id: I81152a152284b156535813fd8fa5d61a3dd7219f
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Simon Marchi [Thu, 8 Feb 2024 19:31:13 +0000 (14:31 -0500)]
bt2/setup.py.in: don't call get_cflags/get_ldshared unnecessarily
In our_get_config_vars(), we call get_cflags() and get_ldshared() even
if their result is not going to be used. Make the
`overridden_config_vars` dict hold references to the functions, and
invoke them as needed.
Change-Id: Ibad179b84fb06c4d7ae9bf1160ec38e903210f79
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Philippe Proulx [Fri, 9 Feb 2024 03:35:49 +0000 (22:35 -0500)]
tests/utils/env.sh.in: make it portable for Bash and Zsh
The syntax
${!varname:-}
isn't valid in Zsh.
To make it possible to source the generated `env.sh` interactively, make
this (more) portable.
Now _set_var_def() also sets if the variable is set but empty, but I
don't think it's an issue here.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I07d49199c403ac24d569d383fd8bde2cf5b668e6
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11769
Philippe Proulx [Fri, 9 Feb 2024 18:58:38 +0000 (13:58 -0500)]
tools/shellcheck.sh: use tabs
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I666cf63f2ca27c731896fb9d01ae3e5a23f4d6b4
Simon Marchi [Thu, 8 Feb 2024 19:25:32 +0000 (14:25 -0500)]
bt2/setup.py.in: improve legibility of our_get_config_vars a bit
This is a bit subjective, but avoid early returns / continue. I like
early returns when there is clearly one "happy" of "main" path in a
function, for instance for error handling or returning early because a
function is a no-op. But when handling different significant cases, I
prefer an explicit if/else. It makes the different code paths stand
out visually.
Change-Id: I484eb4ec7187ce3c889507e31349c3b4461f3fc7
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11764
Simon Marchi [Thu, 8 Feb 2024 21:12:56 +0000 (16:12 -0500)]
Revert "tests/utils/utils.sh: quote command name when running it"
This reverts commit
e612f2daa6b262796ca0750754142f0abd686f1d.
I believe that we want to do word splitting in these cases. My
`$BT_TESTS_CC_BIN` is "ccache gcc". Without word splitting, I get:
/home/smarchi/src/babeltrace/tests/utils/utils.sh: line 431: ccache gcc: command not found
Change-Id: I7443dbcf1a45672cf4c7fcb7e15e94e83e85a832
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11766
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Simon Marchi [Thu, 8 Feb 2024 19:14:45 +0000 (14:14 -0500)]
.editorconfig: handle .py.in files
Handle .py.in files the same as Python, so that editors use the proper
whitespace settings when editing `setup.py.in`.
Change-Id: Ic02716165d8c809ff152552fb7d9cc160c2435de
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11763
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Simon Marchi [Wed, 7 Feb 2024 16:28:53 +0000 (11:28 -0500)]
tests/lib: reorganize Makefile.am a bit
Regroup _SOURCES variables with the corresponding _LDADD ones.
Change-Id: Ib90b09688b5275789aa03d6de0a6c1584535f173
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11754
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Simon Marchi [Tue, 6 Feb 2024 19:50:42 +0000 (14:50 -0500)]
lib: remove unused includes
Remove some includes that clangd reports as unused. Add a few includes
to make up for includes that were used transitively, that were removed.
Change-Id: I5b38ab8af317198cd9043943cd955e3a4eeb2d19
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11752
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Simon Marchi [Tue, 6 Feb 2024 20:03:12 +0000 (15:03 -0500)]
lib: remove BT_ASSERT_COND_SUPPORTED check in graph/graph.h
This header file no longer uses pre-condition macros.
Change-Id: I1afd3a709560221dd67100a5a0beb653f79df6a3
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11751
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Simon Marchi [Mon, 27 Nov 2023 21:23:10 +0000 (16:23 -0500)]
Fix: lib: strengthen clock expectation check for no Unix epoch / no UUID case
When an iterator sees a clock class with an origin that is not the Unix
and has no UUID, it sets its clock expectation to
CLOCK_EXPECTATION_ORIGIN_OTHER_NO_UUID. In this mode, when validating
subsequent clock classes, it validates that the clock class' origin is
not the Unix epoch and that it has no UUID. This is too loose: an
iterator could send messages with two distinct clocks with unknown
origins and no UUID, and it would pass validation. However, these two
clock classes are not correletable.
Fix that by making the iterator remember which specific clock class
instance it saw first. Each subsequent message must have exactly that
clock class instance.
To be sure that a clock class an iterator has saved doesn't get freed,
and then a new one reallocated at the same address, the iterator takes a
strong reference to the clock class. This ensures that the saved clock
class at least outlives the iterator.
TODO: I would like to write a test for this
Change-Id: I339936b730fe2f4e64dbc58d56557ffcd23cce16
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11448
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Simon Marchi [Thu, 8 Feb 2024 03:15:37 +0000 (22:15 -0500)]
cpp-common/bt2c: remove lib-str.hpp
This is unused, and I think it will never be. If we need something like
this, it will likely be in the form of a `format_as` function used by
the `{fmt}` library.
Change-Id: I81e21d697f6b246c986c5c9126b1177a0d5bcb03
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11759
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Philippe Proulx [Fri, 10 Nov 2023 14:54:44 +0000 (09:54 -0500)]
configure.ac: don't make `tests/utils/env.sh` executable
It's only meant to be sourced, not executed directly.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I085c8e83ce9596336c0904a28b94e832e33665ab
Philippe Proulx [Fri, 10 Nov 2023 14:48:29 +0000 (09:48 -0500)]
run-in-py-utils-bt2-env.sh: rename `UTILSSH` variable -> `utils_sh`
Uppercase suggests this is an exported variable while it's local to the
script.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I5e0d0885b9b2668bd1347156c20d90c9421a9782
Philippe Proulx [Fri, 10 Nov 2023 14:46:47 +0000 (09:46 -0500)]
run-in-py-utils-bt2-env.sh: `${@}` -> `$@`
Curly braces not needed here.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I37ead8ae4b6a5f7ce450dbb976690ce53af36e24
Philippe Proulx [Fri, 10 Nov 2023 14:45:50 +0000 (09:45 -0500)]
run-in-py-utils-bt2-env.sh: update comment
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I33aed97ce0a22ffe0a106be088c951d04a9b22bb
Philippe Proulx [Fri, 10 Nov 2023 14:41:57 +0000 (09:41 -0500)]
run-in-py-utils-bt2-env.sh: remove unneeded quotes
Word splitting and globbing doesn't happen in those contexts.
Removing them makes the code easier to read.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I067b0a53098ed42f61ea45ec37fe1fa6b8ba4d2e
Philippe Proulx [Fri, 10 Nov 2023 14:40:37 +0000 (09:40 -0500)]
run-in-py-utils-bt2-env.sh: use the arg. count io. checking a string
More readable.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ib8f616f815c1d7d6ed44a6b6c412e419225aa8dd
Philippe Proulx [Fri, 10 Nov 2023 14:25:07 +0000 (09:25 -0500)]
run-in-py-utils-bt2-env.sh: update error message style
Also print to the standard error.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ia77de318ec01aa92a80c086df6f68c4240ba9101
Philippe Proulx [Fri, 10 Nov 2023 14:19:17 +0000 (09:19 -0500)]
run-in-py-utils-bt2-env.sh: use `[[ ... ]]` instead of `[` or `test`
For the same reason we're using this form in `utils.sh` (see
"tests/utils/utils.sh: use `[[ ... ]]` instead of `[` or `test`").
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I9284cff1dc7d64cfbcf2ad56e6a3d2bd3652fb6e
Philippe Proulx [Fri, 10 Nov 2023 14:17:17 +0000 (09:17 -0500)]
run-in-py-utils-bt2-env.sh: update usage and remove redundant comment
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I36137023cc7d9882d2695f5c9eb2dd8568463540
Philippe Proulx [Fri, 10 Nov 2023 14:09:21 +0000 (09:09 -0500)]
tests/utils: `run-python-bt2.sh` -> `run-in-py-env.sh`
This makes it consistent with the underlying Bash function name and
indicates that it doesn't need to run Python itself.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: If030bcea8349edc4d4ba1425a64778c08227101d
Philippe Proulx [Fri, 10 Nov 2023 21:36:27 +0000 (16:36 -0500)]
tests/utils/utils.sh: gen_mctf_trace() -> bt_gen_mctf_trace()
Adding the `bt_` prefix like other functions in `utils.sh`.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I682317576133727155778a79fc6716a83697e18e
Philippe Proulx [Fri, 10 Nov 2023 14:04:42 +0000 (09:04 -0500)]
tests/utils/utils.sh: run_python_bt2_test() -> bt_run_py_test()
Adding the `bt_` prefix like other functions in `utils.sh` and
shortening the rest.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I58caf29067a45495a1e80a9937d937a87b14c969
Philippe Proulx [Fri, 10 Nov 2023 14:03:15 +0000 (09:03 -0500)]
tests/utils/utils.sh: run_python_bt2() -> bt_run_in_py_env()
Adding the `bt_` prefix like other functions in `utils.sh` and renaming
the rest to indicate that it runs something in a specific environment,
not necessarily Python itself.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I5635f04f494c50e1955a27adaae28f964c336bf3
Philippe Proulx [Fri, 10 Nov 2023 13:59:49 +0000 (08:59 -0500)]
tests/utils/utils.sh: run_python() -> bt_run_in_py_utils_env()
Adding the `bt_` prefix like other functions in `utils.sh` and renaming
the rest to indicate that it runs something in a specific environment,
not necessarily Python itself.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I011c837857eb6d2b08f0c0064d399fd3acc2b89d
Philippe Proulx [Fri, 10 Nov 2023 05:41:41 +0000 (00:41 -0500)]
tests/utils/utils.sh: remove redundancy when setting def. var. values
This patch removes more redundancy in `utils.sh` by using a function
which sets a variable by name if it's empty and exports it.
This makes the file less error-prone: the variable name is written just
once, making it safer to add more.
The
export "${varname?}"
form is to make ShellCheck happy, even if a simple `export $varname`
would perfectly work in this context.
The function is unset when it's not needed anymore to avoid polluting
the scope of whatever sources `utils.sh`.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I6e25aa557f4d09f8129121b76b8b3a860ba3ed29
Philippe Proulx [Fri, 10 Nov 2023 05:24:48 +0000 (00:24 -0500)]
tests/utils/utils.sh: aerate the code
Have newlines above and below declarations and blocks to make the code
more readable.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: If74eff4e029ab6fb92383bd2e2a2a12f77b913ff
Philippe Proulx [Fri, 10 Nov 2023 05:11:57 +0000 (00:11 -0500)]
tests/utils/utils.sh: remove unneeded curly braces around var. names
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I459172a3bec08534c69c3a7164f2f56d28f74564
Philippe Proulx [Fri, 10 Nov 2023 05:01:54 +0000 (00:01 -0500)]
tests/utils/utils.sh: remove unneeded quotes
Word splitting and globbing doesn't happen in those contexts.
Removing them makes the code easier to read.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I50f0a8a7c1190b81a1e97933e5fbc056d36def7f
Philippe Proulx [Fri, 10 Nov 2023 04:54:58 +0000 (23:54 -0500)]
tests/utils/utils.sh: _set_vars_srcdir_builddir(): use `&>`
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ibb84b1411c457a40f678cbdc6ae0d033215d657a
Philippe Proulx [Fri, 10 Nov 2023 04:47:14 +0000 (23:47 -0500)]
tests/utils/utils.sh: use `[[ ... ]]` instead of `[` or `test`
Even if `[` and `test` are Bash built-ins for POSIX shell backward
compatibility, `[[` has more features, and since we're using it at least
at once place, it makes sense to always use it in my opinion.
Also use `==` instead of `=`, the latter only existing for POSIX shell
backward compatibility, the former being like pretty much all the other
programming languages we use.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ic3268e8d544bbbdf8f013ca3ca0659c4bc699d6d
Philippe Proulx [Fri, 10 Nov 2023 04:36:37 +0000 (23:36 -0500)]
tests/utils/utils.sh: gen_mctf_trace(): use an array for the command line
This removes the redundancy to both print and run the command line.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I9100aa02c221e3699de726668a4de1d6b65ec2d9
Philippe Proulx [Fri, 10 Nov 2023 04:35:02 +0000 (23:35 -0500)]
tests/utils/utils.sh: gen_mctf_trace(): use `echo` instead of `diag`
This makes gen_mctf_trace() independent from needing `tap.sh` or not.
It's like what we do in bt_cli().
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I8074f47309e3d02b6e533ae4e00fdf3edaa729b0
Philippe Proulx [Fri, 10 Nov 2023 04:32:47 +0000 (23:32 -0500)]
tests/utils/utils.sh: use `+=` instead of expanding the same variable
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I2843b2629e21bb645bd793a127eeaef64110723f
Philippe Proulx [Fri, 10 Nov 2023 04:30:06 +0000 (23:30 -0500)]
tests/utils/utils.sh: check_coverage() -> _bt_tests_check_coverage()
Make this function "private" (by name) as it's not intended that
whatever sources `utils.sh` use it directly (run_python_bt2_test() uses
it if `BT_TESTS_COVERAGE` is `1`).
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I6e75945eae067c08d6c8f2a3711b4c177608c3d1
Philippe Proulx [Fri, 10 Nov 2023 04:28:28 +0000 (23:28 -0500)]
tests/utils/utils.sh: bt_grep_ok(): only define if `SH_TAP` is `1`
This function uses ok() which comes from `tap.sh` which `utils.sh`
only sources if `SH_TAP` is `1`.
Therefore it makes no sense to run or even define this function if the
intention of whatever sources `utils.sh` isn't to output TAP directly.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ia59ceadc9b74b2a2c5201def51d340d9050d944e
Philippe Proulx [Fri, 10 Nov 2023 04:25:55 +0000 (23:25 -0500)]
tests/utils/utils.sh: bt_diff_details_ctf_single(): remove unneeded `expected_stderr_file` var.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I565c108061b223404ab51bc5a2a0ad6da08fe7d5
Philippe Proulx [Fri, 10 Nov 2023 04:24:43 +0000 (23:24 -0500)]
tests/utils/utils.sh: bt_diff_cli(): return directly, don't use `ret`
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I60257da865052146ca3b1bb3b10bcea02f4ff1d2
Philippe Proulx [Fri, 10 Nov 2023 04:22:01 +0000 (23:22 -0500)]
tests/utils/utils.sh: bt_diff(): remove useless `ret` var. and `return`
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I8970f29a926fbf7c707d3bf6a6516a36e6995679
Philippe Proulx [Fri, 10 Nov 2023 04:20:46 +0000 (23:20 -0500)]
tests/utils/utils.sh: use backticks to quote in printed messages
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I75a0e53663d96b2e6aea02d765fd4b3844db864c
Philippe Proulx [Fri, 10 Nov 2023 04:19:24 +0000 (23:19 -0500)]
tests/utils/utils.sh: gen_mctf_trace(): use `local -r` when possible
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Id0b1f21a582c6742e153f869c917238867db2d61
Philippe Proulx [Fri, 10 Nov 2023 04:41:04 +0000 (23:41 -0500)]
tests/utils/utils.sh: run_python_bt2_test(): make `python_exec` var. local
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I05f7600cd60ba849ab20617d6354ddf07db4afa0
Philippe Proulx [Fri, 10 Nov 2023 04:19:10 +0000 (23:19 -0500)]
tests/utils/utils.sh: run_python_bt2_test(): use `local -r` when possible
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I02bda233ecb271078c443cc4fdd53022dfdcfa90
Philippe Proulx [Fri, 10 Nov 2023 05:21:54 +0000 (00:21 -0500)]
tests/utils/utils.sh: run_python_bt2_test(): remove useless `test_runner_args` var.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ib2122628f627ba89e3e9f56597711c8498a8ea86
Philippe Proulx [Fri, 10 Nov 2023 04:18:21 +0000 (23:18 -0500)]
tests/utils/utils.sh: run_python_bt2(): use `local -r` when possible
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ia6f52dd7d41b84f567f0ec28bbe61d6c30d7caf2
Philippe Proulx [Fri, 10 Nov 2023 04:16:22 +0000 (23:16 -0500)]
tests/utils/utils.sh: bt_grep_ok(): use `local -r` when possible
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ifbe0ccbd2c42d929331eb87e5f7743083d9c1a1a
Philippe Proulx [Fri, 10 Nov 2023 04:15:54 +0000 (23:15 -0500)]
tests/utils/utils.sh: bt_diff_details_ctf_gen_single(): use `local -r` when possible
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I18c910ca25a680fde94528dbe3bf11f908b77b77
Philippe Proulx [Fri, 10 Nov 2023 04:15:02 +0000 (23:15 -0500)]
tests/utils/utils.sh: bt_diff_details_ctf_single(): use `local -r` when possible
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Iaf6229b868111eb0870c023ebd4e030b28d01c2c
Philippe Proulx [Fri, 10 Nov 2023 04:14:34 +0000 (23:14 -0500)]
tests/utils/utils.sh: bt_diff_cli(): use `local -r` when possible
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I87b7d665cfe7c1ae55afe85a3f743e3e15c03f51
This page took 0.04703 seconds and 4 git commands to generate.