|
| 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