Clean-up: run format-cpp on the tree The original re-format commit missed a number of files that were caught by format-cpp. Hopefully this is the last large reformat commit for a while. Change-Id: I493ee6d9fe6187e0bd087c68ed346af69c929c1e Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Force usage of assert() condition when NDEBUG is defined Reuse the BT2 approach to force the usage of the assertion condition even when assert() are removed by the NDEBUG define. See `BT_USE_EXPR()` macro and documentation in Babeltrace commit[0]: commit 1778c2a4134647150b199b2b57130817144446b0 Author: Philippe Proulx <eeppeliteloop@gmail.com> Date: Tue Apr 21 11:15:42 2020 -0400 lib: assign a unique ID to each pre/postcond. and report it on failure 0: https://github.com/efficios/babeltrace/commit/1778c2a4134647150b199b2b57130817144446b0 Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: I3844b6ae7e95952d90033898397ac936540b785c
Fix: tests: base notification client: unchecked sscanf return value CID 1407934 (#2 of 2): Unchecked return value (CHECKED_RETURN) 8. check_return: Calling sscanf without checking return value (as is done elsewhere 17 out of 19 times). Reported-by: Coverity Scan Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: Ifcef490aa15aea8ae4846553fbc63c596583d274
Rename action group to action list This is necessary to convey that the `group` an ordered sequence of actions. We use the term `list` to put an emphasis on the ordered nature of the group. Files rename follows. Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: Idb85d8ca5b60947d8dc3d43d98c8d915bf34c3f2
Tests: fix: unchecked sscanf return value 1407934 Unchecked return value If the function returns an error value, the error value may be mistaken for a normal value. In parse_arguments: Value returned from a function is not checked for errors before being used (CWE-252) Reported-by: Coverity Scan Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: I7733e88ea6af6313379bd8d4ca131cd243cda401
Fix: sessiond: notification: use after free of trigger object Background ========== * Clients can subscribe to certain specific conditions (e.g. buffer usage) using the `lttng_notification_channel_subscribe()` function. * This subscription is only useful once a trigger with that condition AND at least one notify action is registered. * The sessiond keeps a list for client subscribed to each registered condition. * More than one trigger with the same condition may be registered the sessiond at the same time if they have different actions. Issue ===== Currently, when registering a trigger (T1) the sessiond looks if there is already a client list for the condition of this trigger. If not, the sessiond links the newly created client list object to that trigger T1 by keeping a pointer to it. This means that if another trigger (T2) is registered with the same condition (but a different name, or different actions) it will reuse the same client list object and use the pointer to the T1. This causes problems if T1 is unregistered before T2. In that case, the pointer to T1 in the client list object is pointing to a deallocated trigger object. This issue is not encountered with the current test suite, namely the `test_notification_multi_app` test case, because triggers with the same condition also had the same action, so they are considered identical and are not registered. This issue was first witnessed when adding a trigger name comparison in the `lttng_trigger_is_equal()` function. Fix === Change the client list object so that it has its own copy of the condition and a list of dependent triggers. Each trigger with that condition has a reference on this client list object. When unregistering a trigger, the notification thread removes it for the client list's triggers list and put its reference on the client list object. Tests ===== This commit adds a parameter to the base_client that dictates if the notify action should be in a group. This is a trick to create triggers that are not equal but have the same behaviour. The `test_notification_multi_app` test case is modified to turn on this option every other trigger registration. Semi-related cleanups ===================== * Merge `notification_client_list_create()` and `publish_notification_client_list()` functions since they are used together anyway. This removes the need to call `notification_client_list_put()` at the end of the `_register_trigger()` function * Rename `trigger_applies_to_client()` to `condition_applies_to_client()`. Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: I3ebb90a1a64236a440a085e6fc1b82726a0e5af9
Make parse_arguments static in base_client.c Fixes: CC base_client.o /home/smarchi/src/lttng-tools/tests/regression/tools/notification/base_client.c:60:5: error: no previous declaration for ‘parse_arguments’ [-Werror=missing-declarations] int parse_arguments(char **argv) { ^~~~~~~~~~~~~~~ Signed-off-by: Simon Marchi <simon.marchi@efficios.com> Change-Id: I4e431009d6e174eaadd82d206f9bedde9efdd30b Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
tests: Move to kernel style SPDX license identifiers The SPDX identifier is a legally binding shorthand, which can be used instead of the full boiler plate text. See https://spdx.org/ids-how for details. Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Change-Id: I89cd4b4b7440f71f52426a5508252932bb46e796 Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Fix: circular inclusion of lttng.h results in warning The circular inclusion of lttng.h, which includes all public headers, from condition.h results in the following warning for users of the API: warning: ‘struct lttng_evaluation’ declared inside parameter list will not be visible outside of this definition or declaration Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Test: kernel testing for notification Perform notification tests on both domains. Scenarios where low notifications are wanted need further synchronization since multiple low notifications can be sent between resume_consumer and the lttng stop command. This problem can be addressed by suspending the generation of events. This is achieved by the use of signal-aware background shells and the use of lttng-test kernel module or gen-ust-events as events generator. These background shells are controlled by signal SIGUSR1 and provide their states via a state file. If the file is present the application is suspended and does not generate events, otherwise events are generated. Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Fix: notification test: resources leak and return handling Fixes CID #1375913, 1375912, 1375911 1375910 1375909 1375908 Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Tests: regression testing for notification API This test suite includes tests for low and high buffer usage conditions, triggers, and multi application client scenarios. Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>