summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorMimi Zohar <zohar@linux.ibm.com>2019-03-06 17:19:45 +0100
committerShuah Khan <skhan@linuxfoundation.org>2019-04-17 23:32:19 +0200
commitc660a81796d456f0769937dd3ecf4cfd30f0ece6 (patch)
tree44230e58ce824cfac67db34fa2adcac6e077d779 /tools
parentselftests/kexec: define common logging functions (diff)
downloadlinux-c660a81796d456f0769937dd3ecf4cfd30f0ece6.tar.xz
linux-c660a81796d456f0769937dd3ecf4cfd30f0ece6.zip
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')
-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=$?