未验证 提交 ac9a49ef 编写于 作者: C chunfu wen 提交者: GitHub

Merge pull request #2928 from smitterl/s390_bootmenu

Add test case for s390 boot menu
...@@ -8,6 +8,16 @@ ...@@ -8,6 +8,16 @@
status_error = "no" status_error = "no"
variants: variants:
- define_start_destroy_save_restore_undefine: - define_start_destroy_save_restore_undefine:
no s390-virtio
- check_menu:
only by_qemu_on_s390
expected_text = "s390-ccw Enumerated Boot Menu.*\[2\].*Please choose.*default will boot in 3 seconds.*"
bootmenu_timeout = "3000"
- boot_non_default:
only by_qemu_on_s390
expected_text = "Booting entry #2"
boot_entry = 2
bootmenu_timeout = "60000"
variants: variants:
- boot_dev: - boot_dev:
boot_ref = "dev" boot_ref = "dev"
...@@ -24,6 +34,7 @@ ...@@ -24,6 +34,7 @@
disk_target_dev = 'sda' disk_target_dev = 'sda'
disk_target_bus = 'sata' disk_target_bus = 'sata'
- by_seabios: - by_seabios:
no s390-virtio
boot_type = "seabios" boot_type = "seabios"
loader = "/usr/share/seabios/bios.bin" loader = "/usr/share/seabios/bios.bin"
loader_type = "rom" loader_type = "rom"
...@@ -31,3 +42,11 @@ ...@@ -31,3 +42,11 @@
bios_reboot_timeout = "1000" bios_reboot_timeout = "1000"
disk_target_dev = 'hda' disk_target_dev = 'hda'
disk_target_bus = 'scsi' disk_target_bus = 'scsi'
- by_qemu_on_s390:
only s390-virtio
only boot_dev
boot_type = "s390_qemu"
smbios_mode = ""
disk_target_dev = 'vda'
disk_target_bus = 'virtio'
loader = ""
import time
import logging import logging
import os import os
import re
from virttest import virsh from virttest import virsh
from virttest import utils_package from virttest import utils_package
from virttest.libvirt_xml import vm_xml from virttest.libvirt_xml import vm_xml
from virttest.utils_test import libvirt as utlv from virttest.utils_test import libvirt as utlv
from virttest.utils_misc import wait_for
from virttest import data_dir from virttest import data_dir
from virttest import libvirt_version from virttest import libvirt_version
...@@ -29,11 +32,13 @@ def prepare_boot_xml(vmxml, params): ...@@ -29,11 +32,13 @@ def prepare_boot_xml(vmxml, params):
dict_os_attrs = {} dict_os_attrs = {}
logging.debug("Set boot loader common attributes") logging.debug("Set boot loader common attributes")
dict_os_attrs.update({"bootmenu_enable": bootmenu_enable})
dict_os_attrs.update({"bootmenu_timeout": bootmenu_timeout})
if loader:
dict_os_attrs.update({"loader": loader}) dict_os_attrs.update({"loader": loader})
dict_os_attrs.update({"loader_type": loader_type}) dict_os_attrs.update({"loader_type": loader_type})
dict_os_attrs.update({"loader_readonly": readonly}) dict_os_attrs.update({"loader_readonly": readonly})
dict_os_attrs.update({"bootmenu_enable": bootmenu_enable}) if smbios_mode:
dict_os_attrs.update({"bootmenu_timeout": bootmenu_timeout})
dict_os_attrs.update({"smbios_mode": smbios_mode}) dict_os_attrs.update({"smbios_mode": smbios_mode})
# Set Uefi special attributes # Set Uefi special attributes
...@@ -56,13 +61,34 @@ def prepare_boot_xml(vmxml, params): ...@@ -56,13 +61,34 @@ def prepare_boot_xml(vmxml, params):
return vmxml return vmxml
def console_check(vm, pattern, debug_log=False):
"""
Return function for use with wait_for.
:param vm: vm to check serial console for
:param pattern: line or pattern to match
:param debug_log: if to log all output for debugging
:return: function returning true if console output matches pattern
"""
def _matches():
output = vm.serial_console.get_stripped_output()
matches = re.search(pattern, output, re.S)
if debug_log:
logging.debug("Checked for '%s' in '%s'", pattern, output)
if matches:
logging.debug("Found '%s' in '%s'", pattern, output)
return True
return False
return _matches
def run(test, params, env): def run(test, params, env):
""" """
Test Define/undefine/start/destroy/save/restore a OVMF/Seabios domain Test Define/undefine/start/destroy/save/restore a OVMF/Seabios domain
with 'boot dev' element or 'boot order' element with 'boot dev' element or 'boot order' element
Steps: Steps:
1) Prepare a typical VM XML for OVMF or Seabios Guest boot 1) Prepare a typical VM XML, e.g. for OVMF or Seabios Guest boot
2) Setup boot sequence by element 'boot dev' or 'boot order' 2) Setup boot sequence by element 'boot dev' or 'boot order'
2) Define/undefine/start/destroy/save/restore VM and check result 2) Define/undefine/start/destroy/save/restore VM and check result
""" """
...@@ -75,6 +101,8 @@ def run(test, params, env): ...@@ -75,6 +101,8 @@ def run(test, params, env):
disk_target_bus = params.get("disk_target_bus", "") disk_target_bus = params.get("disk_target_bus", "")
save_file = os.path.join(data_dir.get_tmp_dir(), vm_name + ".save") save_file = os.path.join(data_dir.get_tmp_dir(), vm_name + ".save")
nvram_file = params.get("nvram", "") nvram_file = params.get("nvram", "")
expected_text = params.get("expected_text", None)
boot_entry = params.get("boot_entry", None)
# Back VM XML # Back VM XML
vmxml = vm_xml.VMXML.new_from_dumpxml(vm_name) vmxml = vm_xml.VMXML.new_from_dumpxml(vm_name)
...@@ -114,6 +142,28 @@ def run(test, params, env): ...@@ -114,6 +142,28 @@ def run(test, params, env):
vmxml.undefine() vmxml.undefine()
virsh_dargs = {"debug": True, "ignore_status": True} virsh_dargs = {"debug": True, "ignore_status": True}
if boot_type == "s390_qemu":
# Start test and check result
ret = virsh.define(vmxml.xml, **virsh_dargs)
ret = virsh.start(vm_name, "--paused", **virsh_dargs)
time.sleep(1)
vm.create_serial_console()
time.sleep(1)
vm.resume()
if not boot_entry:
check_boot = console_check(vm, expected_text)
if not wait_for(check_boot, 60, 1):
test.fail("No boot menu found. Please check log.")
else:
vm.serial_console.send(boot_entry)
time.sleep(0.5)
vm.serial_console.sendcontrol('m')
check_boot = console_check(vm, expected_text)
if not wait_for(check_boot, 60, 1):
test.fail("Boot entry not selected. Please check log.")
vm.wait_for_login()
else:
# Start test and check result # Start test and check result
ret = virsh.define(vmxml.xml, **virsh_dargs) ret = virsh.define(vmxml.xml, **virsh_dargs)
stdout_patt = "Domain %s defined from %s" % (vm_name, vmxml.xml) stdout_patt = "Domain %s defined from %s" % (vm_name, vmxml.xml)
...@@ -148,4 +198,4 @@ def run(test, params, env): ...@@ -148,4 +198,4 @@ def run(test, params, env):
if vm.is_alive: if vm.is_alive:
vm.destroy() vm.destroy()
logging.debug("Restore the VM XML") logging.debug("Restore the VM XML")
vmxml_backup.define() vmxml_backup.sync()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册