Skip to content

Commit 5997bad

Browse files
authored
Merge pull request #4368 from XueqiangWei/uefi_disable_firmware_config
uefi_disable_firmware_config: creates a new test case
2 parents 24b2641 + 9792304 commit 5997bad

File tree

2 files changed

+102
-0
lines changed

2 files changed

+102
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
- uefi_disable_firmware_config:
2+
virt_test_type = qemu
3+
type = uefi_disable_firmware_config
4+
only q35
5+
only ovmf
6+
no Host_RHEL.m7 Host_RHEL.m8 Host_RHEL.m9 Host_RHEL.m10.u0
7+
boot_menu_key = esc
8+
boot_menu_hint = "Boot Options"
9+
timeout = 30
10+
variants:
11+
- firmware_setup_support:
12+
firmware_config_option = FirmwareSetupSupport
13+
boot_dev = "EFI Firmware Setup"
14+
- ipv4_pxe_support:
15+
firmware_config_option = IPv4PXESupport
16+
boot_dev = "UEFI PXEv4"
17+
- ipv6_pxe_support:
18+
firmware_config_option = IPv6PXESupport
19+
boot_dev = "UEFI PXEv6"
20+
- ipv4_support:
21+
firmware_config_option = IPv4Support
22+
boot_dev = "UEFI HTTPv4"
23+
- ipv6_support:
24+
firmware_config_option = IPv6Support
25+
boot_dev = "UEFI HTTPv6"
26+
variants:
27+
- enable:
28+
firmware_config_enabled = yes
29+
extra_params += " -fw_cfg name=opt/org.tianocore/${firmware_config_option},string=yes"
30+
- disable:
31+
firmware_config_enabled = no
32+
extra_params += " -fw_cfg name=opt/org.tianocore/${firmware_config_option},string=no"
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import re
2+
3+
from virttest import error_context, utils_misc
4+
5+
6+
@error_context.context_aware
7+
def run(test, params, env):
8+
"""
9+
A user is able to enter the firmware configuration app (not really just
10+
a boot menu) and do whatever they want, including changing boot order and
11+
devices. To avoid that, we can disable the configuration app by adding
12+
firmware config files using the qemu command line option -fw_cfg.
13+
If the config option is disabled, the corresponding boot device will not
14+
appear in BootManagerMenuApp.
15+
e.g. disable Firmware setup support, "EFI Firmware Setup" does not appear
16+
in BootManagerMenuApp and then user can not enter the firmware
17+
configuration app.
18+
19+
In this case, the following config files will be covered.
20+
Check the boot device whether in BootManagerMenuApp when enabling/disabling
21+
the corresponding configuration.
22+
1. Firmware Config: opt/org.tianocore/FirmwareSetupSupport
23+
As the name suggests, this enables/disables Firmware setup support.
24+
2. Network: opt/org.tianocore/IPv4PXESupport
25+
As the name suggests, this enables/disables PXE network boot over IPv4.
26+
3. Network: opt/org.tianocore/IPv6PXESupport
27+
As the name suggests, this enables/disables PXE network boot over IPv6.
28+
4. Network: opt/org.tianocore/IPv4Support
29+
As the name suggests, this enables/disables HTTP network boot over IPv4.
30+
5. Network: opt/org.tianocore/IPv6Support
31+
As the name suggests, this enables/disables HTTP network boot over IPv6.
32+
33+
:param test: QEMU test object
34+
:param params: Dictionary with the test parameters
35+
:param env: Dictionary with test environment.
36+
"""
37+
38+
def boot_check(info):
39+
"""
40+
boot info check
41+
"""
42+
return re.search(info, vm.logsessions["seabios"].get_output(), re.S)
43+
44+
boot_menu_key = params["boot_menu_key"]
45+
boot_menu_hint = params["boot_menu_hint"]
46+
boot_dev = params["boot_dev"]
47+
timeout = params.get_numeric("timeout", 30, float)
48+
firmware_config_enabled = params.get_boolean("firmware_config_enabled")
49+
vm = env.get_vm(params["main_vm"])
50+
vm.verify_alive()
51+
52+
error_context.context("Navigate to Boot Manager Menu App", test.log.info)
53+
if not utils_misc.wait_for(lambda: boot_check(boot_menu_hint), timeout, 1):
54+
test.fail("Could not get boot manager menu message")
55+
vm.send_key(boot_menu_key)
56+
57+
if firmware_config_enabled:
58+
error_context.context(
59+
f"Check boot device {boot_dev} in the Boot Manager Menu App", test.log.info
60+
)
61+
if not boot_check(boot_dev):
62+
test.fail(f"Could not get boot device {boot_dev} in Boot Manager Menu App")
63+
else:
64+
error_context.context(
65+
f"Check boot device {boot_dev} does not appear "
66+
"in the Boot Manager Menu App",
67+
test.log.info,
68+
)
69+
if boot_check(boot_dev):
70+
test.fail(f"Get unexpected boot device {boot_dev} in Boot Manager Menu App")

0 commit comments

Comments
 (0)