mirror of
https://github.com/qemu/qemu.git
synced 2024-12-04 09:13:39 +08:00
tests/functional: Convert Aarch64 Virt machine avocado tests
Straight forward conversion. Update the SHA1 hash to SHA256 since SHA1 should not be used anymore nowadays. Provide get_qemu_img() helper in qemu_test. $ make check-functional-aarch64 V=1 ▶ 1/4 test_aarch64_virt.Aarch64VirtMachine.test_aarch64_virt_gicv2 OK ▶ 1/4 test_aarch64_virt.Aarch64VirtMachine.test_aarch64_virt_gicv3 OK ▶ 1/4 test_aarch64_virt.Aarch64VirtMachine.test_alpine_virt_tcg_gic_max OK 1/4 qemu:func-thorough+func-aarch64-thorough+thorough / func-aarch64-aarch64_virt OK 30.44s 3 subtests passed ... Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Message-ID: <20240826103634.52384-1-philmd@linaro.org> Reviewed-by: Thomas Huth <thuth@redhat.com> Message-ID: <20240830133841.142644-36-thuth@redhat.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
This commit is contained in:
parent
8f16cd80fc
commit
1255f5e496
@ -1022,7 +1022,7 @@ S: Maintained
|
|||||||
F: hw/arm/virt*
|
F: hw/arm/virt*
|
||||||
F: include/hw/arm/virt.h
|
F: include/hw/arm/virt.h
|
||||||
F: docs/system/arm/virt.rst
|
F: docs/system/arm/virt.rst
|
||||||
F: tests/avocado/machine_aarch64_virt.py
|
F: tests/functional/test_aarch64_virt.py
|
||||||
|
|
||||||
Xilinx Zynq
|
Xilinx Zynq
|
||||||
M: Edgar E. Iglesias <edgar.iglesias@gmail.com>
|
M: Edgar E. Iglesias <edgar.iglesias@gmail.com>
|
||||||
|
@ -12,6 +12,7 @@ endif
|
|||||||
# Timeouts for individual tests that can be slow e.g. with debugging enabled
|
# Timeouts for individual tests that can be slow e.g. with debugging enabled
|
||||||
test_timeouts = {
|
test_timeouts = {
|
||||||
'aarch64_sbsaref' : 600,
|
'aarch64_sbsaref' : 600,
|
||||||
|
'aarch64_virt' : 360,
|
||||||
'acpi_bits' : 240,
|
'acpi_bits' : 240,
|
||||||
'netdev_ethtool' : 180,
|
'netdev_ethtool' : 180,
|
||||||
'ppc_40p' : 240,
|
'ppc_40p' : 240,
|
||||||
@ -35,6 +36,7 @@ tests_generic_bsduser = [
|
|||||||
|
|
||||||
tests_aarch64_system_thorough = [
|
tests_aarch64_system_thorough = [
|
||||||
'aarch64_sbsaref',
|
'aarch64_sbsaref',
|
||||||
|
'aarch64_virt',
|
||||||
]
|
]
|
||||||
|
|
||||||
tests_arm_system_thorough = [
|
tests_arm_system_thorough = [
|
||||||
|
@ -10,5 +10,5 @@ from .asset import Asset
|
|||||||
from .config import BUILD_DIR
|
from .config import BUILD_DIR
|
||||||
from .cmd import has_cmd, has_cmds, run_cmd, is_readable_executable_file, \
|
from .cmd import has_cmd, has_cmds, run_cmd, is_readable_executable_file, \
|
||||||
interrupt_interactive_console_until_pattern, wait_for_console_pattern, \
|
interrupt_interactive_console_until_pattern, wait_for_console_pattern, \
|
||||||
exec_command, exec_command_and_wait_for_pattern
|
exec_command, exec_command_and_wait_for_pattern, get_qemu_img
|
||||||
from .testcase import QemuSystemTest, QemuBaseTest
|
from .testcase import QemuSystemTest, QemuBaseTest
|
||||||
|
@ -16,6 +16,8 @@ import os
|
|||||||
import os.path
|
import os.path
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
|
from .config import BUILD_DIR
|
||||||
|
|
||||||
|
|
||||||
def has_cmd(name, args=None):
|
def has_cmd(name, args=None):
|
||||||
"""
|
"""
|
||||||
@ -176,3 +178,16 @@ def exec_command_and_wait_for_pattern(test, command,
|
|||||||
:param failure_message: if this message appears, test fails
|
:param failure_message: if this message appears, test fails
|
||||||
"""
|
"""
|
||||||
_console_interaction(test, success_message, failure_message, command + '\r')
|
_console_interaction(test, success_message, failure_message, command + '\r')
|
||||||
|
|
||||||
|
def get_qemu_img(test):
|
||||||
|
test.log.debug('Looking for and selecting a qemu-img binary')
|
||||||
|
|
||||||
|
# If qemu-img has been built, use it, otherwise the system wide one
|
||||||
|
# will be used.
|
||||||
|
qemu_img = os.path.join(BUILD_DIR, 'qemu-img')
|
||||||
|
if os.path.exists(qemu_img):
|
||||||
|
return qemu_img
|
||||||
|
if has_cmd('qemu-img'):
|
||||||
|
return 'qemu-img'
|
||||||
|
test.skipTest('Could not find "qemu-img", which is required to '
|
||||||
|
'create temporary images')
|
||||||
|
69
tests/avocado/machine_aarch64_virt.py → tests/functional/test_aarch64_virt.py
Normal file → Executable file
69
tests/avocado/machine_aarch64_virt.py → tests/functional/test_aarch64_virt.py
Normal file → Executable file
@ -1,3 +1,5 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
#
|
||||||
# Functional test that boots a various Linux systems and checks the
|
# Functional test that boots a various Linux systems and checks the
|
||||||
# console output.
|
# console output.
|
||||||
#
|
#
|
||||||
@ -12,12 +14,11 @@ import time
|
|||||||
import os
|
import os
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from avocado_qemu import QemuSystemTest
|
from qemu_test import BUILD_DIR
|
||||||
from avocado_qemu import wait_for_console_pattern
|
from qemu_test import QemuSystemTest, Asset
|
||||||
from avocado_qemu import exec_command
|
from qemu_test import exec_command, wait_for_console_pattern
|
||||||
from avocado_qemu import BUILD_DIR
|
from qemu_test import get_qemu_img, run_cmd
|
||||||
from avocado.utils import process
|
|
||||||
from avocado.utils.path import find_command
|
|
||||||
|
|
||||||
class Aarch64VirtMachine(QemuSystemTest):
|
class Aarch64VirtMachine(QemuSystemTest):
|
||||||
KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 '
|
KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 '
|
||||||
@ -28,23 +29,18 @@ class Aarch64VirtMachine(QemuSystemTest):
|
|||||||
failure_message='Kernel panic - not syncing',
|
failure_message='Kernel panic - not syncing',
|
||||||
vm=vm)
|
vm=vm)
|
||||||
|
|
||||||
|
ASSET_ALPINE_ISO = Asset(
|
||||||
|
('https://dl-cdn.alpinelinux.org/'
|
||||||
|
'alpine/v3.17/releases/aarch64/alpine-standard-3.17.2-aarch64.iso'),
|
||||||
|
'5a36304ecf039292082d92b48152a9ec21009d3a62f459de623e19c4bd9dc027')
|
||||||
|
|
||||||
# This tests the whole boot chain from EFI to Userspace
|
# This tests the whole boot chain from EFI to Userspace
|
||||||
# We only boot a whole OS for the current top level CPU and GIC
|
# We only boot a whole OS for the current top level CPU and GIC
|
||||||
# Other test profiles should use more minimal boots
|
# Other test profiles should use more minimal boots
|
||||||
def test_alpine_virt_tcg_gic_max(self):
|
def test_alpine_virt_tcg_gic_max(self):
|
||||||
"""
|
iso_path = self.ASSET_ALPINE_ISO.fetch()
|
||||||
:avocado: tags=arch:aarch64
|
|
||||||
:avocado: tags=machine:virt
|
|
||||||
:avocado: tags=accel:tcg
|
|
||||||
"""
|
|
||||||
iso_url = (
|
|
||||||
"https://dl-cdn.alpinelinux.org/"
|
|
||||||
"alpine/v3.17/releases/aarch64/alpine-standard-3.17.2-aarch64.iso"
|
|
||||||
)
|
|
||||||
|
|
||||||
iso_hash = "5a36304ecf039292082d92b48152a9ec21009d3a62f459de623e19c4bd9dc027"
|
|
||||||
iso_path = self.fetch_asset(iso_url, algorithm="sha256", asset_hash=iso_hash)
|
|
||||||
|
|
||||||
|
self.set_machine('virt')
|
||||||
self.vm.set_console()
|
self.vm.set_console()
|
||||||
kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
|
kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
|
||||||
'console=ttyAMA0')
|
'console=ttyAMA0')
|
||||||
@ -68,6 +64,11 @@ class Aarch64VirtMachine(QemuSystemTest):
|
|||||||
self.wait_for_console_pattern('Welcome to Alpine Linux 3.17')
|
self.wait_for_console_pattern('Welcome to Alpine Linux 3.17')
|
||||||
|
|
||||||
|
|
||||||
|
ASSET_KERNEL = Asset(
|
||||||
|
('https://fileserver.linaro.org/s/'
|
||||||
|
'z6B2ARM7DQT3HWN/download'),
|
||||||
|
'12a54d4805cda6ab647cb7c7bbdb16fafb3df400e0d6f16445c1a0436100ef8d')
|
||||||
|
|
||||||
def common_aarch64_virt(self, machine):
|
def common_aarch64_virt(self, machine):
|
||||||
"""
|
"""
|
||||||
Common code to launch basic virt machine with kernel+initrd
|
Common code to launch basic virt machine with kernel+initrd
|
||||||
@ -75,11 +76,9 @@ class Aarch64VirtMachine(QemuSystemTest):
|
|||||||
"""
|
"""
|
||||||
logger = logging.getLogger('aarch64_virt')
|
logger = logging.getLogger('aarch64_virt')
|
||||||
|
|
||||||
kernel_url = ('https://fileserver.linaro.org/s/'
|
kernel_path = self.ASSET_KERNEL.fetch()
|
||||||
'z6B2ARM7DQT3HWN/download')
|
|
||||||
kernel_hash = 'ed11daab50c151dde0e1e9c9cb8b2d9bd3215347'
|
|
||||||
kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
|
|
||||||
|
|
||||||
|
self.set_machine('virt')
|
||||||
self.vm.set_console()
|
self.vm.set_console()
|
||||||
kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
|
kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
|
||||||
'console=ttyAMA0')
|
'console=ttyAMA0')
|
||||||
@ -98,14 +97,8 @@ class Aarch64VirtMachine(QemuSystemTest):
|
|||||||
# Also add a scratch block device
|
# Also add a scratch block device
|
||||||
logger.info('creating scratch qcow2 image')
|
logger.info('creating scratch qcow2 image')
|
||||||
image_path = os.path.join(self.workdir, 'scratch.qcow2')
|
image_path = os.path.join(self.workdir, 'scratch.qcow2')
|
||||||
qemu_img = os.path.join(BUILD_DIR, 'qemu-img')
|
qemu_img = get_qemu_img(self)
|
||||||
if not os.path.exists(qemu_img):
|
run_cmd([qemu_img, 'create', '-f', 'qcow2', image_path, '8M'])
|
||||||
qemu_img = find_command('qemu-img', False)
|
|
||||||
if qemu_img is False:
|
|
||||||
self.cancel('Could not find "qemu-img", which is required to '
|
|
||||||
'create the temporary qcow2 image')
|
|
||||||
cmd = '%s create -f qcow2 %s 8M' % (qemu_img, image_path)
|
|
||||||
process.run(cmd)
|
|
||||||
|
|
||||||
# Add the device
|
# Add the device
|
||||||
self.vm.add_args('-blockdev',
|
self.vm.add_args('-blockdev',
|
||||||
@ -128,19 +121,11 @@ class Aarch64VirtMachine(QemuSystemTest):
|
|||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
|
|
||||||
def test_aarch64_virt_gicv3(self):
|
def test_aarch64_virt_gicv3(self):
|
||||||
"""
|
|
||||||
:avocado: tags=arch:aarch64
|
|
||||||
:avocado: tags=machine:virt
|
|
||||||
:avocado: tags=accel:tcg
|
|
||||||
:avocado: tags=cpu:max
|
|
||||||
"""
|
|
||||||
self.common_aarch64_virt("virt,gic_version=3")
|
self.common_aarch64_virt("virt,gic_version=3")
|
||||||
|
|
||||||
def test_aarch64_virt_gicv2(self):
|
def test_aarch64_virt_gicv2(self):
|
||||||
"""
|
|
||||||
:avocado: tags=arch:aarch64
|
|
||||||
:avocado: tags=machine:virt
|
|
||||||
:avocado: tags=accel:tcg
|
|
||||||
:avocado: tags=cpu:max
|
|
||||||
"""
|
|
||||||
self.common_aarch64_virt("virt,gic-version=2")
|
self.common_aarch64_virt("virt,gic-version=2")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
QemuSystemTest.main()
|
Loading…
Reference in New Issue
Block a user