summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/livepatch/functions.sh
diff options
context:
space:
mode:
Diffstat (limited to 'tools/testing/selftests/livepatch/functions.sh')
-rw-r--r--tools/testing/selftests/livepatch/functions.sh26
1 files changed, 26 insertions, 0 deletions
diff --git a/tools/testing/selftests/livepatch/functions.sh b/tools/testing/selftests/livepatch/functions.sh
index 8ec0cb64ad94..a65b7b1ac8ad 100644
--- a/tools/testing/selftests/livepatch/functions.sh
+++ b/tools/testing/selftests/livepatch/functions.sh
@@ -4,6 +4,8 @@
# Shell functions for the rest of the scripts.
+export LC_ALL=C
+
MAX_RETRIES=600
RETRY_INTERVAL=".1" # seconds
SYSFS_KERNEL_DIR="/sys/kernel"
@@ -124,6 +126,20 @@ function set_ftrace_enabled() {
echo "livepatch: kernel.ftrace_enabled = $result" > /dev/kmsg
}
+# ftrace_disable_supported() - probe whether kernel.ftrace_enabled=0
+# can still disable ftrace on this kernel. Newer kernels deprecate
+# the knob and always refuse the write with -EOPNOTSUPP.
+function ftrace_disable_supported() {
+ local orig result
+
+ orig=$(sysctl --values kernel.ftrace_enabled)
+ sysctl -q kernel.ftrace_enabled=0 &> /dev/null
+ result=$(sysctl --values kernel.ftrace_enabled)
+ sysctl -q "kernel.ftrace_enabled=$orig" &> /dev/null
+
+ [[ "$result" == "0" ]]
+}
+
function cleanup() {
pop_config
}
@@ -339,6 +355,16 @@ function check_result {
fi
}
+# does_sysfs_exist(modname, attr) - check sysfs attribute existence
+# modname - livepatch module creating the sysfs interface
+# attr - attribute name to be checked
+function does_sysfs_exist() {
+ local mod="$1"; shift
+ local attr="$1"; shift
+
+ [[ -f "$SYSFS_KLP_DIR/$mod/$attr" ]]
+}
+
# check_sysfs_rights(modname, rel_path, expected_rights) - check sysfs
# path permissions
# modname - livepatch module creating the sysfs interface