Skip to content

Commit

Permalink
Merge pull request #5025 from meinaLi/bootmenu
Browse files Browse the repository at this point in the history
guest_os_booting: add new case for guest bootmenu
  • Loading branch information
dzhengfy committed Oct 23, 2023
2 parents 09ad9a6 + 56a0cb8 commit 5e52f53
Show file tree
Hide file tree
Showing 2 changed files with 109 additions and 0 deletions.
39 changes: 39 additions & 0 deletions libvirt/tests/cfg/guest_os_booting/boot_menu/bootmenu.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
- guest_os_booting.bootmenu:
type = bootmenu
start_vm = no
bootmenu_enable = "yes"
bootmenu_dict = {'bootmenu_enable': '%s', 'bootmenu_timeout': '%s', 'bios_useserial': 'yes'}
variants:
- positive_test:
status_error = "no"
variants:
- timeout_0:
directly_boot = "yes"
bootmenu_timeout = 0
- timeout_6000:
bootmenu_timeout = 6000
- timeout_65535:
bootmenu_timeout = 65535
- disable_bootmenu:
directly_boot = "yes"
bootmenu_enable = "no"
- negative_test:
status_error = "yes"
variants:
- timeout_-2:
bootmenu_timeout = -2
error_msg = " Invalid value for attribute 'timeout' in element 'bootmenu': '${bootmenu_timeout}'. Expected non-negative integer value"
- timeout_string:
bootmenu_timeout = "string"
error_msg = " Invalid value for attribute 'timeout' in element 'bootmenu': '${bootmenu_timeout}'. Expected non-negative integer value"
- timeout_65536:
bootmenu_timeout = 65536
error_msg = "invalid value for boot menu timeout, must be in range [0,65535]"
variants:
- by_ovmf:
only q35
firmware_type = "ovmf"
check_prompt = "BdsDxe: loading Boot0000 "UiApp" from Fv"
- by_seabios:
firmware_type = "seabios"
check_prompt = "Select boot device"
70 changes: 70 additions & 0 deletions libvirt/tests/src/guest_os_booting/boot_menu/bootmenu.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright Red Hat
#
# SPDX-License-Identifier: GPL-2.0

# Author: Meina Li <[email protected]>
#
import time

from virttest import virsh
from virttest.libvirt_xml import vm_xml
from virttest.libvirt_xml import xcepts

from provider.guest_os_booting import guest_os_booting_base as guest_os


def run(test, params, env):
"""
This case is to verify the boot menu element.
1) Prepare a guest with boot menu element.
2) Start and boot the guest.
"""
vm_name = guest_os.get_vm(params)
firmware_type = params.get("firmware_type")
bootmenu_timeout = params.get("bootmenu_timeout")
bootmenu_enable = params.get("bootmenu_enable")
bootmenu_dict = eval(params.get("bootmenu_dict") % (bootmenu_enable, bootmenu_timeout))
check_prompt = params.get("check_prompt")
error_msg = params.get("error_msg", "")
status_error = "yes" == params.get("status_error", "no")
directly_boot = "yes" == params.get("directly_boot", "no")
virsh_dargs = {"debug": True, "ignore_status": True}

vm = env.get_vm(vm_name)
vmxml = vm_xml.VMXML.new_from_inactive_dumpxml(vm_name)
bkxml = vmxml.copy()

try:
try:
guest_os.prepare_os_xml(vm_name, bootmenu_dict)
except xcepts.LibvirtXMLError as details:
if error_msg and error_msg in str(details):
test.log.info("Get expected error message: %s.", error_msg)
else:
test.fail("Failed to define the guest because error:%s" % str(details))
if not status_error:
if directly_boot:
guest_os.check_vm_startup(vm, vm_name)
else:
virsh.start(vm_name, "--paused", **virsh_dargs)
vm.create_serial_console()
vm.resume()
# Wait $bootmenu_timeout/1000 seconds before entering boot menu
sleep_time = int(bootmenu_timeout) / 1000
time.sleep(sleep_time)
for _ in range(2):
vm.serial_console.sendcontrol('[')
vm.serial_console.read_until_any_line_matches([check_prompt], timeout=30,
internal_timeout=0.5)
test.log.info("Get check point as expected")
if firmware_type == "seabios":
vm.serial_console.send('1')
else:
virsh.destroy(vm_name)
virsh.start(vm_name, debug=True, ignore_status=False)
vm.wait_for_login().close()
finally:
bkxml.sync()

0 comments on commit 5e52f53

Please sign in to comment.