diff --git a/qemu/tests/cfg/uefi_check_boot_option.cfg b/qemu/tests/cfg/uefi_check_boot_option.cfg new file mode 100644 index 0000000000000000000000000000000000000000..09a0a0bd391f4784745599aab12cfe55a0dd6fce --- /dev/null +++ b/qemu/tests/cfg/uefi_check_boot_option.cfg @@ -0,0 +1,35 @@ +- uefi_check_boot_option: + only q35 + only ovmf + type = uefi_check_boot_option + start_vm = no + boot_menu = on + del boot_once + del boot_order + del boot_strict + splash_time_pattern = "SetVariable\(Timeout,\s%d\)" + variants: + - splash_time_10: + boot_splash_time = 10000 + - splash_time_12: + boot_splash_time = 12000 + - bootindex: + cdroms = "test" + cdrom_test = "/tmp/test.iso" + cd_format_test = ahci + images = "stg" + image_name_stg = "images/stg" + image_size_stg = 100M + force_create_image_stg = yes + remove_image_stg = yes + drive_format_stg = scsi-hd + image_boot = no + variants: + - hard_disk: + bootindex_stg = 0 + bootindex_test = 1 + boot_entry_info = "Booting UEFI QEMU QEMU HARDDISK" + - cd_rom: + bootindex_stg = 1 + bootindex_test = 0 + boot_entry_info = "Booting UEFI QEMU DVD-ROM" diff --git a/qemu/tests/uefi_check_boot_option.py b/qemu/tests/uefi_check_boot_option.py new file mode 100644 index 0000000000000000000000000000000000000000..f5ef17f2956b6c241e967af3f6128a2ab759ac79 --- /dev/null +++ b/qemu/tests/uefi_check_boot_option.py @@ -0,0 +1,67 @@ +import re +import os +import logging + +from avocado.utils import process + +from virttest import utils_misc +from virttest import env_process +from virttest import error_context + + +@error_context.context_aware +def run(test, params, env): + """ + Verify UEFI config setting in the GUI screen: + 1) Boot up a guest. + 2) If boot_splash_time not None, check splash-time in log output + 3) If check_boot_info not None, check boot entry info in log output + :param test: QEMU test object + :param params: Dictionary with the test parameters + :param env: Dictionary with test environment. + """ + + def info_check(info): + """ + Check log info + """ + logs = vm.logsessions['seabios'].get_output() + result = re.search(info, logs, re.S) + return result + + def create_cdroms(cdrom_test): + """ + Create 'test' cdrom with one file on it + """ + logging.info("creating test cdrom") + process.run("dd if=/dev/urandom of=test bs=10M count=1") + process.run("mkisofs -o %s test" % cdrom_test) + process.run("rm -f test") + + boot_splash_time = params.get("boot_splash_time") + check_boot_info = params.get("boot_entry_info") + timeout = int(params.get("check_timeout", 360)) + cdrom_test = params.get("cdrom_test") + if cdrom_test: + create_cdroms(cdrom_test) + params["start_vm"] = "yes" + env_process.process(test, params, env, + env_process.preprocess_image, + env_process.preprocess_vm) + vm = env.get_vm(params["main_vm"]) + vm.verify_alive() + + try: + if check_boot_info: + expect_result = check_boot_info + elif boot_splash_time: + splash_time_pattern = params.get("splash_time_pattern") + expect_result = (splash_time_pattern % + (int(boot_splash_time) // 1000)) + if not utils_misc.wait_for(lambda: info_check(expect_result), timeout): + test.fail("Does not get expected result from bios log: %s" + % expect_result) + finally: + if params.get("cdroms") == "test": + logging.info("cleaning up temp cdrom images") + os.remove(cdrom_test)