selftests/kexec: define "require_root_privileges"

Many tests require root privileges.  Define a common function.

Suggested-by: Petr Vorel <pvorel@suse.cz>
Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
This commit is contained in:
Mimi Zohar 2019-03-06 11:19:45 -05:00 committed by Shuah Khan
parent 6038c81526
commit c660a81796
2 changed files with 8 additions and 3 deletions

View File

@ -66,3 +66,10 @@ get_secureboot_mode()
log_info "secure boot mode not enabled"
return 0;
}
require_root_privileges()
{
if [ $(id -ru) -ne 0 ]; then
log_skip "requires root privileges"
fi
}

View File

@ -8,9 +8,7 @@ TEST="$0"
. ./kexec_common_lib.sh
# kexec requires root privileges
if [ $(id -ru) -ne 0 ]; then
log_skip "requires root privileges"
fi
require_root_privileges
get_secureboot_mode
secureboot=$?