Skip to content

Commit

Permalink
Merge pull request #4254 from XueqiangWei/check_net_boot_entry
Browse files Browse the repository at this point in the history
uefishell.check_net_boot_entry: adds new test case
  • Loading branch information
zhencliu authored Jan 21, 2025
2 parents bd33da7 + 06d2c56 commit 8719131
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 3 deletions.
40 changes: 40 additions & 0 deletions qemu/tests/cfg/uefishell.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,46 @@
command_ping6_args = "form_ping6_args()"
check_result_show6 = "(\w+::\w+:\w+:\w+:\w+)/64"
check_result_ping6 = "0.*packet loss"
- check_net_boot_entry:
bootindex_nic1 = 1
Windows:
cdroms = ""
test_scenarios = "connect bcfg"
command_connect = "connect -r"
command_bcfg = "bcfg boot dump"
check_result_bcfg = "UEFI\s+PXEv4, UEFI\s+PXEv6, UEFI\s+HTTPv4, UEFI\s+HTTPv6"
variants:
- with_one_serial:
serials = "vs1"
serial_type_vs1 = isa-serial
- with_two_serials:
serials = "vs1 vs2"
serial_type_vs1 = isa-serial
serial_type_vs2 = isa-serial
variants:
- with_virtio_rng:
no_virtio_rng:
virtio_rngs = "rng0"
backend_rng0 = rng-random
backend_type = passthrough
filename_passthrough = /dev/urandom
- with_fallback_rng:
virtio_rngs =
only cpu_without_rdrand
check_message = "WARNING: Pseudo Random Number Generator in use - Pixiefail CVE not mitigated"
- without_virtio_rng:
no cpu_without_rdrand
virtio_rngs =
variants:
- cpu_without_rdrand:
auto_cpu_model = no
HostCpuVendor.intel:
cpu_model_list = "core2duo qemu64 Nehalem"
HostCpuVendor.amd:
cpu_model_list = "core2duo qemu64 Opteron_G4"
- cpu_with_rdrand:
check_host_flags = yes
flags = rdrand
- uefi_cmd:
test_scenarios = "connect alias attrib dump date dblk devices "
test_scenarios += "devtree dh dmem dmpstore drivers getmtc help "
Expand Down
56 changes: 53 additions & 3 deletions qemu/tests/uefishell.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import logging
import os
import random
import re
import time

from avocado.utils import process
from virttest import data_dir, env_process, utils_misc, utils_net
from virttest import data_dir, env_process, utils_misc, utils_net, utils_qemu

from provider.cpu_utils import check_cpu_flags

LOG_JOB = logging.getLogger("avocado.test")

Expand All @@ -27,6 +30,47 @@ def __init__(self, test, params, env):
self.params = params
self.env = env
self.session = None
self.vm = None

def set_cpu_model(self, cpu_model_list):
"""
set cpu model by the given cpu model list
:param cpu_model_list: a list of cpu model
"""
qemu_binary = "/usr/libexec/qemu-kvm"
cpu_list = utils_qemu.get_supported_devices_list(qemu_binary, "CPU")
cpu_list = list(map(lambda x: x.split("-")[0], cpu_list))
cpu_model_list = list(filter(lambda x: x in cpu_list, cpu_model_list))
self.params["cpu_model"] = random.choice(cpu_model_list)

def check_host_cpu_flags(self):
"""
check if the host supports the cpu flags
"""
check_host_flags = self.params.get_boolean("check_host_flags")
if check_host_flags:
check_cpu_flags(self.params, self.params["flags"], self.test)

def check_message_in_serial_log(self, msg):
"""
check the given message in serial log
:param msg: the message to be checked in serial log
"""
serial_output = self.vm.serial_console.get_output()
if not re.search(msg, serial_output, re.S):
self.test.fail("Can't find 'msg' in serial log.")

def check_message_in_edk2_log(self, msg):
"""
check the given message in edk2 log
:param msg: the message to be checked in edk2 log
"""
logs = self.vm.logsessions["seabios"].get_output()
if not re.search(msg, logs, re.S):
self.test.fail("Can't find 'msg' in edk2 log.")

def setup(self, under_fs0):
"""
Expand All @@ -35,6 +79,9 @@ def setup(self, under_fs0):
:param under_fs0: most uefi command executed under fs0:\
"""
if not self.params.get_boolean("auto_cpu_model"):
self.set_cpu_model(self.params.get_list("cpu_model_list"))
self.check_host_cpu_flags()
params = self.params
for cdrom in params.objects("cdroms"):
boot_index = params.get("boot_index_%s" % cdrom)
Expand All @@ -60,8 +107,8 @@ def setup(self, under_fs0):
env_process.preprocess_image,
env_process.preprocess_vm,
)
vm = self.env.get_vm(params["main_vm"])
self.session = vm.wait_for_serial_login()
self.vm = self.env.get_vm(params["main_vm"])
self.session = self.vm.wait_for_serial_login()
if under_fs0 == "yes":
self.send_command("fs0:")

Expand Down Expand Up @@ -250,6 +297,9 @@ def handle_smbiosview(output):
time_interval = float(params["time_interval"])
under_fs0 = params.get("under_fs0", "yes")
uefishell_test.setup(under_fs0)
if params.get("check_message"):
uefishell_test.check_message_in_serial_log(params["check_message"])
uefishell_test.check_message_in_edk2_log(params["check_message"])
test_scenarios = params["test_scenarios"]
for scenario in test_scenarios.split():
command = params["command_%s" % scenario]
Expand Down

0 comments on commit 8719131

Please sign in to comment.