summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/kexec
diff options
context:
space:
mode:
authorMimi Zohar <zohar@linux.ibm.com>2019-03-06 19:19:45 +0300
committerShuah Khan <skhan@linuxfoundation.org>2019-04-18 00:32:19 +0300
commitc660a81796d456f0769937dd3ecf4cfd30f0ece6 (patch)
tree44230e58ce824cfac67db34fa2adcac6e077d779 /tools/testing/selftests/kexec
parent6038c81526d748b2bba691688095ced72a620539 (diff)
downloadlinux-c660a81796d456f0769937dd3ecf4cfd30f0ece6.tar.xz
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>
Diffstat (limited to 'tools/testing/selftests/kexec')
-rwxr-xr-xtools/testing/selftests/kexec/kexec_common_lib.sh7
-rwxr-xr-xtools/testing/selftests/kexec/test_kexec_load.sh4
2 files changed, 8 insertions, 3 deletions
diff --git a/tools/testing/selftests/kexec/kexec_common_lib.sh b/tools/testing/selftests/kexec/kexec_common_lib.sh
index 347a0d171450..a65337e8f290 100755
--- a/tools/testing/selftests/kexec/kexec_common_lib.sh
+++ b/tools/testing/selftests/kexec/kexec_common_lib.sh
@@ -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
+}
diff --git a/tools/testing/selftests/kexec/test_kexec_load.sh b/tools/testing/selftests/kexec/test_kexec_load.sh
index cbf598a380d2..49545fcdc646 100755
--- a/tools/testing/selftests/kexec/test_kexec_load.sh
+++ b/tools/testing/selftests/kexec/test_kexec_load.sh
@@ -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=$?