From 3821394295d4cf08b696dbc29e9d44d20f657ae1 Mon Sep 17 00:00:00 2001 From: Kienan Stewart Date: Wed, 19 Feb 2025 15:23:49 -0500 Subject: [PATCH] tests: Avoid failing on loaded modules when kernel tests are skipped MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit In the future I would like to be able to run lttng-sessiond of the container host for various reasons. When loaded on the host as the root user, the lttng-modules are loaded when available - and this is visible inside the containers which share the kernel. Some tests validate that the modules are unloaded even if the kernel testing has been skipped. The second part of this change limits the possible PID search space to those started by the current user. This avoids situations where a non-privileged user tries to kill the lttng-sessiond run by root. Change-Id: I0cec2e385f37c62d8961488751805b1248ce2687 Signed-off-by: Kienan Stewart Signed-off-by: Jérémie Galarneau --- tests/utils/utils.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/utils/utils.sh b/tests/utils/utils.sh index 190199a9f..69d8c8936 100644 --- a/tests/utils/utils.sh +++ b/tests/utils/utils.sh @@ -211,7 +211,7 @@ function lttng_pgrep () local full_command_no_argument local command_basename - possible_pids=$($PGREP -f "$pattern") + possible_pids=$($PGREP -f "$pattern" -u "${UID}") if [ -z "$possible_pids" ]; then return 0 fi @@ -486,6 +486,7 @@ function _lttng_modules_loaded_opt local ret local message="%d LTTng modules loaded, expected count " + check_skip_kernel_test 1 && return if [[ "${fail_when_present}" -eq "1" ]] ; then message+="= 0" else -- 2.39.5