selftests/kexec: kexec_file_load syscall test
[platform/kernel/linux-starfive.git] / tools / testing / selftests / kexec / test_kexec_load.sh
1 #!/bin/sh
2 # SPDX-License-Identifier: GPL-2.0
3 # Loading a kernel image via the kexec_load syscall should fail
4 # when the kernel is CONFIG_KEXEC_VERIFY_SIG enabled and the system
5 # is booted in secureboot mode.
6
7 TEST="$0"
8 . ./kexec_common_lib.sh
9
10 # kexec requires root privileges
11 require_root_privileges
12
13 get_secureboot_mode
14 secureboot=$?
15
16 # kexec_load should fail in secure boot mode
17 kexec --load $KERNEL_IMAGE > /dev/null 2>&1
18 if [ $? -eq 0 ]; then
19         kexec --unload
20         if [ $secureboot -eq 1 ]; then
21                 log_fail "kexec_load succeeded"
22         else
23                 log_pass "kexec_load succeeded"
24         fi
25 else
26         if [ $secureboot -eq 1 ]; then
27                 log_pass "kexec_load failed"
28         else
29                 log_fail "kexec_load failed"
30         fi
31 fi