Tests: add kernel test into the `make check` test suite. The Jenkins CI mostly run the `make check` suite. Only the Lava base CI run the root_regression test suite. Most of those test can be run on `make check` without incurring any major extra time. Only `regression/tools/streaming/test_high_throughput_limits` is left in root_regression since it is currently "unreasonable" in term of the time it takes to run. This could be tackled another time. Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: I3d59705e84549c2a1840cf96a7723396e2e0c402
Tests: remove test_notification_kernel from root_regression test_notification_kernel no longer exists; its content was spread into other notification tests. Remove it from the root_regression test list. Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: I69027df4640f4d1265c6f3d82dea7734b3f421c7
Prevent channel buffer allocation larger than memory Background ========== Until recently (before lttng-modules commit 1f0ab1e) it was possible to trigger an Out-Of-Memory crash by creating a kernel channel buffer larger than the currently usable memory on the system. The following commands was triggering the issue on my laptop: lttng create lttng enable-channel -k --subbuf-size=100G --num-subbuf=1 chan0 The lttng-modules commit 1f0ab1e adds a verification based on an estimate to prevent this from happening. Since this kernel tracer sanity check is based on an estimate, it would safer to do a similar check on the session daemon side. Approach ======== Verify that there is enough memory available on the system to do all the allocations needed to enable the channel. If the available memory is insufficient for the buffer allocation, return an error to the user without trying to allocate the buffers. Use the `/proc/meminfo` procfile to get an estimate of the current size of available memory (using `MemAvailable`). The `MemAvailable` field was added in the Linux kernel 3.14, so if it's absent, fallback to verifying that the requested buffer is smaller than the physical memory on the system. Compute the size of the requested buffers using the following equation: requested_memory = number_subbuffer * size_subbuffer * number_cpu The following error is returned to the command line user: lttng enable-channel -k --subbuf-size=100G --num-subbuf=1 chan0 Error: Channel chan0: Not enough memory (session auto-20181121-161146) Side effect =========== This patch has the interesting side effect to alerting the user with an error that buffer allocation has failed because of memory availability in both --kernel and --userspace channel creation. Drawback ======== The fallback check on older kernels is imperfect and is only to prevent obvious user errors. Note ==== In the future, there might be a need for a way to deactivate this check (by using an environment variable) if a case arises where `/proc/meminfo` doesn't accurately reflect the state of memory for a particular use case. Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Implement userspace-probe regression tests This adds regression testcases for the following userspace probe features and should-fail scenarios. Features: * ELF function location tracing works, * ELF C++ mangled function and method location tracing works, * SDT tracepoint location tracing works, * Implicit location type defaults to ELF location, * Binary found $PATH, * Binary found using full path, * Binary with colon in file name, * Disabling of all location types, * Listing of all location types, * Saving and loading of all location types, * SDT probe with one or more callsites, * SDT probe with arguments, * SDT probe in shared object, * SDT probe in dlopen()ed and ldpreload()ed shared object. Should-fail: * Target binary does not exist, * Target binary not ELF file, * ELF symbol not found in target binary, * ELF symbol not a function, * SDT provider name not found, * SDT probe name not found, * SDT probe guarded by a semaphore. We also make sure to disable testcases when the necessary files/tools for them are not found: * Disables C++ testcases if no C++ compiler is found. * Disables SDT testcases if the Systemtap header files are not found. This is tested by trying to compile a simple C program with a SDT probe. If it fails, it will only disable the testcases and not the feature since the SDT userspace probe feature does not use this header for parsing. Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com> Signed-off-by: Erica Bugden <ebugden@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Tests: Add callstack contexts tests Tests callstack-user and callstack-kernel contexts by tracing with those contexts an application that calls multiple functions in chain before executing a system call. callstack-user addresses are tested against the output of coreutils' addr2line. callstack-kernel addresses are tested against the addresses of kernel symbols available in the /proc/kallsyms procfile. Both these tests need to be run by root because those contexts are made available by the kernel tracer. The callstack-kernel test also need to access /proc/kallsyms. Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Test for lttng-logger Basic test to write in /proc/lttng-logger and /dev/lttng-logger and ensure we have the right amount of events in the trace resulting trace. We also test the 1024 characters limit for the payload. Signed-off-by: Julien Desfossez <jdesfossez@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Rename the "metadata regenerate" command to "regenerate metadata" Prepare the deprecation of the "metadata regenerate" command since we need to regenerate the statedump as well, so it is more convenient to have one command to regenerate various session's attributes. Signed-off-by: Julien Desfossez <jdesfossez@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Test for select, poll and epoll syscall overrides This test for root_regression checks if the syscall overrides for select, pselect6, poll, ppoll, epoll_ctl, epoll_wait and epoll_pwait work as expected on arm and x86 (32 and 64-bit). There are 11 test cases that check for normal and abnormal behaviour. If the test system has the Babeltrace python bindings, the test validates the content of the events, otherwise only the presence of the generated events is checked. We also check if kernel OOPS, WARNING or BUG were generated during the test. Signed-off-by: Julien Desfossez <jdesfossez@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Fix: tests: skip UST perf tests if not root Some distributions like Debian (e.g. Debian kernel 4.1.0-2-amd64) have some grsecurity options enabled, such as CONFIG_GRKERNSEC_PERF_HARDEN. Unfortunately, this option makes it impossible to use the SW page-fault perf event as a normal user. It only leaves some HW events. However, we can only use SW events within virtual machines. Therefore, only run this test as root for now until we find a better approach. Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>