mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-12-29 17:25:38 +00:00
selftests/livepatch: Add selftests for "replace" sysfs attribute
Add selftests for both atomic replace and non atomic replace livepatches. The result is as follows, TEST: sysfs test ... ok TEST: sysfs test object/patched ... ok TEST: sysfs test replace enabled ... ok TEST: sysfs test replace disabled ... ok Suggested-by: Marcos Paulo de Souza <mpdesouza@suse.com> Signed-off-by: Yafang Shao <laoar.shao@gmail.com> Tested-by: Marcos Paulo de Souza <mpdesouza@suse.com> Reviewed-by: Marcos Paulo de Souza <mpdesouza@suse.com> Reviewed-by: Petr Mladek <pmladek@suse.com> Acked-by: Miroslav Benes <mbenes@suse.cz> Link: https://lore.kernel.org/r/20240625151123.2750-3-laoar.shao@gmail.com Signed-off-by: Petr Mladek <pmladek@suse.com>
This commit is contained in:
parent
adb68ed26a
commit
40f9caa7b1
@ -18,6 +18,7 @@ check_sysfs_rights "$MOD_LIVEPATCH" "" "drwxr-xr-x"
|
||||
check_sysfs_rights "$MOD_LIVEPATCH" "enabled" "-rw-r--r--"
|
||||
check_sysfs_value "$MOD_LIVEPATCH" "enabled" "1"
|
||||
check_sysfs_rights "$MOD_LIVEPATCH" "force" "--w-------"
|
||||
check_sysfs_rights "$MOD_LIVEPATCH" "replace" "-r--r--r--"
|
||||
check_sysfs_rights "$MOD_LIVEPATCH" "transition" "-r--r--r--"
|
||||
check_sysfs_value "$MOD_LIVEPATCH" "transition" "0"
|
||||
check_sysfs_rights "$MOD_LIVEPATCH" "vmlinux/patched" "-r--r--r--"
|
||||
@ -83,4 +84,51 @@ test_klp_callbacks_demo: post_unpatch_callback: vmlinux
|
||||
livepatch: 'test_klp_callbacks_demo': unpatching complete
|
||||
% rmmod test_klp_callbacks_demo"
|
||||
|
||||
start_test "sysfs test replace enabled"
|
||||
|
||||
MOD_LIVEPATCH=test_klp_atomic_replace
|
||||
load_lp $MOD_LIVEPATCH replace=1
|
||||
|
||||
check_sysfs_rights "$MOD_LIVEPATCH" "replace" "-r--r--r--"
|
||||
check_sysfs_value "$MOD_LIVEPATCH" "replace" "1"
|
||||
|
||||
disable_lp $MOD_LIVEPATCH
|
||||
unload_lp $MOD_LIVEPATCH
|
||||
|
||||
check_result "% insmod test_modules/$MOD_LIVEPATCH.ko replace=1
|
||||
livepatch: enabling patch '$MOD_LIVEPATCH'
|
||||
livepatch: '$MOD_LIVEPATCH': initializing patching transition
|
||||
livepatch: '$MOD_LIVEPATCH': starting patching transition
|
||||
livepatch: '$MOD_LIVEPATCH': completing patching transition
|
||||
livepatch: '$MOD_LIVEPATCH': patching complete
|
||||
% echo 0 > /sys/kernel/livepatch/$MOD_LIVEPATCH/enabled
|
||||
livepatch: '$MOD_LIVEPATCH': initializing unpatching transition
|
||||
livepatch: '$MOD_LIVEPATCH': starting unpatching transition
|
||||
livepatch: '$MOD_LIVEPATCH': completing unpatching transition
|
||||
livepatch: '$MOD_LIVEPATCH': unpatching complete
|
||||
% rmmod $MOD_LIVEPATCH"
|
||||
|
||||
start_test "sysfs test replace disabled"
|
||||
|
||||
load_lp $MOD_LIVEPATCH replace=0
|
||||
|
||||
check_sysfs_rights "$MOD_LIVEPATCH" "replace" "-r--r--r--"
|
||||
check_sysfs_value "$MOD_LIVEPATCH" "replace" "0"
|
||||
|
||||
disable_lp $MOD_LIVEPATCH
|
||||
unload_lp $MOD_LIVEPATCH
|
||||
|
||||
check_result "% insmod test_modules/$MOD_LIVEPATCH.ko replace=0
|
||||
livepatch: enabling patch '$MOD_LIVEPATCH'
|
||||
livepatch: '$MOD_LIVEPATCH': initializing patching transition
|
||||
livepatch: '$MOD_LIVEPATCH': starting patching transition
|
||||
livepatch: '$MOD_LIVEPATCH': completing patching transition
|
||||
livepatch: '$MOD_LIVEPATCH': patching complete
|
||||
% echo 0 > /sys/kernel/livepatch/$MOD_LIVEPATCH/enabled
|
||||
livepatch: '$MOD_LIVEPATCH': initializing unpatching transition
|
||||
livepatch: '$MOD_LIVEPATCH': starting unpatching transition
|
||||
livepatch: '$MOD_LIVEPATCH': completing unpatching transition
|
||||
livepatch: '$MOD_LIVEPATCH': unpatching complete
|
||||
% rmmod $MOD_LIVEPATCH"
|
||||
|
||||
exit 0
|
||||
|
Loading…
Reference in New Issue
Block a user