Return 0 if the livepatch sysfs attribute don't exists, and 1 otherwise. This new function will be used in the next patches.
Signed-off-by: Marcos Paulo de Souza <[email protected]> --- tools/testing/selftests/livepatch/functions.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tools/testing/selftests/livepatch/functions.sh b/tools/testing/selftests/livepatch/functions.sh index 8ec0cb64ad94a..781346d6e94e0 100644 --- a/tools/testing/selftests/livepatch/functions.sh +++ b/tools/testing/selftests/livepatch/functions.sh @@ -339,6 +339,20 @@ function check_result { fi } +# check_sysfs_exists(modname, attr) - check sysfs attribute existence +# modname - livepatch module creating the sysfs interface +# attr - attribute name to be checked +function check_sysfs_exists() { + local mod="$1"; shift + local attr="$1"; shift + + if [[ ! -f "$SYSFS_KLP_DIR/$mod/$attr" ]]; then + return 0 + fi + + return 1 +} + # check_sysfs_rights(modname, rel_path, expected_rights) - check sysfs # path permissions # modname - livepatch module creating the sysfs interface -- 2.52.0

