Python and Acceptance Tests

- New SMMUv3 and Intel IOMMU tests
 - Respect "cpu" tags and reduce boiler plate code
 - Improved logging of qemu execution output
 - Other misc improvements
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEeruW64tGuU1eD+m7ZX6NM6XyCfMFAmDuAYgACgkQZX6NM6Xy
 CfNdzhAAq1EN78aKeUhRDQukBm1y5zJuxNMwlLHqrRg/z7pML9A9lsMVZtkfVUuM
 rDxOsLArEfvOw1YksyKg7zYUtDjXTTKfwS0JC5HLiAjEd9/sUiTMZQPNjpfZtvT0
 wQt1n1OOm5oQzWAAHyya+R5B7PlZubF1dj79HgdPym4kSHP3/EkwbRKhDQwKGcWT
 Ddl38nuCXG31u8HHU6hLllv+m9e8jxhdEN3cCjb9fYffprNoVaj9oRZ4uoDITlM+
 f/D37vb4GmWi92dwrtxsCWWTGLr1W0TZGS5EWhj5lg294b/MJ10rbSgnIjxVSzvI
 cuJxGPXfXZhXcFA6K0imXvRFfpkCjAfNTlI2ccngCrUXmrTh386PNxhe8gBKsZko
 o4HBaNTkSSG/xZssmxuk8eCxzdxNmWeew7ZgJV15cgo8//8Vvn9UxbtueBdkzcZN
 5ofY+NpgHQpImiq4cDaT2Eokw4AueAOrXceE5Do57Dtyl6+y8UZG7aTWHxqx+6tq
 wsZflHTPaIBDY9nxzr3K0zB6RBSHG/X7BNewrMobcQ10FLOUiMC1twUq4jfEo3qN
 kf42peIER2pzRHifLeJCsCNecQpVr6tCIfDAE/TXs82HDSeI1vVFR7GeoRaFpLLk
 jVx4UqD178ejSt5GXvNipR/PaOha1ZlojZoVPoHFptjS3nE2prs=
 =25zZ
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/cleber-gitlab/tags/python-next-pull-request' into staging

Python and Acceptance Tests

- New SMMUv3 and Intel IOMMU tests
- Respect "cpu" tags and reduce boiler plate code
- Improved logging of qemu execution output
- Other misc improvements

# gpg: Signature made Tue 13 Jul 2021 22:11:36 BST
# gpg:                using RSA key 7ABB96EB8B46B94D5E0FE9BB657E8D33A5F209F3
# gpg: Good signature from "Cleber Rosa <crosa@redhat.com>" [marginal]
# gpg: WARNING: This key is not certified with sufficiently trusted signatures!
# gpg:          It is not certain that the signature belongs to the owner.
# Primary key fingerprint: 7ABB 96EB 8B46 B94D 5E0F  E9BB 657E 8D33 A5F2 09F3

* remotes/cleber-gitlab/tags/python-next-pull-request: (23 commits)
  tests/acceptance/cpu_queries.py: use the proper logging channels
  tests/acceptance/linux_ssh_mips_malta.py: drop identical setUp
  Acceptance tests: do not try to reuse packages from the system
  python: Configure tox to skip missing interpreters
  tests/acceptance: Handle cpu tag on x86_cpu_model_versions tests
  tests/acceptance: Add set_vm_arg() to the Test class
  python/qemu: Add args property to the QEMUMachine class
  tests/acceptance: Tagging tests with "cpu:VALUE"
  tests/acceptance: Let the framework handle "cpu:VALUE" tagged tests
  tests/acceptance: Fix mismatch on cpu tagged tests
  tests/acceptance: Automatic set -cpu to the test vm
  tests/acceptance: Tag NetBSD tests as 'os:netbsd'
  avocado_qemu: Add Intel iommu tests
  avocado_qemu: Add SMMUv3 tests
  Acceptance Tests: Add default kernel params and pxeboot url to the KNOWN_DISTROS collection
  avocado_qemu: Fix KNOWN_DISTROS map into the LinuxDistro class
  tests/acceptance: Ignore binary data sent on serial console
  Acceptance Tests: support choosing specific distro and version
  Acceptance Tests: move definition of distro checksums to the framework
  Acceptance Tests: rename attribute holding the distro image checksum
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2021-07-14 18:09:09 +01:00
commit a9649a719a
23 changed files with 603 additions and 72 deletions

View File

@ -43,6 +43,7 @@ check-python-tox:
- make -C python check-tox
variables:
GIT_DEPTH: 1
QEMU_TOX_EXTRA_ARGS: --skip-missing-interpreters=false
needs:
job: python-container
allow_failure: true

View File

@ -171,6 +171,7 @@ L: qemu-arm@nongnu.org
S: Maintained
F: hw/arm/smmu*
F: include/hw/arm/smmu*
F: tests/acceptance/smmu.py
AVR TCG CPUs
M: Michael Rolnik <mrolnik@gmail.com>

View File

@ -904,6 +904,17 @@ name. If one is not given explicitly, it will either be set to
``None``, or, if the test is tagged with one (and only one)
``:avocado: tags=arch:VALUE`` tag, it will be set to ``VALUE``.
cpu
~~~
The cpu model that will be set to all QEMUMachine instances created
by the test.
The ``cpu`` attribute will be set to the test parameter of the same
name. If one is not given explicitly, it will either be set to
``None ``, or, if the test is tagged with one (and only one)
``:avocado: tags=cpu:VALUE`` tag, it will be set to ``VALUE``.
machine
~~~~~~~
@ -922,6 +933,39 @@ The preserved value of the ``qemu_bin`` parameter or the result of the
dynamic probe for a QEMU binary in the current working directory or
source tree.
LinuxTest
~~~~~~~~~
Besides the attributes present on the ``avocado_qemu.Test`` base
class, the ``avocado_qemu.LinuxTest`` adds the following attributes:
distro
......
The name of the Linux distribution used as the guest image for the
test. The name should match the **Provider** column on the list
of images supported by the avocado.utils.vmimage library:
https://avocado-framework.readthedocs.io/en/latest/guides/writer/libs/vmimage.html#supported-images
distro_version
..............
The version of the Linux distribution as the guest image for the
test. The name should match the **Version** column on the list
of images supported by the avocado.utils.vmimage library:
https://avocado-framework.readthedocs.io/en/latest/guides/writer/libs/vmimage.html#supported-images
distro_checksum
...............
The sha256 hash of the guest image file used for the test.
If this value is not set in the code or by a test parameter (with the
same name), no validation on the integrity of the image will be
performed.
Parameter reference
-------------------
@ -950,6 +994,12 @@ architecture of a kernel or disk image to boot a VM with.
This parameter has a direct relation with the ``arch`` attribute. If
not given, it will default to None.
cpu
~~~
The cpu model that will be set to all QEMUMachine instances created
by the test.
machine
~~~~~~~
@ -962,6 +1012,38 @@ qemu_bin
The exact QEMU binary to be used on QEMUMachine.
LinuxTest
~~~~~~~~~
Besides the parameters present on the ``avocado_qemu.Test`` base
class, the ``avocado_qemu.LinuxTest`` adds the following parameters:
distro
......
The name of the Linux distribution used as the guest image for the
test. The name should match the **Provider** column on the list
of images supported by the avocado.utils.vmimage library:
https://avocado-framework.readthedocs.io/en/latest/guides/writer/libs/vmimage.html#supported-images
distro_version
..............
The version of the Linux distribution as the guest image for the
test. The name should match the **Version** column on the list
of images supported by the avocado.utils.vmimage library:
https://avocado-framework.readthedocs.io/en/latest/guides/writer/libs/vmimage.html#supported-images
distro_checksum
...............
The sha256 hash of the guest image file used for the test.
If this value is not set in the code or by this parameter no
validation on the integrity of the image will be performed.
Skipping tests
--------------
The Avocado framework provides Python decorators which allow for easily skip

