]> git.lttng.org Git - lttng-tools.git/commitdiff
tests: Add helper functions to validate if lttng modules are loaded
authorKienan Stewart <kstewart@efficios.com>
Thu, 4 Jul 2024 13:25:51 +0000 (09:25 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 29 Nov 2024 22:32:33 +0000 (17:32 -0500)
Observed issue
==============

Regression tests exercising kernel modules don't validate before and
after the test execution that there are no LTTng kernel modules
loaded.

Solution
========

Add convenient tap helper functions that may be used by shell TAP
tests.

Known drawbacks
===============

None.

Change-Id: I8244358137c2d049ed72e6dc7d9290cb9dda10e3
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
tests/utils/utils.sh

index f9f545bd4c3ab3f9e44ff590c9aeb8a330c8066a..8ffc424f4c9dd101681d1c110d739987288ecf83 100644 (file)
@@ -470,6 +470,38 @@ function _run_babeltrace_cmd ()
        fi
 }
 
+function _lttng_modules_loaded_opt
+{
+       local fail_when_present="${1}"
+       local module_count
+       local ret
+       local message="%d LTTng modules loaded, expected count "
+
+       if [[ "${fail_when_present}" -eq "1" ]] ; then
+               message+="= 0"
+       else
+               message+="> 0"
+       fi
+
+       grep -q -E '^lttng' '/proc/modules'
+       ret="${?}"
+       module_count="$(grep -E '^lttng' '/proc/modules' | wc -l)"
+
+       is "${ret}" "${fail_when_present}" "$(printf "${message}" "${module_count}")"
+}
+
+# Pass if any lttng modules are loaded
+function lttng_modules_loaded_ok()
+{
+       _lttng_modules_loaded_opt 0
+}
+
+# Fail if any lttng modules are loaded
+function lttng_modules_loaded_fail()
+{
+       _lttng_modules_loaded_opt 1
+}
+
 # Run the lttng binary.
 #
 # The first two arguments are stdout and stderr redirect paths, respectively.
This page took 0.031494 seconds and 4 git commands to generate.