]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
selftests: livepatch: Introduce does_sysfs_exist function
authorMarcos Paulo de Souza <mpdesouza@suse.com>
Mon, 4 May 2026 18:34:44 +0000 (15:34 -0300)
committerPetr Mladek <pmladek@suse.com>
Wed, 6 May 2026 12:09:33 +0000 (14:09 +0200)
Returns true if the livepatch sysfs attribute exists, and false otherwise.
This new function will be used in the next patches.

Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
Reviewed-by: Petr Mladek <pmladek@suse.com>
Acked-by: Joe Lawrence <joe.lawrence@redhat.com>
Link: https://patch.msgid.link/20260504-lp-tests-old-fixes-v5-3-0be26d94ab9a@suse.com
Signed-off-by: Petr Mladek <pmladek@suse.com>
tools/testing/selftests/livepatch/functions.sh

index 8ec0cb64ad94a6c3094e8d1a2a1eff028fc672dd..2bc50271729c62595c338a9cf22505eda0379dd9 100644 (file)
@@ -339,6 +339,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