View File

@ -1,4 +1,5 @@
QEMU_VENV_DIR=.dev-venv
QEMU_TOX_EXTRA_ARGS ?=
.PHONY: help
help:
@ -15,6 +16,8 @@ help:
@echo " These tests use the newest dependencies."
@echo " Requires: Python 3.6 - 3.10, and tox."
@echo " Hint (Fedora): 'sudo dnf install python3-tox python3.10'"
@echo " The variable QEMU_TOX_EXTRA_ARGS can be use to pass extra"
@echo " arguments to tox".
@echo ""
@echo "make check-dev:"
@echo " Run tests in a venv against your default python3 version."
@ -87,7 +90,7 @@ check:
.PHONY: check-tox
check-tox:
@tox
@tox $(QEMU_TOX_EXTRA_ARGS)
.PHONY: clean
clean:

View File

@ -96,7 +96,8 @@ class QEMUMachine:
socket_scm_helper: Optional[str] = None,
sock_dir: Optional[str] = None,
drain_console: bool = False,
console_log: Optional[str] = None):
console_log: Optional[str] = None,
log_dir: Optional[str] = None):
'''
Initialize a QEMUMachine
@ -110,6 +111,7 @@ class QEMUMachine:
@param sock_dir: where to create socket (defaults to base_temp_dir)
@param drain_console: (optional) True to drain console socket to buffer
@param console_log: (optional) path to console log file
@param log_dir: where to create and keep log files
@note: Qemu process is not started until launch() is used.
'''
# pylint: disable=too-many-arguments
@ -123,6 +125,7 @@ class QEMUMachine:
self._name = name or "qemu-%d" % os.getpid()
self._base_temp_dir = base_temp_dir
self._sock_dir = sock_dir or self._base_temp_dir
self._log_dir = log_dir
self._socket_scm_helper = socket_scm_helper
if monitor_address is not None:
@ -313,9 +316,12 @@ class QEMUMachine:
args.extend(['-device', device])
return args
def _pre_launch(self) -> None:
self._qemu_log_path = os.path.join(self.temp_dir, self._name + ".log")
@property
def args(self) -> List[str]:
"""Returns the list of arguments given to the QEMU binary."""
return self._args
def _pre_launch(self) -> None:
if self._console_set:
self._remove_files.append(self._console_address)
@ -332,6 +338,7 @@ class QEMUMachine:
# NOTE: Make sure any opened resources are *definitely* freed in
# _post_shutdown()!
# pylint: disable=consider-using-with
self._qemu_log_path = os.path.join(self.log_dir, self._name + ".log")
self._qemu_log_file = open(self._qemu_log_path, 'wb')
def _post_launch(self) -> None:
@ -770,3 +777,12 @@ class QEMUMachine:
self._temp_dir = tempfile.mkdtemp(prefix="qemu-machine-",
dir=self._base_temp_dir)
return self._temp_dir
@property
def log_dir(self) -> str:
"""
Returns a directory to be used for writing logs
"""
if self._log_dir is None:
return self.temp_dir
return self._log_dir

View File

@ -121,6 +121,7 @@ multi_line_output=3
[tox:tox]
envlist = py36, py37, py38, py39, py310
skip_missing_interpreters = true
[testenv]
allowlist_externals = make

View File

