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
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
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
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>
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>
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>
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>
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: 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>
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>
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>
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>
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>
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>
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>
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>
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>