diff options
author | Petr Mladek <pmladek@suse.com> | 2022-10-05 13:00:03 +0200 |
---|---|---|
committer | Petr Mladek <pmladek@suse.com> | 2022-10-05 13:00:03 +0200 |
commit | 59b2a38c6afdc9341ac4fcff455bfdf77113ed37 (patch) | |
tree | 251697325d8c728343834929b0b56d2c1860c02d /tools/testing/selftests/livepatch/functions.sh | |
parent | selftests/livepatch: normalize sysctl error message (diff) | |
parent | selftests/livepatch: add sysfs test (diff) | |
download | linux-59b2a38c6afdc9341ac4fcff455bfdf77113ed37.tar.xz linux-59b2a38c6afdc9341ac4fcff455bfdf77113ed37.zip |
Merge branch 'for-6.1/sysfs-patched-object' into for-linus
Diffstat (limited to 'tools/testing/selftests/livepatch/functions.sh')
-rw-r--r-- | tools/testing/selftests/livepatch/functions.sh | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tools/testing/selftests/livepatch/functions.sh b/tools/testing/selftests/livepatch/functions.sh index d5001c9eb72e..c8416c54b463 100644 --- a/tools/testing/selftests/livepatch/functions.sh +++ b/tools/testing/selftests/livepatch/functions.sh @@ -6,6 +6,7 @@ MAX_RETRIES=600 RETRY_INTERVAL=".1" # seconds +KLP_SYSFS_DIR="/sys/kernel/livepatch" # Kselftest framework requirement - SKIP code is 4 ksft_skip=4 @@ -308,3 +309,36 @@ function check_result { cleanup_dmesg_file } + +# check_sysfs_rights(modname, rel_path, expected_rights) - check sysfs +# path permissions +# modname - livepatch module creating the sysfs interface +# rel_path - relative path of the sysfs interface +# expected_rights - expected access rights +function check_sysfs_rights() { + local mod="$1"; shift + local rel_path="$1"; shift + local expected_rights="$1"; shift + + local path="$KLP_SYSFS_DIR/$mod/$rel_path" + local rights=$(/bin/stat --format '%A' "$path") + if test "$rights" != "$expected_rights" ; then + die "Unexpected access rights of $path: $expected_rights vs. $rights" + fi +} + +# check_sysfs_value(modname, rel_path, expected_value) - check sysfs value +# modname - livepatch module creating the sysfs interface +# rel_path - relative path of the sysfs interface +# expected_value - expected value read from the file +function check_sysfs_value() { + local mod="$1"; shift + local rel_path="$1"; shift + local expected_value="$1"; shift + + local path="$KLP_SYSFS_DIR/$mod/$rel_path" + local value=`cat $path` + if test "$value" != "$expected_value" ; then + die "Unexpected value in $path: $expected_value vs. $value" + fi +} |