From d9c21a492f645dba9d19f12d64717a10a5da9920 Mon Sep 17 00:00:00 2001
From: Wang Shengfang <wangshengfang@huawei.com>
Date: Tue, 2 Jun 2020 21:17:44 +0800
Subject: [PATCH 75/77] virsh_boot: add edk cdrom boot test case

Add aarch64 edk cdrom boot test case configuration.

Signed-off-by: Wang Shengfang <wangshengfang@huawei.com>
---
 libvirt/tests/cfg/bios/virsh_boot.cfg | 96 +++++++++++++++++++++++++++
 libvirt/tests/src/bios/virsh_boot.py  | 11 ++-
 2 files changed, 104 insertions(+), 3 deletions(-)

diff --git a/libvirt/tests/cfg/bios/virsh_boot.cfg b/libvirt/tests/cfg/bios/virsh_boot.cfg
index e6bee629..46df8604 100644
--- a/libvirt/tests/cfg/bios/virsh_boot.cfg
+++ b/libvirt/tests/cfg/bios/virsh_boot.cfg
@@ -163,8 +163,11 @@
                             uefi_target_dev = "sda"
                             check_prompt = "error:.*has invalid signature"
         - by_seabios:
+            no aarch64
             boot_type = "seabios"
             loader = "/usr/share/seabios/bios.bin"
+            Host_openEuler:
+                loader = "/usr/share/qemu/bios.bin"
             loader_type = "rom"
             variants:
                 - positive_test:
@@ -269,3 +272,96 @@
                                     boot_order = "a"
                                 - zero:
                                     boot_order = 0
+        - by_edk:
+            only aarch64
+            boot_type = "edk"
+            loader = "/usr/share/edk2/aarch64/QEMU_EFI-pflash.raw"
+            loader_type = "pflash"
+            template = "/usr/share/edk2/aarch64/vars-template-pflash.raw"
+            nvram = "/var/lib/libvirt/qemu/nvram/<VM_NAME>.fd"
+            shell_prompt = "Shell>.*$"
+            uefi_custom_codes = "\[\=3h"
+            with_nvram = "yes"
+            with_nvram_template = "yes"
+            os_firmware = "efi"
+            variants:
+                - positive_test:
+                    variants:
+                        - options:
+                            variants:
+                                - os_loader:
+                                    variants:
+                                        - valid_readonly:
+                                    variants:
+                                        - valid_loader_type:
+                            variants:
+                                - os_nvram:
+                                    variants:
+                                        - valid_template:
+                                        - no_template:
+                                            with_nvram_template = "no"
+                                - no_os_nvram:
+                                    with_nvram = "no"
+                            variants:
+                                - boot:
+                                    variants:
+                                        - boot_dev:
+                                        - boot_order:
+                                            boot_ref = "order"
+                                    variants:
+                                        - cdrom:
+                                            boot_dev = "cdrom"
+                                            target_dev = "sda"
+                                            device_bus = "scsi"
+                                            driver_type = "raw"
+                                            boot_iso_url = "EXAMPLE_BOOT_ISO_URL"
+                                            check_prompt = "Install openEuler"
+                                - no_boot:
+                                    only valid_readonly
+                                    only valid_loader_type
+                                    only valid_template
+                                    with_boot = "no"
+                        - invalid_nvram:
+                            nvram = "noexist"
+                        - boot_order_big_integer:
+                            boot_ref = "order"
+                            boot_order = 1000000000
+                        - two_same_boot_dev:
+                            two_same_boot_dev = "yes"
+                - negative_test:
+                    status_error = "yes"
+                    variants:
+                        - invalid_loader:
+                            loader = "noexist"
+                            checkpoint = "No such file or directory"
+                        - invalid_loader_type:
+                            define_error = "yes"
+                            loader_type = "noexist"
+                            checkpoint = "error: unknown type value"
+                        - invalid_nvram_template:
+                            template = "noexist"
+                            checkpoint = "error: Failed to open file.+: No such file or directory"
+                        - invalid_boot_dev:
+                            define_error = "yes"
+                            boot_dev = "noexist"
+                            checkpoint = "error: unsupported configuration: unknown boot device"
+                        - special_boot_order:
+                            boot_ref = "order"
+                            define_error = "yes"
+                            checkpoint = "error: internal error: incorrect boot order.+expecting positive integer"
+                            variants:
+                                - negative:
+                                    boot_order = -1
+                                - character:
+                                    boot_order = "a"
+                                - zero:
+                                    boot_order = 0
+                        - readonly_no:
+                            readonly = "no"
+                            checkpoint = "Could not open .+: Permission denied" || "error:.+Block node is read-only"
+                        - no_readonly:
+                            with_readonly = "no"
+                            checkpoint = "Could not open .+: Permission denied" || "error:.+Block node is read-only"
+                        - no_loader_type:
+                            with_loader_type = "no"
+                            checkpoint = "could not load PC BIOS"
diff --git a/libvirt/tests/src/bios/virsh_boot.py b/libvirt/tests/src/bios/virsh_boot.py
index cad95bda..97afd309 100755
--- a/libvirt/tests/src/bios/virsh_boot.py
+++ b/libvirt/tests/src/bios/virsh_boot.py
@@ -4,6 +4,7 @@ import re
 from aexpect.utils import astring
 from aexpect.exceptions import ShellProcessTerminatedError
 
+from avocado.utils import distro
 from avocado.utils import process
 
 from virttest import remote
@@ -239,9 +240,13 @@ def setup_test_env(params, test):
         elif not utils_package.package_install('qemu-kvm'):
             test.error("qemu-kvm package install failed")
 
-    if boot_type == "seabios" and \
-            not utils_package.package_install('seabios-bin'):
-        test.error("seabios package install failed")
+    if boot_type == "seabios":
+        if distro.detect().name == "openEuler":
+            seabios_pkg = "qemu-seabios"
+        else:
+            seabios_pkg = "seabios-bin"
+        if not utils_package.package_install(seabios_pkg):
+            test.error("seabios package install failed")
 
     if (source_protocol == "gluster"
             and not params.get("gluster_server_ip")
-- 
2.23.0

