[PATCH 1/4] selftests: livepatch: Introduce _remove_mod function
From: Marcos Paulo de Souza
Date: Sun May 24 2026 - 19:50:59 EST
This new function will be used in the next patch to remove loaded
modules when a testcase fails.
Signed-off-by: Marcos Paulo de Souza <mpdesouza@xxxxxxxx>
---
tools/testing/selftests/livepatch/functions.sh | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/livepatch/functions.sh b/tools/testing/selftests/livepatch/functions.sh
index 2bc50271729c..3ec0b7962fc5 100644
--- a/tools/testing/selftests/livepatch/functions.sh
+++ b/tools/testing/selftests/livepatch/functions.sh
@@ -241,9 +241,10 @@ function load_failing_mod() {
log "$ret"
}
-# unload_mod(modname) - unload a kernel module
+# _remove_mod(modname) - Internal function to remove a loaded module.
+# Use unload_mod() instead, which also updates TEST_MODS tracking.
# modname - module name to unload
-function unload_mod() {
+function _remove_mod() {
local mod="$1"
# Wait for module reference count to clear ...
@@ -261,6 +262,14 @@ function unload_mod() {
die "failed to unload module $mod (/sys/module)"
}
+# unload_mod(modname) - unload a kernel module
+# modname - module name to unload
+function unload_mod() {
+ local mod="$1"
+
+ _remove_mod "$mod"
+}
+
# unload_lp(modname) - unload a kernel module with a livepatch
# modname - module name to unload
function unload_lp() {
--
2.54.0