tests: add check_skip_kernel_test to check root user and lttng kernel modules The current tests will run both userspace and kernel testing. Some of use cases only use lttng for one kind of tracing on an embedded device (e.g. userspace), so in this scenario, the kernel modules might not install to target rootfs, the test cases would be fail and exit. Add LTTNG_TOOLS_DISABLE_KERNEL_TESTS to skip the lttng kernel features test, this flag can be set via "make": make check LTTNG_TOOLS_DISABLE_KERNEL_TESTS=1 When this flag was set, all kernel related testcases would be marked as SKIP in result. Since the the LTTNG_TOOLS_DISABLE_KERNEL_TESTS was checked in function check_skip_kernel_test, lots of testcases also need to check root permission, so merging the root permission checking into check_skip_kernel_test. Change-Id: I49a1f642a9869c21a69e0186c296fd917bd7b525 Signed-off-by: Xiangyu Chen <xiangyu.chen@windriver.com> Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
lttng: enable-event: use the terminology of the documentation Rework most of the human-readable messages of the enable-event to use the terminology used throughout the online documentation and the man pages. Some clean-ups are also done to follow the rest of the project's conventions, such as quoting user input with back-ticks, not ending messages with a period, etc. Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: I00d89d6e3c32ccbde60081ef427a099fb8cd206e
Wrap main functions to handle uncaught exceptions Coverity reports multiple instances where formatting facilities can throw (e.g. invalid format string). A wrapper to handle formatting exceptions is added in a follow-up change, but it is a good practice to catch exceptions at the top level nonetheless. Reported-by: Coverity Scan Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: Ie55af338b9ef1f7d6e8825055cfc2e7037cdd80e
Provide an idiomatic c++ interface for action lists Replace for_each macros with the use of an iterator. It is done by using a random_access_container_wrapper util which is intended to wrap random_access containers implemented in C. Change-Id: I1b22725b7335f267c9b2d02fc65f9375baf37426 Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
actions: list: Add `for_each_action_{const, mutable}()` macros Accessing all the inner actions of a action list in a loop is a common access pattern. This commit adds 2 `for_each` macros to iterate over all elements either using a const or a mutable pointer. Add a few unit tests for the list action to test these macros. Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: I9aff0b81e1f782b5d20c3fcb82ee7028da8dd810
Tests: fix: list_triggers_cli: kallsyms contains prefixed symbols The test_list_triggers_cli test fails with: # Listing event-rule-matches kernel probe ./tests/regression/tools/trigger/test_list_triggers_cli: line 808: [[: 0xffffffffc1fca020 ffffffffc1fca030: syntax error in expression (error token is "ffffffffc1fca030") ./tests/regression/tools/trigger/test_list_triggers_cli: line 813: 0xffffffffc1fca020 ffffffffc1fca030 - 0xffffffffc1fca0c0 ffffffffc1fca0b0 : syntax error in expression (error token is "ffffffffc1fca030 - 0xffffffffc1fca0c0 ffffffffc1fca0b0 ") This is due to the fact that /proc/kallsyms now contains prefixed symbols (e.g. `__pfx_lttng_channel_enable`) which cause the test to fail since the grep invocation doesn't expect more than one match. Matching the begin/end of the "word" (or rather, function name) allows us to check for exact matches only. https://github.com/torvalds/linux/commit/9f2899fe36a623885d8576604cb582328ad32b3c Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: Ifc04757719c733caf55c8eea447e18a2246a9f49
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>
clang-tidy: add most bugprone warnings Most of the changes proposed by clang-tidy are explicit checks for the result of strcmp() and adding parentheses for all macro parameters. Change-Id: I6ce7384b6d96035454d5456ac920becbf2882e65 Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
clang-tidy: add Chrome-inspired checks Add the checks used by the Chrome project. Most of these changes were produced and applied by clang-tidy. Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: I4058dafbdef00e81ac04f202fdfe377384a99e6b
Add a basic .clang-tidy file and fix typedef warnings This initial .clang-tidy file only enforces the use of 'using' instead of 'typedef'. Note that a second .clang-tidy is added to the filter sub-folder to disable checks against generated code. The entire tree can be checked by running `run-clang-tidy` after generating a compilation command database. I personally use `bear` to generate `compile_commands.json`. $ ./configure $ bear -- make -j$(nproc) $ run-clang-tidy -fix Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: I074b6f2724e1af9a2df311e07a2fcdacb689bcf5
Run clang-format on the whole tree Generated by running: find -not \( -path "./src/vendor*" -prune \) -iname "*.h" -o -iname "*.hpp" -o -iname "*.c" -o -iname "*.cpp" -exec clang-format -i {} \; Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: I9557e7d84e305187475ef88124857cf2f438bbb1
port: add support for BSD mktemp Use '-t' which is portable instead of the GNU specific '--tmpdir'. Change-Id: I430af6b96c27c2766a2cc4b5574af8563297d717 Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Tests: fix: leak of trigger in trigger listing tests ==1480456==ERROR: LeakSanitizer: detected memory leaks Direct leak of 112 byte(s) in 1 object(s) allocated from: #0 0x7fdb9260cfb9 in __interceptor_calloc /usr/src/debug/gcc/libsanitizer/asan/asan_malloc_linux.cpp:154 #1 0x7fdb9242348d in zmalloc_internal ../../src/common/macros.hpp:60 #2 0x7fdb924295a9 in lttng_trigger* zmalloc<lttng_trigger>() ../../src/common/macros.hpp:89 #3 0x7fdb92423dbe in lttng_trigger_create /home/jgalar/EfficiOS/src/lttng-tools/src/common/trigger.cpp:58 #4 0x56304832331f in register_trigger /home/jgalar/EfficiOS/src/lttng-tools/tests/regression/tools/trigger/utils/register-some-triggers.cpp:24 #5 0x5630483233f1 in register_trigger_action_list_notify /home/jgalar/EfficiOS/src/lttng-tools/tests/regression/tools/trigger/utils/register-some-triggers.cpp:46 #6 0x5630483239a0 in test_session_rotation_conditions /home/jgalar/EfficiOS/src/lttng-tools/tests/regression/tools/trigger/utils/register-some-triggers.cpp:246 #7 0x563048323d4d in main /home/jgalar/EfficiOS/src/lttng-tools/tests/regression/tools/trigger/utils/register-some-triggers.cpp:309 #8 0x7fdb91c6630f in __libc_start_call_main (/usr/lib/libc.so.6+0x2d30f) Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: Ie163989a70f65f9c2c4e93c36cc9fc6ba6bdeeb5
Rename C++ header files to .hpp Rename all C++ header files (include/**/*-internal.h, src/**/*.h except argpar and msgpack, some headers in tests) to have the .hpp extension. Doing so highlights that we include some C++ header files in some test files still compiled as C. This is ok for now, as the files they include don't actually contain C++ code incompatible with C yet, but they could eventually. This is something we can fix later. Change-Id: I8bf326b6b2946a3e26704f3ef3ac5831bbe9bc26 Signed-off-by: Simon Marchi <simon.marchi@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Prepare for '-Wmissing-field-initializers' In preparation for '-Wextra' Change-Id: Ic593491ad44c1254f158b19659c3b9567d180ad1 Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Tests: Fix: test_list_triggers_cli: support in-kernel builtin lttng-modules This commit changes the grep call to remove the [lttng_tracer] string from the pattern. When building the lttng modules directly in the kernel there is not mention of [lttng_tracer]. Furthermore, the symbol type "t" is "T" in my test VM. The difference may be due to the builtin nature of lttng on this VM. Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: I046905dc51524c23ad3671b66614b86a084ef8e2 Depends-on: lttng-ust: If1f29dd64538bc5979d3e89aa5cca3be4e41046f
src/common: use single Makefile for parallel builds Use a single Makefile in 'src/common' as it contains multiple subdirectories with a small number of objects to compile. This allows faster parallel builds since parallelism in automake is applied per Makefile. There is anectodal evidence of a 25 seconds improvement to the build process on a 36 core machine. Change-Id: If2ce266050e345d58b00bf65b574ccf5168f28f1 Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>