@ -96,7 +96,7 @@ AVOCADO_TAGS=$(patsubst %-softmmu,-t arch:%, $(filter %-softmmu,$(TARGETS)))
$(TESTS_VENV_DIR): $(TESTS_VENV_REQ)
$(call quiet-command, \
$(PYTHON) -m venv --system-site-packages $@, \
$(PYTHON) -m venv $@, \
VENV, $@)
$(call quiet-command, \
$(TESTS_VENV_DIR)/bin/python -m pip -q install -r $(TESTS_VENV_REQ), \

View File

@ -86,14 +86,17 @@ def _console_interaction(test, success_message, failure_message,
assert not keep_sending or send_string
if vm is None:
vm = test.vm
console = vm.console_socket.makefile()
console = vm.console_socket.makefile(mode='rb', encoding='utf-8')
console_logger = logging.getLogger('console')
while True:
if send_string:
vm.console_socket.sendall(send_string.encode())
if not keep_sending:
send_string = None # send only once
msg = console.readline().strip()
try:
msg = console.readline().decode().strip()
except UnicodeDecodeError:
msg = None
if not msg:
continue
console_logger.debug(msg)
@ -210,6 +213,9 @@ class Test(avocado.Test):
self.arch = self.params.get('arch',
default=self._get_unique_tag_val('arch'))
self.cpu = self.params.get('cpu',
default=self._get_unique_tag_val('cpu'))
self.machine = self.params.get('machine',
default=self._get_unique_tag_val('machine'))
@ -219,9 +225,13 @@ class Test(avocado.Test):
if self.qemu_bin is None:
self.cancel("No QEMU binary defined or found in the build tree")
def _new_vm(self, *args):
def _new_vm(self, name, *args):
self._sd = tempfile.TemporaryDirectory(prefix="avo_qemu_sock_")
vm = QEMUMachine(self.qemu_bin, sock_dir=self._sd.name)
vm = QEMUMachine(self.qemu_bin, base_temp_dir=self.workdir,
sock_dir=self._sd.name, log_dir=self.logdir)
self.log.debug('QEMUMachine "%s" created', name)
self.log.debug('QEMUMachine "%s" temp_dir: %s', name, vm.temp_dir)
self.log.debug('QEMUMachine "%s" log_dir: %s', name, vm.log_dir)
if args:
vm.add_args(*args)
return vm
@ -234,11 +244,34 @@ class Test(avocado.Test):
if not name:
name = str(uuid.uuid4())
if self._vms.get(name) is None:
self._vms[name] = self._new_vm(*args)
self._vms[name] = self._new_vm(name, *args)
if self.cpu is not None:
self._vms[name].add_args('-cpu', self.cpu)
if self.machine is not None:
self._vms[name].set_machine(self.machine)
return self._vms[name]
def set_vm_arg(self, arg, value):
"""
Set an argument to list of extra arguments to be given to the QEMU
binary. If the argument already exists then its value is replaced.
:param arg: the QEMU argument, such as "-cpu" in "-cpu host"
:type arg: str
:param value: the argument value, such as "host" in "-cpu host"
:type value: str
"""
if not arg or not value:
return
if arg not in self.vm.args:
self.vm.args.extend([arg, value])
else:
idx = self.vm.args.index(arg) + 1
if idx < len(self.vm.args):
self.vm.args[idx] = value
else:
self.vm.args.append(value)
def tearDown(self):
for vm in self._vms.values():
vm.shutdown()
@ -299,6 +332,103 @@ class LinuxSSHMixIn:
f'Guest command failed: {command}')
return stdout_lines, stderr_lines
class LinuxDistro:
"""Represents a Linux distribution
Holds information of known distros.
"""
#: A collection of known distros and their respective image checksum
KNOWN_DISTROS = {
'fedora': {
'31': {
'x86_64':
{'checksum': ('e3c1b309d9203604922d6e255c2c5d09'
'8a309c2d46215d8fc026954f3c5c27a0'),
'pxeboot_url': ('https://archives.fedoraproject.org/'
'pub/archive/fedora/linux/releases/31/'
'Everything/x86_64/os/images/pxeboot/'),
'kernel_params': ('root=UUID=b1438b9b-2cab-4065-a99a-'
'08a96687f73c ro no_timer_check '
'net.ifnames=0 console=tty1 '
'console=ttyS0,115200n8'),
},
'aarch64':
{'checksum': ('1e18d9c0cf734940c4b5d5ec592facae'
'd2af0ad0329383d5639c997fdf16fe49'),
'pxeboot_url': 'https://archives.fedoraproject.org/'
'pub/archive/fedora/linux/releases/31/'
'Everything/aarch64/os/images/pxeboot/',
'kernel_params': ('root=UUID=b6950a44-9f3c-4076-a9c2-'
'355e8475b0a7 ro earlyprintk=pl011,0x9000000'
' ignore_loglevel no_timer_check'
' printk.time=1 rd_NO_PLYMOUTH'
' console=ttyAMA0'),
},
'ppc64':
{'checksum': ('7c3528b85a3df4b2306e892199a9e1e4'
'3f991c506f2cc390dc4efa2026ad2f58')},
's390x':
{'checksum': ('4caaab5a434fd4d1079149a072fdc789'
'1e354f834d355069ca982fdcaf5a122d')},
},
'32': {
'aarch64':
{'checksum': ('b367755c664a2d7a26955bbfff985855'
'adfa2ca15e908baf15b4b176d68d3967'),
'pxeboot_url': ('http://dl.fedoraproject.org/pub/fedora/linux/'
'releases/32/Server/aarch64/os/images/'
'pxeboot/'),
'kernel_params': ('root=UUID=3df75b65-be8d-4db4-8655-'
'14d95c0e90c5 ro no_timer_check net.ifnames=0'
' console=tty1 console=ttyS0,115200n8'),
},
},
'33': {
'aarch64':
{'checksum': ('e7f75cdfd523fe5ac2ca9eeece68edc1'
'a81f386a17f969c1d1c7c87031008a6b'),
'pxeboot_url': ('http://dl.fedoraproject.org/pub/fedora/linux/'
'releases/33/Server/aarch64/os/images/'
'pxeboot/'),
'kernel_params': ('root=UUID=d20b3ffa-6397-4a63-a734-'
'1126a0208f8a ro no_timer_check net.ifnames=0'
' console=tty1 console=ttyS0,115200n8'
' console=tty0'),
},
},
}
}
def __init__(self, name, version, arch):
self.name = name
self.version = version
self.arch = arch
try:
info = self.KNOWN_DISTROS.get(name).get(version).get(arch)
except AttributeError:
# Unknown distro
info = None
self._info = info or {}
@property
def checksum(self):
"""Gets the cloud-image file checksum"""
return self._info.get('checksum', None)
@checksum.setter
def checksum(self, value):
self._info['checksum'] = value
@property
def pxeboot_url(self):
"""Gets the repository url where pxeboot files can be found"""
return self._info.get('pxeboot_url', None)
@property
def default_kernel_params(self):
"""Gets the default kernel parameters"""
return self._info.get('kernel_params', None)
class LinuxTest(Test, LinuxSSHMixIn):
"""Facilitates having a cloud-image Linux based available.
@ -308,12 +438,39 @@ class LinuxTest(Test, LinuxSSHMixIn):
"""
timeout = 900
chksum = None
distro = None
username = 'root'
password = 'password'
def _set_distro(self):
distro_name = self.params.get(
'distro',
default=self._get_unique_tag_val('distro'))
if not distro_name:
distro_name = 'fedora'
distro_version = self.params.get(
'distro_version',
default=self._get_unique_tag_val('distro_version'))
if not distro_version:
distro_version = '31'
self.distro = LinuxDistro(distro_name, distro_version, self.arch)
# The distro checksum behaves differently than distro name and
# version. First, it does not respect a tag with the same
# name, given that it's not expected to be used for filtering
# (distro name versions are the natural choice). Second, the
# order of precedence is: parameter, attribute and then value
# from KNOWN_DISTROS.
distro_checksum = self.params.get('distro_checksum',
default=None)
if distro_checksum:
self.distro.checksum = distro_checksum
def setUp(self, ssh_pubkey=None, network_device_type='virtio-net'):
super(LinuxTest, self).setUp()
self._set_distro()
self.vm.add_args('-smp', '2')
self.vm.add_args('-m', '1024')
# The following network device allows for SSH connections
@ -351,12 +508,14 @@ class LinuxTest(Test, LinuxSSHMixIn):
self.log.info('Downloading/preparing boot image')
# Fedora 31 only provides ppc64le images
image_arch = self.arch
if image_arch == 'ppc64':
image_arch = 'ppc64le'
if self.distro.name == 'fedora':
if image_arch == 'ppc64':
image_arch = 'ppc64le'
try:
boot = vmimage.get(
'fedora', arch=image_arch, version='31',
checksum=self.chksum,
self.distro.name, arch=image_arch, version=self.distro.version,
checksum=self.distro.checksum,
algorithm='sha256',
cache_dir=self.cache_dirs[0],
snapshot_dir=self.workdir)

View File

@ -20,8 +20,6 @@ class BootLinuxX8664(LinuxTest):
:avocado: tags=arch:x86_64
"""
chksum = 'e3c1b309d9203604922d6e255c2c5d098a309c2d46215d8fc026954f3c5c27a0'
def test_pc_i440fx_tcg(self):
"""
:avocado: tags=machine:pc
@ -66,8 +64,6 @@ class BootLinuxAarch64(LinuxTest):
:avocado: tags=machine:gic-version=2
"""
chksum = '1e18d9c0cf734940c4b5d5ec592facaed2af0ad0329383d5639c997fdf16fe49'
def add_common_args(self):
self.vm.add_args('-bios',
os.path.join(BUILD_DIR, 'pc-bios',
@ -83,7 +79,6 @@ class BootLinuxAarch64(LinuxTest):
"""
self.require_accelerator("tcg")
self.vm.add_args("-accel", "tcg")
self.vm.add_args("-cpu", "max")
self.vm.add_args("-machine", "virt,gic-version=2")
self.add_common_args()
self.launch_and_wait(set_up_ssh_connection=False)
@ -96,7 +91,6 @@ class BootLinuxAarch64(LinuxTest):
"""
self.require_accelerator("tcg")
self.vm.add_args("-accel", "tcg")
self.vm.add_args("-cpu", "max")
self.vm.add_args("-machine", "virt,gic-version=3")
self.add_common_args()
self.launch_and_wait(set_up_ssh_connection=False)
@ -108,7 +102,6 @@ class BootLinuxAarch64(LinuxTest):
"""
self.require_accelerator("kvm")
self.vm.add_args("-accel", "kvm")
self.vm.add_args("-cpu", "host")
self.vm.add_args("-machine", "virt,gic-version=host")
self.add_common_args()
self.launch_and_wait(set_up_ssh_connection=False)
@ -119,8 +112,6 @@ class BootLinuxPPC64(LinuxTest):
:avocado: tags=arch:ppc64
"""
chksum = '7c3528b85a3df4b2306e892199a9e1e43f991c506f2cc390dc4efa2026ad2f58'
def test_pseries_tcg(self):
"""
:avocado: tags=machine:pseries
@ -136,8 +127,6 @@ class BootLinuxS390X(LinuxTest):
:avocado: tags=arch:s390x
"""
chksum = '4caaab5a434fd4d1079149a072fdc7891e354f834d355069ca982fdcaf5a122d'
@skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab')
def test_s390_ccw_virtio_tcg(self):
"""

View File

@ -239,6 +239,7 @@ class BootLinuxConsole(LinuxKernelTest):
:avocado: tags=arch:mips64el
:avocado: tags=machine:malta
:avocado: tags=endian:little
:avocado: tags=cpu:5KEc
"""
kernel_url = ('https://github.com/philmd/qemu-testing-blob/'
'raw/9ad2df38/mips/malta/mips64el/'
@ -258,8 +259,7 @@ class BootLinuxConsole(LinuxKernelTest):
kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE
+ 'console=ttyS0 console=tty '
+ 'rdinit=/sbin/init noreboot')
self.vm.add_args('-cpu', '5KEc',
'-kernel', kernel_path,
self.vm.add_args('-kernel', kernel_path,
'-initrd', initrd_path,
'-append', kernel_command_line,
'-no-reboot')
@ -287,7 +287,6 @@ class BootLinuxConsole(LinuxKernelTest):
+ 'mem=256m@@0x0 '
+ 'console=ttyS0')
self.vm.add_args('-no-reboot',
'-cpu', 'I7200',
'-kernel', kernel_path,
'-append', kernel_command_line)
self.vm.launch()
@ -299,6 +298,7 @@ class BootLinuxConsole(LinuxKernelTest):
:avocado: tags=arch:mipsel
:avocado: tags=machine:malta
:avocado: tags=endian:little
:avocado: tags=cpu:I7200
"""
kernel_url = ('https://mipsdistros.mips.com/LinuxDistro/nanomips/'
'kernels/v4.15.18-432-gb2eb9a8b07a1-20180627102142/'
@ -311,6 +311,7 @@ class BootLinuxConsole(LinuxKernelTest):
:avocado: tags=arch:mipsel
:avocado: tags=machine:malta
:avocado: tags=endian:little
:avocado: tags=cpu:I7200
"""
kernel_url = ('https://mipsdistros.mips.com/LinuxDistro/nanomips/'
'kernels/v4.15.18-432-gb2eb9a8b07a1-20180627102142/'
@ -323,6 +324,7 @@ class BootLinuxConsole(LinuxKernelTest):
:avocado: tags=arch:mipsel
:avocado: tags=machine:malta
:avocado: tags=endian:little
:avocado: tags=cpu:I7200
"""
kernel_url = ('https://mipsdistros.mips.com/LinuxDistro/nanomips/'
'kernels/v4.15.18-432-gb2eb9a8b07a1-20180627102142/'
@ -335,6 +337,7 @@ class BootLinuxConsole(LinuxKernelTest):
:avocado: tags=arch:aarch64
:avocado: tags=machine:virt
:avocado: tags=accel:tcg
:avocado: tags=cpu:cortex-a53
"""
kernel_url = ('https://archives.fedoraproject.org/pub/archive/fedora'
'/linux/releases/29/Everything/aarch64/os/images/pxeboot'
@ -905,6 +908,7 @@ class BootLinuxConsole(LinuxKernelTest):
:avocado: tags=arch:arm
:avocado: tags=machine:orangepi-pc
:avocado: tags=device:sd
:avocado: tags=os:netbsd
"""
# This test download a 304MB compressed image and expand it to 2GB
deb_url = ('http://snapshot.debian.org/archive/debian/'
@ -1167,9 +1171,9 @@ class BootLinuxConsole(LinuxKernelTest):
"""
:avocado: tags=arch:ppc64
:avocado: tags=machine:ppce500
:avocado: tags=cpu:e5500
"""
tar_hash = '6951d86d644b302898da2fd701739c9406527fe1'
self.vm.add_args('-cpu', 'e5500')
self.do_test_advcal_2018('19', tar_hash, 'uImage')
def test_ppc_g3beige(self):
@ -1211,7 +1215,7 @@ class BootLinuxConsole(LinuxKernelTest):
"""
:avocado: tags=arch:xtensa
:avocado: tags=machine:lx60
:avocado: tags=cpu:dc233c
"""
tar_hash = '49e88d9933742f0164b60839886c9739cb7a0d34'
self.vm.add_args('-cpu', 'dc233c')
self.do_test_advcal_2018('02', tar_hash, 'santas-sleigh-ride.elf')

View File

@ -48,7 +48,6 @@ class BootXenBase(LinuxKernelTest):
xen_command_line = self.XEN_COMMON_COMMAND_LINE
self.vm.add_args('-machine', 'virtualization=on',
'-cpu', 'cortex-a57',
'-m', '768',
'-kernel', xen_path,
'-append', xen_command_line,

View File

@ -8,8 +8,6 @@
# This work is licensed under the terms of the GNU GPL, version 2 or
# later. See the COPYING file in the top-level directory.
import logging
from avocado_qemu import Test
class QueryCPUModelExpansion(Test):
@ -27,7 +25,7 @@ class QueryCPUModelExpansion(Test):
cpus = self.vm.command('query-cpu-definitions')
for c in cpus:
print(repr(c))
self.log.info("Checking CPU: %s", c)
self.assertNotIn('', c['unavailable-features'], c['name'])
for c in cpus:

View File

@ -0,0 +1,119 @@
# INTEL_IOMMU Functional tests
#
# Copyright (c) 2021 Red Hat, Inc.
#
# Author:
# Eric Auger <eric.auger@redhat.com>
#
# This work is licensed under the terms of the GNU GPL, version 2 or
# later. See the COPYING file in the top-level directory.
import os
from avocado import skipIf
from avocado_qemu import LinuxTest
@skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab')
class IntelIOMMU(LinuxTest):
"""
:avocado: tags=arch:x86_64
:avocado: tags=distro:fedora
:avocado: tags=distro_version:31
:avocado: tags=machine:q35
:avocado: tags=accel:kvm
:avocado: tags=intel_iommu
"""
IOMMU_ADDON = ',iommu_platform=on,disable-modern=off,disable-legacy=on'
kernel_path = None
initrd_path = None
kernel_params = None
def set_up_boot(self):
path = self.download_boot()
self.vm.add_args('-device', 'virtio-blk-pci,bus=pcie.0,scsi=off,' +
'drive=drv0,id=virtio-disk0,bootindex=1,'
'werror=stop,rerror=stop' + self.IOMMU_ADDON)
self.vm.add_args('-device', 'virtio-gpu-pci' + self.IOMMU_ADDON)
self.vm.add_args('-drive',
'file=%s,if=none,cache=writethrough,id=drv0' % path)
def setUp(self):
super(IntelIOMMU, self).setUp(None, 'virtio-net-pci' + self.IOMMU_ADDON)
def add_common_args(self):
self.vm.add_args('-device', 'virtio-rng-pci,rng=rng0')
self.vm.add_args('-object',
'rng-random,id=rng0,filename=/dev/urandom')
def common_vm_setup(self, custom_kernel=None):
self.require_accelerator("kvm")
self.add_common_args()
self.vm.add_args("-accel", "kvm")
if custom_kernel is None:
return
kernel_url = self.distro.pxeboot_url + 'vmlinuz'
initrd_url = self.distro.pxeboot_url + 'initrd.img'
self.kernel_path = self.fetch_asset(kernel_url)
self.initrd_path = self.fetch_asset(initrd_url)
def run_and_check(self):
if self.kernel_path:
self.vm.add_args('-kernel', self.kernel_path,
'-append', self.kernel_params,
'-initrd', self.initrd_path)
self.launch_and_wait()
self.ssh_command('cat /proc/cmdline')
self.ssh_command('dmesg | grep -e DMAR -e IOMMU')
self.ssh_command('find /sys/kernel/iommu_groups/ -type l')
self.ssh_command('dnf -y install numactl-devel')
def test_intel_iommu(self):
"""
:avocado: tags=intel_iommu_intremap
"""
self.common_vm_setup(True)
self.vm.add_args('-device', 'intel-iommu,intremap=on')
self.vm.add_args('-machine', 'kernel_irqchip=split')
self.kernel_params = (self.distro.default_kernel_params +
' quiet intel_iommu=on')
self.run_and_check()
def test_intel_iommu_strict(self):
"""
:avocado: tags=intel_iommu_strict
"""
self.common_vm_setup(True)
self.vm.add_args('-device', 'intel-iommu,intremap=on')
self.vm.add_args('-machine', 'kernel_irqchip=split')
self.kernel_params = (self.distro.default_kernel_params +
' quiet intel_iommu=on,strict')
self.run_and_check()
def test_intel_iommu_strict_cm(self):
"""
:avocado: tags=intel_iommu_strict_cm
"""
self.common_vm_setup(True)
self.vm.add_args('-device', 'intel-iommu,intremap=on,caching-mode=on')
self.vm.add_args('-machine', 'kernel_irqchip=split')
self.kernel_params = (self.distro.default_kernel_params +
' quiet intel_iommu=on,strict')
self.run_and_check()
def test_intel_iommu_pt(self):
"""
:avocado: tags=intel_iommu_pt
"""
self.common_vm_setup(True)
self.vm.add_args('-device', 'intel-iommu,intremap=on')
self.vm.add_args('-machine', 'kernel_irqchip=split')
self.kernel_params = (self.distro.default_kernel_params +
' quiet intel_iommu=on iommu=pt')
self.run_and_check()

View File

@ -19,6 +19,8 @@ from avocado.utils import archive
from avocado.utils import ssh
@skipUnless(os.getenv('AVOCADO_TIMEOUT_EXPECTED'), 'Test might timeout')
@skipUnless(ssh.SSH_CLIENT_BINARY, 'No SSH client available')
class LinuxSSH(Test, LinuxSSHMixIn):
timeout = 150 # Not for 'configure --enable-debug --enable-debug-tcg'
@ -65,11 +67,6 @@ class LinuxSSH(Test, LinuxSSHMixIn):
kernel_hash = self.IMAGE_INFO[endianess]['kernel_hash'][wordsize]
return kernel_url, kernel_hash
@skipUnless(ssh.SSH_CLIENT_BINARY, 'No SSH client available')
@skipUnless(os.getenv('AVOCADO_TIMEOUT_EXPECTED'), 'Test might timeout')
def setUp(self):
super(LinuxSSH, self).setUp()
def ssh_disconnect_vm(self):
self.ssh_session.quit()

View File

@ -62,7 +62,6 @@ class MaltaMachineFramebuffer(Test):
kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
'clocksource=GIC console=tty0 console=ttyS0')
self.vm.add_args('-kernel', kernel_path,
'-cpu', 'I6400',
'-smp', '%u' % cpu_cores_count,
'-vga', 'std',
'-append', kernel_command_line)
@ -96,7 +95,7 @@ class MaltaMachineFramebuffer(Test):
"""
:avocado: tags=arch:mips64el
:avocado: tags=machine:malta
:avocado: tags=cpu:i6400
:avocado: tags=cpu:I6400
"""
self.do_test_i6400_framebuffer_logo(1)
@ -105,7 +104,7 @@ class MaltaMachineFramebuffer(Test):
"""
:avocado: tags=arch:mips64el
:avocado: tags=machine:malta
:avocado: tags=cpu:i6400
:avocado: tags=cpu:I6400
:avocado: tags=mips:smp
"""
self.do_test_i6400_framebuffer_logo(7)
@ -115,7 +114,7 @@ class MaltaMachineFramebuffer(Test):
"""
:avocado: tags=arch:mips64el
:avocado: tags=machine:malta
:avocado: tags=cpu:i6400
:avocado: tags=cpu:I6400
:avocado: tags=mips:smp
"""
self.do_test_i6400_framebuffer_logo(8)

View File

@ -25,11 +25,11 @@ from avocado_qemu import Test
class OmittedCPUProps(Test):
"""
:avocado: tags=arch:x86_64
:avocado: tags=cpu:qemu64
"""
def test_no_die_id(self):
self.vm.add_args('-nodefaults', '-S')
self.vm.add_args('-smp', '1,sockets=2,cores=2,threads=2,maxcpus=8')
self.vm.add_args('-cpu', 'qemu64')
self.vm.add_args('-device', 'qemu64-x86_64-cpu,socket-id=1,core-id=0,thread-id=0')
self.vm.launch()
self.assertEquals(len(self.vm.command('query-cpus-fast')), 2)

View File

@ -27,6 +27,7 @@ class IbmPrep40pMachine(Test):
"""
:avocado: tags=arch:ppc
:avocado: tags=machine:40p
:avocado: tags=os:netbsd
:avocado: tags=slowness:high
"""
bios_url = ('http://ftpmirror.your.org/pub/misc/'
@ -64,6 +65,7 @@ class IbmPrep40pMachine(Test):
"""
:avocado: tags=arch:ppc
:avocado: tags=machine:40p
:avocado: tags=os:netbsd
"""
drive_url = ('https://cdn.netbsd.org/pub/NetBSD/iso/7.1.2/'
'NetBSD-7.1.2-prep.iso')

View File

@ -156,8 +156,7 @@ class ReplayKernelNormal(ReplayKernelBase):
'console=ttyAMA0')
console_pattern = 'VFS: Cannot open root device'
self.run_rr(kernel_path, kernel_command_line, console_pattern,
args=('-cpu', 'cortex-a53'))
self.run_rr(kernel_path, kernel_command_line, console_pattern)
def test_arm_virt(self):
"""
@ -301,7 +300,7 @@ class ReplayKernelNormal(ReplayKernelBase):
tar_url = ('https://www.qemu-advent-calendar.org'
'/2018/download/day19.tar.xz')
file_path = self.fetch_asset(tar_url, asset_hash=tar_hash)
self.do_test_advcal_2018(file_path, 'uImage', ('-cpu', 'e5500'))
self.do_test_advcal_2018(file_path, 'uImage')
def test_ppc_g3beige(self):
"""
@ -348,8 +347,7 @@ class ReplayKernelNormal(ReplayKernelBase):
tar_url = ('https://www.qemu-advent-calendar.org'
'/2018/download/day02.tar.xz')
file_path = self.fetch_asset(tar_url, asset_hash=tar_hash)
self.do_test_advcal_2018(file_path, 'santas-sleigh-ride.elf',
args=('-cpu', 'dc233c'))
self.do_test_advcal_2018(file_path, 'santas-sleigh-ride.elf')
@skipUnless(os.getenv('AVOCADO_TIMEOUT_EXPECTED'), 'Test might timeout')
class ReplayKernelSlow(ReplayKernelBase):
@ -394,6 +392,7 @@ class ReplayKernelSlow(ReplayKernelBase):
:avocado: tags=machine:malta
:avocado: tags=endian:little
:avocado: tags=slowness:high
:avocado: tags=cpu:5KEc
"""
kernel_url = ('https://github.com/philmd/qemu-testing-blob/'
'raw/9ad2df38/mips/malta/mips64el/'
@ -414,7 +413,7 @@ class ReplayKernelSlow(ReplayKernelBase):
'rdinit=/sbin/init noreboot')
console_pattern = 'Boot successful.'
self.run_rr(kernel_path, kernel_command_line, console_pattern, shift=5,
args=('-initrd', initrd_path, '-cpu', '5KEc'))
args=('-initrd', initrd_path))
def do_test_mips_malta32el_nanomips(self, kernel_path_xz):
kernel_path = self.workdir + "kernel"
@ -426,14 +425,14 @@ class ReplayKernelSlow(ReplayKernelBase):
'mem=256m@@0x0 '
'console=ttyS0')
console_pattern = 'Kernel command line: %s' % kernel_command_line
self.run_rr(kernel_path, kernel_command_line, console_pattern, shift=5,
args=('-cpu', 'I7200'))
self.run_rr(kernel_path, kernel_command_line, console_pattern, shift=5)
def test_mips_malta32el_nanomips_4k(self):
"""
:avocado: tags=arch:mipsel
:avocado: tags=machine:malta
:avocado: tags=endian:little
:avocado: tags=cpu:I7200
"""
kernel_url = ('https://mipsdistros.mips.com/LinuxDistro/nanomips/'
'kernels/v4.15.18-432-gb2eb9a8b07a1-20180627102142/'
@ -447,6 +446,7 @@ class ReplayKernelSlow(ReplayKernelBase):
:avocado: tags=arch:mipsel
:avocado: tags=machine:malta
:avocado: tags=endian:little
:avocado: tags=cpu:I7200
"""
kernel_url = ('https://mipsdistros.mips.com/LinuxDistro/nanomips/'
'kernels/v4.15.18-432-gb2eb9a8b07a1-20180627102142/'
@ -460,6 +460,7 @@ class ReplayKernelSlow(ReplayKernelBase):
:avocado: tags=arch:mipsel
:avocado: tags=machine:malta
:avocado: tags=endian:little
:avocado: tags=cpu:I7200
"""
kernel_url = ('https://mipsdistros.mips.com/LinuxDistro/nanomips/'
'kernels/v4.15.18-432-gb2eb9a8b07a1-20180627102142/'

View File

@ -207,4 +207,4 @@ class ReverseDebugging_AArch64(ReverseDebugging):
kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
self.reverse_debugging(
args=('-kernel', kernel_path, '-cpu', 'cortex-a53'))
args=('-kernel', kernel_path))

137
tests/acceptance/smmu.py Normal file
View File

@ -0,0 +1,137 @@
# SMMUv3 Functional tests
#
# Copyright (c) 2021 Red Hat, Inc.
#
# Author:
# Eric Auger <eric.auger@redhat.com>
#
# This work is licensed under the terms of the GNU GPL, version 2 or
# later. See the COPYING file in the top-level directory.
import os
from avocado import skipIf
from avocado_qemu import LinuxTest, BUILD_DIR
@skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab')
class SMMU(LinuxTest):
"""
:avocado: tags=accel:kvm
:avocado: tags=cpu:host
:avocado: tags=arch:aarch64
:avocado: tags=machine:virt
:avocado: tags=distro:fedora
:avocado: tags=smmu
"""
IOMMU_ADDON = ',iommu_platform=on,disable-modern=off,disable-legacy=on'
kernel_path = None
initrd_path = None
kernel_params = None
def set_up_boot(self):
path = self.download_boot()
self.vm.add_args('-device', 'virtio-blk-pci,bus=pcie.0,scsi=off,' +
'drive=drv0,id=virtio-disk0,bootindex=1,'
'werror=stop,rerror=stop' + self.IOMMU_ADDON)
self.vm.add_args('-drive',
'file=%s,if=none,cache=writethrough,id=drv0' % path)
def setUp(self):
super(SMMU, self).setUp(None, 'virtio-net-pci' + self.IOMMU_ADDON)
def common_vm_setup(self, custom_kernel=False):
self.require_accelerator("kvm")
self.vm.add_args("-accel", "kvm")
self.vm.add_args("-cpu", "host")
self.vm.add_args("-machine", "iommu=smmuv3")
self.vm.add_args("-d", "guest_errors")
self.vm.add_args('-bios', os.path.join(BUILD_DIR, 'pc-bios',
'edk2-aarch64-code.fd'))
self.vm.add_args('-device', 'virtio-rng-pci,rng=rng0')
self.vm.add_args('-object',
'rng-random,id=rng0,filename=/dev/urandom')
if custom_kernel is False:
return
kernel_url = self.distro.pxeboot_url + 'vmlinuz'
initrd_url = self.distro.pxeboot_url + 'initrd.img'
self.kernel_path = self.fetch_asset(kernel_url)
self.initrd_path = self.fetch_asset(initrd_url)
def run_and_check(self):
if self.kernel_path:
self.vm.add_args('-kernel', self.kernel_path,
'-append', self.kernel_params,
'-initrd', self.initrd_path)
self.launch_and_wait()
self.ssh_command('cat /proc/cmdline')
self.ssh_command('dnf -y install numactl-devel')
# 5.3 kernel without RIL #
def test_smmu_noril(self):
"""
:avocado: tags=smmu_noril
:avocado: tags=smmu_noril_tests
:avocado: tags=distro_version:31
"""
self.common_vm_setup()
self.run_and_check()
def test_smmu_noril_passthrough(self):
"""
:avocado: tags=smmu_noril_passthrough
:avocado: tags=smmu_noril_tests
:avocado: tags=distro_version:31
"""
self.common_vm_setup(True)
self.kernel_params = (self.distro.default_kernel_params +
' iommu.passthrough=on')
self.run_and_check()
def test_smmu_noril_nostrict(self):
"""
:avocado: tags=smmu_noril_nostrict
:avocado: tags=smmu_noril_tests
:avocado: tags=distro_version:31
"""
self.common_vm_setup(True)
self.kernel_params = (self.distro.default_kernel_params +
' iommu.strict=0')
self.run_and_check()
# 5.8 kernel featuring range invalidation
# >= v5.7 kernel
def test_smmu_ril(self):
"""
:avocado: tags=smmu_ril
:avocado: tags=smmu_ril_tests
:avocado: tags=distro_version:33
"""
self.common_vm_setup()
self.run_and_check()
def test_smmu_ril_passthrough(self):
"""
:avocado: tags=smmu_ril_passthrough
:avocado: tags=smmu_ril_tests
:avocado: tags=distro_version:33
"""
self.common_vm_setup(True)
self.kernel_params = (self.distro.default_kernel_params +
' iommu.passthrough=on')
self.run_and_check()
def test_smmu_ril_nostrict(self):
"""
:avocado: tags=smmu_ril_nostrict
:avocado: tags=smmu_ril_tests
:avocado: tags=distro_version:33
"""
self.common_vm_setup(True)
self.kernel_params = (self.distro.default_kernel_params +
' iommu.strict=0')
self.run_and_check()

View File

@ -25,7 +25,7 @@ class PluginKernelBase(LinuxKernelTest):
KERNEL_COMMON_COMMAND_LINE = 'printk.time=1 panic=-1 '
def run_vm(self, kernel_path, kernel_command_line,
plugin, plugin_log, console_pattern, args):
plugin, plugin_log, console_pattern, args=None):
vm = self.get_vm()
vm.set_console()
@ -68,7 +68,7 @@ class PluginKernelNormal(PluginKernelBase):
:avocado: tags=accel:tcg
:avocado: tags=arch:aarch64
:avocado: tags=machine:virt
:avocado: tags=cpu:cortex-a57
:avocado: tags=cpu:cortex-a53
"""
kernel_path = self._grab_aarch64_kernel()
kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
@ -80,8 +80,7 @@ class PluginKernelNormal(PluginKernelBase):
self.run_vm(kernel_path, kernel_command_line,
"tests/plugin/libinsn.so", plugin_log.name,
console_pattern,
args=('-cpu', 'cortex-a53'))
console_pattern)
with plugin_log as lf, \
mmap.mmap(lf.fileno(), 0, access=mmap.ACCESS_READ) as s:
@ -95,7 +94,7 @@ class PluginKernelNormal(PluginKernelBase):
:avocado: tags=accel:tcg
:avocado: tags=arch:aarch64
:avocado: tags=machine:virt
:avocado: tags=cpu:cortex-a57
:avocado: tags=cpu:cortex-a53
"""
kernel_path = self._grab_aarch64_kernel()
kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
@ -108,7 +107,7 @@ class PluginKernelNormal(PluginKernelBase):
self.run_vm(kernel_path, kernel_command_line,
"tests/plugin/libinsn.so", plugin_log.name,
console_pattern,
args=('-cpu', 'cortex-a53', '-icount', 'shift=1'))
args=('-icount', 'shift=1'))
with plugin_log as lf, \
mmap.mmap(lf.fileno(), 0, access=mmap.ACCESS_READ) as s:
@ -121,7 +120,7 @@ class PluginKernelNormal(PluginKernelBase):
:avocado: tags=accel:tcg
:avocado: tags=arch:aarch64
:avocado: tags=machine:virt
:avocado: tags=cpu:cortex-a57
:avocado: tags=cpu:cortex-a53
"""
kernel_path = self._grab_aarch64_kernel()
kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
@ -134,7 +133,7 @@ class PluginKernelNormal(PluginKernelBase):
self.run_vm(kernel_path, kernel_command_line,
"tests/plugin/libmem.so,arg=both", plugin_log.name,
console_pattern,
args=('-cpu', 'cortex-a53', '-icount', 'shift=1'))
args=('-icount', 'shift=1'))
with plugin_log as lf, \
mmap.mmap(lf.fileno(), 0, access=mmap.ACCESS_READ) as s:

View File

@ -60,6 +60,7 @@ class VirtioGPUx86(Test):
"""
:avocado: tags=arch:x86_64
:avocado: tags=device:virtio-vga
:avocado: tags=cpu:host
"""
kernel_command_line = (
self.KERNEL_COMMON_COMMAND_LINE + "console=ttyS0 rdinit=/bin/bash"
@ -72,7 +73,6 @@ class VirtioGPUx86(Test):
initrd_path = self.fetch_asset(self.INITRD_URL)
self.vm.set_console()
self.vm.add_args("-cpu", "host")
self.vm.add_args("-m", "2G")
self.vm.add_args("-machine", "pc,accel=kvm")
self.vm.add_args("-device", "virtio-vga,virgl=on")
@ -101,6 +101,7 @@ class VirtioGPUx86(Test):
"""
:avocado: tags=arch:x86_64
:avocado: tags=device:vhost-user-vga
:avocado: tags=cpu:host
"""
kernel_command_line = (
self.KERNEL_COMMON_COMMAND_LINE + "console=ttyS0 rdinit=/bin/bash"
@ -140,7 +141,6 @@ class VirtioGPUx86(Test):
)
self.vm.set_console()
self.vm.add_args("-cpu", "host")
self.vm.add_args("-m", "2G")
self.vm.add_args("-object", "memory-backend-memfd,id=mem,size=2G")
self.vm.add_args("-machine", "pc,memory-backend=mem,accel=kvm")

View File

@ -252,10 +252,13 @@ class CascadelakeArchCapabilities(avocado_qemu.Test):
def test_4_1(self):
"""
:avocado: tags=machine:pc-i440fx-4.1
:avocado: tags=cpu:Cascadelake-Server
"""
# machine-type only:
self.vm.add_args('-S')
self.vm.add_args('-cpu', 'Cascadelake-Server,x-force-features=on,check=off,enforce=off')
self.set_vm_arg('-cpu',
'Cascadelake-Server,x-force-features=on,check=off,'
'enforce=off')
self.vm.launch()
self.assertFalse(self.get_cpu_prop('arch-capabilities'),
'pc-i440fx-4.1 + Cascadelake-Server should not have arch-capabilities')
@ -263,9 +266,12 @@ class CascadelakeArchCapabilities(avocado_qemu.Test):
def test_4_0(self):
"""
:avocado: tags=machine:pc-i440fx-4.0
:avocado: tags=cpu:Cascadelake-Server
"""
self.vm.add_args('-S')
self.vm.add_args('-cpu', 'Cascadelake-Server,x-force-features=on,check=off,enforce=off')
self.set_vm_arg('-cpu',
'Cascadelake-Server,x-force-features=on,check=off,'
'enforce=off')
self.vm.launch()
self.assertFalse(self.get_cpu_prop('arch-capabilities'),
'pc-i440fx-4.0 + Cascadelake-Server should not have arch-capabilities')
@ -273,10 +279,13 @@ class CascadelakeArchCapabilities(avocado_qemu.Test):
def test_set_4_0(self):
"""
:avocado: tags=machine:pc-i440fx-4.0
:avocado: tags=cpu:Cascadelake-Server
"""
# command line must override machine-type if CPU model is not versioned:
self.vm.add_args('-S')
self.vm.add_args('-cpu', 'Cascadelake-Server,x-force-features=on,check=off,enforce=off,+arch-capabilities')
self.set_vm_arg('-cpu',
'Cascadelake-Server,x-force-features=on,check=off,'
'enforce=off,+arch-capabilities')
self.vm.launch()
self.assertTrue(self.get_cpu_prop('arch-capabilities'),
'pc-i440fx-4.0 + Cascadelake-Server,+arch-capabilities should have arch-capabilities')
@ -284,9 +293,12 @@ class CascadelakeArchCapabilities(avocado_qemu.Test):
def test_unset_4_1(self):
"""
:avocado: tags=machine:pc-i440fx-4.1
:avocado: tags=cpu:Cascadelake-Server
"""
self.vm.add_args('-S')
self.vm.add_args('-cpu', 'Cascadelake-Server,x-force-features=on,check=off,enforce=off,-arch-capabilities')
self.set_vm_arg('-cpu',
'Cascadelake-Server,x-force-features=on,check=off,'
'enforce=off,-arch-capabilities')
self.vm.launch()
self.assertFalse(self.get_cpu_prop('arch-capabilities'),
'pc-i440fx-4.1 + Cascadelake-Server,-arch-capabilities should not have arch-capabilities')
@ -294,10 +306,13 @@ class CascadelakeArchCapabilities(avocado_qemu.Test):
def test_v1_4_0(self):
"""
:avocado: tags=machine:pc-i440fx-4.0
:avocado: tags=cpu:Cascadelake-Server
"""
# versioned CPU model overrides machine-type:
self.vm.add_args('-S')
self.vm.add_args('-cpu', 'Cascadelake-Server-v1,x-force-features=on,check=off,enforce=off')
self.set_vm_arg('-cpu',
'Cascadelake-Server-v1,x-force-features=on,check=off,'
'enforce=off')
self.vm.launch()
self.assertFalse(self.get_cpu_prop('arch-capabilities'),
'pc-i440fx-4.0 + Cascadelake-Server-v1 should not have arch-capabilities')
@ -305,9 +320,12 @@ class CascadelakeArchCapabilities(avocado_qemu.Test):
def test_v2_4_0(self):
"""
:avocado: tags=machine:pc-i440fx-4.0
:avocado: tags=cpu:Cascadelake-Server
"""
self.vm.add_args('-S')
self.vm.add_args('-cpu', 'Cascadelake-Server-v2,x-force-features=on,check=off,enforce=off')
self.set_vm_arg('-cpu',
'Cascadelake-Server-v2,x-force-features=on,check=off,'
'enforce=off')
self.vm.launch()
self.assertTrue(self.get_cpu_prop('arch-capabilities'),
'pc-i440fx-4.0 + Cascadelake-Server-v2 should have arch-capabilities')
@ -315,10 +333,13 @@ class CascadelakeArchCapabilities(avocado_qemu.Test):
def test_v1_set_4_0(self):
"""
:avocado: tags=machine:pc-i440fx-4.0
:avocado: tags=cpu:Cascadelake-Server
"""
# command line must override machine-type and versioned CPU model:
self.vm.add_args('-S')
self.vm.add_args('-cpu', 'Cascadelake-Server-v1,x-force-features=on,check=off,enforce=off,+arch-capabilities')
self.set_vm_arg('-cpu',
'Cascadelake-Server-v1,x-force-features=on,check=off,'
'enforce=off,+arch-capabilities')
self.vm.launch()
self.assertTrue(self.get_cpu_prop('arch-capabilities'),
'pc-i440fx-4.0 + Cascadelake-Server-v1,+arch-capabilities should have arch-capabilities')
@ -326,9 +347,12 @@ class CascadelakeArchCapabilities(avocado_qemu.Test):
def test_v2_unset_4_1(self):
"""
:avocado: tags=machine:pc-i440fx-4.1
:avocado: tags=cpu:Cascadelake-Server
"""
self.vm.add_args('-S')
self.vm.add_args('-cpu', 'Cascadelake-Server-v2,x-force-features=on,check=off,enforce=off,-arch-capabilities')
self.set_vm_arg('-cpu',
'Cascadelake-Server-v2,x-force-features=on,check=off,'
'enforce=off,-arch-capabilities')
self.vm.launch()
self.assertFalse(self.get_cpu_prop('arch-capabilities'),
'pc-i440fx-4.1 + Cascadelake-Server-v2,-arch-capabilities should not have arch-capabilities')