diff mbox series

[v7,3/8] Acceptance tests: use avocado tags for machine type

Message ID 20191104151323.9883-4-crosa@redhat.com
State New
Headers show
Series Acceptance test: Add "boot_linux" acceptance test | expand

Commit Message

Cleber Rosa Nov. 4, 2019, 3:13 p.m. UTC
The same way the arch tag is being used as a fallback for the arch
parameter, let's do the same for QEMU's machine and avoid some boiler
plate code.

Signed-off-by: Cleber Rosa <crosa@redhat.com>
---
 docs/devel/testing.rst                     | 18 ++++++++
 tests/acceptance/avocado_qemu/__init__.py  |  5 ++
 tests/acceptance/boot_linux_console.py     | 19 +-------
 tests/acceptance/cpu_queries.py            |  2 +-
 tests/acceptance/linux_initrd.py           |  2 +-
 tests/acceptance/linux_ssh_mips_malta.py   |  5 --
 tests/acceptance/machine_m68k_nextcube.py  | 21 ++-------
 tests/acceptance/machine_sparc_leon3.py    |  3 +-
 tests/acceptance/ppc_prep_40p.py           |  3 --
 tests/acceptance/x86_cpu_model_versions.py | 53 ++++++++++++++++------
 10 files changed, 72 insertions(+), 59 deletions(-)

Comments

Philippe Mathieu-Daudé Nov. 8, 2019, 1:20 p.m. UTC | #1
On 11/4/19 4:13 PM, Cleber Rosa wrote:
> The same way the arch tag is being used as a fallback for the arch
> parameter, let's do the same for QEMU's machine and avoid some boiler
> plate code.
> 
> Signed-off-by: Cleber Rosa <crosa@redhat.com>
> ---
>   docs/devel/testing.rst                     | 18 ++++++++
>   tests/acceptance/avocado_qemu/__init__.py  |  5 ++
>   tests/acceptance/boot_linux_console.py     | 19 +-------
>   tests/acceptance/cpu_queries.py            |  2 +-
>   tests/acceptance/linux_initrd.py           |  2 +-
>   tests/acceptance/linux_ssh_mips_malta.py   |  5 --
>   tests/acceptance/machine_m68k_nextcube.py  | 21 ++-------
>   tests/acceptance/machine_sparc_leon3.py    |  3 +-
>   tests/acceptance/ppc_prep_40p.py           |  3 --
>   tests/acceptance/x86_cpu_model_versions.py | 53 ++++++++++++++++------
>   10 files changed, 72 insertions(+), 59 deletions(-)
> 
> diff --git a/docs/devel/testing.rst b/docs/devel/testing.rst
> index 8e981e062d..27f286858a 100644
> --- a/docs/devel/testing.rst
> +++ b/docs/devel/testing.rst
> @@ -746,6 +746,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``.
>   
> +machine
> +~~~~~~~
> +
> +The machine type that will be set to all QEMUMachine instances created
> +by the test.
> +
> +The ``machine`` 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=machine:VALUE`` tag, it will be set to ``VALUE``.
> +
>   qemu_bin
>   ~~~~~~~~
>   
> @@ -781,6 +792,13 @@ 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.
>   
> +machine
> +~~~~~~~
> +
> +The machine type that will be set to all QEMUMachine instances created
> +by the test.
> +
> +
>   qemu_bin
>   ~~~~~~~~
>   
> diff --git a/tests/acceptance/avocado_qemu/__init__.py b/tests/acceptance/avocado_qemu/__init__.py
> index e676d9c4e7..6618ea67c1 100644
> --- a/tests/acceptance/avocado_qemu/__init__.py
> +++ b/tests/acceptance/avocado_qemu/__init__.py
> @@ -115,6 +115,9 @@ class Test(avocado.Test):
>           self.arch = self.params.get('arch',
>                                       default=self._get_unique_tag_val('arch'))
>   
> +        self.machine = self.params.get('machine',
> +                                       default=self._get_unique_tag_val('machine'))
> +
>           default_qemu_bin = pick_default_qemu_bin(arch=self.arch)
>           self.qemu_bin = self.params.get('qemu_bin',
>                                           default=default_qemu_bin)
> @@ -136,6 +139,8 @@ class Test(avocado.Test):
>               name = str(uuid.uuid4())
>           if self._vms.get(name) is None:
>               self._vms[name] = self._new_vm(*args)
> +            if self.machine is not None:
> +                self._vms[name].set_machine(self.machine)
>           return self._vms[name]
>   
>       def tearDown(self):
> diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py
> index 7e41cebd47..6732cc59ca 100644
> --- a/tests/acceptance/boot_linux_console.py
> +++ b/tests/acceptance/boot_linux_console.py
> @@ -62,7 +62,6 @@ class BootLinuxConsole(Test):
>           kernel_hash = '23bebd2680757891cf7adedb033532163a792495'
>           kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
>   
> -        self.vm.set_machine('pc')
>           self.vm.set_console()
>           kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0'
>           self.vm.add_args('-kernel', kernel_path,
> @@ -85,7 +84,6 @@ class BootLinuxConsole(Test):
>           kernel_path = self.extract_from_deb(deb_path,
>                                               '/boot/vmlinux-2.6.32-5-4kc-malta')
>   
> -        self.vm.set_machine('malta')
>           self.vm.set_console()
>           kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0'
>           self.vm.add_args('-kernel', kernel_path,
> @@ -118,7 +116,6 @@ class BootLinuxConsole(Test):
>           kernel_path = self.extract_from_deb(deb_path,
>                                               '/boot/vmlinux-2.6.32-5-5kc-malta')
>   
> -        self.vm.set_machine('malta')
>           self.vm.set_console()
>           kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0'
>           self.vm.add_args('-kernel', kernel_path,
> @@ -148,7 +145,6 @@ class BootLinuxConsole(Test):
>           initrd_path = self.workdir + "rootfs.cpio"
>           archive.gzip_uncompress(initrd_path_gz, initrd_path)
>   
> -        self.vm.set_machine('malta')
>           self.vm.set_console()
>           kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE
>                                  + 'console=ttyS0 console=tty '
> @@ -188,7 +184,6 @@ class BootLinuxConsole(Test):
>           initrd_path = self.workdir + "rootfs.cpio"
>           archive.gzip_uncompress(initrd_path_gz, initrd_path)
>   
> -        self.vm.set_machine('malta')
>           self.vm.set_console()
>           kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE
>                                  + 'console=ttyS0 console=tty '
> @@ -215,7 +210,6 @@ class BootLinuxConsole(Test):
>               with open(kernel_path, 'wb') as f_out:
>                   shutil.copyfileobj(f_in, f_out)
>   
> -        self.vm.set_machine('malta')
>           self.vm.set_console()
>           kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE
>                                  + 'mem=256m@@0x0 '
> @@ -275,7 +269,6 @@ class BootLinuxConsole(Test):
>           kernel_hash = '8c73e469fc6ea06a58dc83a628fc695b693b8493'
>           kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
>   
> -        self.vm.set_machine('virt')
>           self.vm.set_console()
>           kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
>                                  'console=ttyAMA0')
> @@ -297,7 +290,6 @@ class BootLinuxConsole(Test):
>           kernel_hash = 'e9826d741b4fb04cadba8d4824d1ed3b7fb8b4d4'
>           kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
>   
> -        self.vm.set_machine('virt')
>           self.vm.set_console()
>           kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
>                                  'console=ttyAMA0')
> @@ -310,7 +302,7 @@ class BootLinuxConsole(Test):
>       def test_arm_emcraft_sf2(self):
>           """
>           :avocado: tags=arch:arm
> -        :avocado: tags=machine:emcraft_sf2
> +        :avocado: tags=machine:emcraft-sf2

Maybe add a comment about this change, "Since avocado 72(?) we can ... 
so use ..."

>           :avocado: tags=endian:little
>           """
>           uboot_url = ('https://raw.githubusercontent.com/'
> @@ -324,7 +316,6 @@ class BootLinuxConsole(Test):
>           spi_hash = '85f698329d38de63aea6e884a86fbde70890a78a'
>           spi_path = self.fetch_asset(spi_url, asset_hash=spi_hash)
>   
> -        self.vm.set_machine('emcraft-sf2')
>           self.vm.set_console()
>           kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE
>           self.vm.add_args('-kernel', uboot_path,
> @@ -351,7 +342,6 @@ class BootLinuxConsole(Test):
>           kernel_path = self.extract_from_deb(deb_path, '/boot/kernel7.img')
>           dtb_path = self.extract_from_deb(deb_path, '/boot/bcm2709-rpi-2-b.dtb')
>   
> -        self.vm.set_machine('raspi2')
>           self.vm.set_console()
>           kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
>                                  serial_kernel_cmdline[uart_id])
> @@ -393,7 +383,6 @@ class BootLinuxConsole(Test):
>           initrd_path = os.path.join(self.workdir, 'rootfs.cpio')
>           archive.gzip_uncompress(initrd_path_gz, initrd_path)
>   
> -        self.vm.set_machine('smdkc210')
>           self.vm.set_console()
>           kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
>                                  'earlycon=exynos4210,0x13800000 earlyprintk ' +
> @@ -414,7 +403,7 @@ class BootLinuxConsole(Test):
>       def test_s390x_s390_ccw_virtio(self):
>           """
>           :avocado: tags=arch:s390x
> -        :avocado: tags=machine:s390_ccw_virtio
> +        :avocado: tags=machine:s390-ccw-virtio
>           """
>           kernel_url = ('https://archives.fedoraproject.org/pub/archive'
>                         '/fedora-secondary/releases/29/Everything/s390x/os/images'
> @@ -422,7 +411,6 @@ class BootLinuxConsole(Test):
>           kernel_hash = 'e8e8439103ef8053418ef062644ffd46a7919313'
>           kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
>   
> -        self.vm.set_machine('s390-ccw-virtio')
>           self.vm.set_console()
>           kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=sclp0'
>           self.vm.add_args('-nodefaults',
> @@ -444,7 +432,6 @@ class BootLinuxConsole(Test):
>   
>           uncompressed_kernel = archive.uncompress(kernel_path, self.workdir)
>   
> -        self.vm.set_machine('clipper')
>           self.vm.set_console()
>           kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0'
>           self.vm.add_args('-vga', 'std',
> @@ -465,7 +452,6 @@ class BootLinuxConsole(Test):
>           kernel_hash = '3fe04abfc852b66653b8c3c897a59a689270bc77'
>           kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
>   
> -        self.vm.set_machine('pseries')
>           self.vm.set_console()
>           kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=hvc0'
>           self.vm.add_args('-kernel', kernel_path,
> @@ -489,7 +475,6 @@ class BootLinuxConsole(Test):
>           kernel_path = self.extract_from_deb(deb_path,
>                                               '/boot/vmlinux-5.3.0-1-m68k')
>   
> -        self.vm.set_machine('q800')
>           self.vm.set_console()
>           kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
>                                  'console=ttyS0 vga=off')
> diff --git a/tests/acceptance/cpu_queries.py b/tests/acceptance/cpu_queries.py
> index af47d2795a..293dccb89a 100644
> --- a/tests/acceptance/cpu_queries.py
> +++ b/tests/acceptance/cpu_queries.py
> @@ -20,8 +20,8 @@ class QueryCPUModelExpansion(Test):
>       def test(self):
>           """
>           :avocado: tags=arch:x86_64
> +        :avocado: tags=machine:none

Not to confuse with None :)

>           """
> -        self.vm.set_machine('none')
>           self.vm.add_args('-S')
>           self.vm.launch()
>   
> diff --git a/tests/acceptance/linux_initrd.py b/tests/acceptance/linux_initrd.py
> index c61d9826a4..3a0ff7b098 100644
> --- a/tests/acceptance/linux_initrd.py
> +++ b/tests/acceptance/linux_initrd.py
> @@ -20,6 +20,7 @@ class LinuxInitrd(Test):
>       Checks QEMU evaluates correctly the initrd file passed as -initrd option.
>   
>       :avocado: tags=arch:x86_64
> +    :avocado: tags=machine:pc

For some tests we can run on multiple machines (here q35), I was tempted 
to use multiple tags. How could I do that now?

>       """
>   
>       timeout = 300
> @@ -66,7 +67,6 @@ class LinuxInitrd(Test):
>               initrd.write(b'\0')
>               initrd.flush()
>   
> -            self.vm.set_machine('pc')
>               self.vm.set_console()
>               kernel_command_line = 'console=ttyS0'
>               self.vm.add_args('-kernel', kernel_path,
> diff --git a/tests/acceptance/linux_ssh_mips_malta.py b/tests/acceptance/linux_ssh_mips_malta.py
> index fc13f9e4d4..1d570deb00 100644
> --- a/tests/acceptance/linux_ssh_mips_malta.py
> +++ b/tests/acceptance/linux_ssh_mips_malta.py
> @@ -111,7 +111,6 @@ class LinuxSSH(Test):
>           image_url, image_hash = self.get_image_info(endianess)
>           image_path = self.fetch_asset(image_url, asset_hash=image_hash)
>   
> -        self.vm.set_machine('malta')
>           self.vm.set_console()
>           kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE
>                                  + 'console=ttyS0 root=/dev/sda1')
> @@ -215,7 +214,6 @@ class LinuxSSH(Test):
>       def test_mips_malta32eb_kernel3_2_0(self):
>           """
>           :avocado: tags=arch:mips
> -        :avocado: tags=machine:malta
>           :avocado: tags=endian:big
>           :avocado: tags=device:pcnet32
>           """
> @@ -224,7 +222,6 @@ class LinuxSSH(Test):
>       def test_mips_malta32el_kernel3_2_0(self):
>           """
>           :avocado: tags=arch:mipsel
> -        :avocado: tags=machine:malta
>           :avocado: tags=endian:little
>           :avocado: tags=device:pcnet32
>           """
> @@ -233,7 +230,6 @@ class LinuxSSH(Test):
>       def test_mips_malta64eb_kernel3_2_0(self):
>           """
>           :avocado: tags=arch:mips64
> -        :avocado: tags=machine:malta
>           :avocado: tags=endian:big
>           :avocado: tags=device:pcnet32
>           """
> @@ -242,7 +238,6 @@ class LinuxSSH(Test):
>       def test_mips_malta64el_kernel3_2_0(self):
>           """
>           :avocado: tags=arch:mips64el
> -        :avocado: tags=machine:malta
>           :avocado: tags=endian:little
>           :avocado: tags=device:pcnet32
>           """
> diff --git a/tests/acceptance/machine_m68k_nextcube.py b/tests/acceptance/machine_m68k_nextcube.py
> index fcd2c58ee7..32cf571f94 100644
> --- a/tests/acceptance/machine_m68k_nextcube.py
> +++ b/tests/acceptance/machine_m68k_nextcube.py
> @@ -43,6 +43,11 @@ def tesseract_available(expected_version):
>   
>   
>   class NextCubeMachine(Test):
> +    """
> +    :avocado: tags=arch:m68k
> +    :avocado: tags=machine:next-cube
> +    :avocado: tags=device:framebuffer
> +    """
>   
>       timeout = 15
>   
> @@ -52,7 +57,6 @@ class NextCubeMachine(Test):
>           rom_hash = 'b3534796abae238a0111299fc406a9349f7fee24'
>           rom_path = self.fetch_asset(rom_url, asset_hash=rom_hash)
>   
> -        self.vm.set_machine('next-cube')
>           self.vm.add_args('-bios', rom_path)
>           self.vm.launch()
>   
> @@ -66,11 +70,6 @@ class NextCubeMachine(Test):
>   
>       @skipUnless(PIL_AVAILABLE, 'Python PIL not installed')
>       def test_bootrom_framebuffer_size(self):
> -        """
> -        :avocado: tags=arch:m68k
> -        :avocado: tags=machine:next_cube
> -        :avocado: tags=device:framebuffer
> -        """
>           screenshot_path = os.path.join(self.workdir, "dump.png")
>           self.check_bootrom_framebuffer(screenshot_path)
>   
> @@ -80,11 +79,6 @@ class NextCubeMachine(Test):
>   
>       @skipUnless(tesseract_available(3), 'tesseract v3 OCR tool not available')
>       def test_bootrom_framebuffer_ocr_with_tesseract_v3(self):
> -        """
> -        :avocado: tags=arch:m68k
> -        :avocado: tags=machine:next_cube
> -        :avocado: tags=device:framebuffer
> -        """
>           screenshot_path = os.path.join(self.workdir, "dump.png")
>           self.check_bootrom_framebuffer(screenshot_path)
>   
> @@ -101,11 +95,6 @@ class NextCubeMachine(Test):
>       # that it is still alpha-level software.
>       @skipUnless(tesseract_available(4), 'tesseract v4 OCR tool not available')
>       def test_bootrom_framebuffer_ocr_with_tesseract_v4(self):
> -        """
> -        :avocado: tags=arch:m68k
> -        :avocado: tags=machine:next_cube
> -        :avocado: tags=device:framebuffer
> -        """
>           screenshot_path = os.path.join(self.workdir, "dump.png")
>           self.check_bootrom_framebuffer(screenshot_path)
>   
> diff --git a/tests/acceptance/machine_sparc_leon3.py b/tests/acceptance/machine_sparc_leon3.py
> index 298f1e25e6..f77e210ccb 100644
> --- a/tests/acceptance/machine_sparc_leon3.py
> +++ b/tests/acceptance/machine_sparc_leon3.py
> @@ -16,7 +16,7 @@ class Leon3Machine(Test):
>       def test_leon3_helenos_uimage(self):
>           """
>           :avocado: tags=arch:sparc
> -        :avocado: tags=machine:leon3
> +        :avocado: tags=machine:leon3_generic
>           :avocado: tags=binfmt:uimage
>           """
>           kernel_url = ('http://www.helenos.org/releases/'
> @@ -24,7 +24,6 @@ class Leon3Machine(Test):
>           kernel_hash = 'a88c9cfdb8430c66650e5290a08765f9bf049a30'
>           kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
>   
> -        self.vm.set_machine('leon3_generic')
>           self.vm.set_console()
>           self.vm.add_args('-kernel', kernel_path)
>   
> diff --git a/tests/acceptance/ppc_prep_40p.py b/tests/acceptance/ppc_prep_40p.py
> index 6f507fb0a6..b27572f212 100644
> --- a/tests/acceptance/ppc_prep_40p.py
> +++ b/tests/acceptance/ppc_prep_40p.py
> @@ -39,7 +39,6 @@ class IbmPrep40pMachine(Test):
>           drive_hash = 'dbcfc09912e71bd5f0d82c7c1ee43082fb596ceb'
>           drive_path = self.fetch_asset(drive_url, asset_hash=drive_hash)
>   
> -        self.vm.set_machine('40p')
>           self.vm.set_console()
>           self.vm.add_args('-bios', bios_path,
>                            '-fda', drive_path)
> @@ -53,7 +52,6 @@ class IbmPrep40pMachine(Test):
>           :avocado: tags=arch:ppc
>           :avocado: tags=machine:40p
>           """
> -        self.vm.set_machine('40p')
>           self.vm.set_console()
>           self.vm.add_args('-m', '192') # test fw_cfg
>   
> @@ -73,7 +71,6 @@ class IbmPrep40pMachine(Test):
>           drive_hash = 'ac6fa2707d888b36d6fa64de6e7fe48e'
>           drive_path = self.fetch_asset(drive_url, asset_hash=drive_hash,
>                                         algorithm='md5')
> -        self.vm.set_machine('40p')
>           self.vm.set_console()
>           self.vm.add_args('-cdrom', drive_path,
>                            '-boot', 'd')
> diff --git a/tests/acceptance/x86_cpu_model_versions.py b/tests/acceptance/x86_cpu_model_versions.py
> index 6eb977954d..90558d9a71 100644
> --- a/tests/acceptance/x86_cpu_model_versions.py
> +++ b/tests/acceptance/x86_cpu_model_versions.py
> @@ -75,12 +75,15 @@ class X86CPUModelAliases(avocado_qemu.Test):
>                            "EPYC-IBPB shouldn't be versioned")
>   
>       def test_4_0_alias_compatibility(self):
> -        """Check if pc-*-4.0 unversioned CPU model won't be reported as aliases"""
> +        """
> +        Check if pc-*-4.0 unversioned CPU model won't be reported as aliases
> +
> +        :avocado: tags=machine:pc-i440fx-4.0
> +        """
>           # pc-*-4.0 won't expose non-versioned CPU models as aliases
>           # We do this to help management software to keep compatibility
>           # with older QEMU versions that didn't have the versioned CPU model
>           self.vm.add_args('-S')
> -        self.vm.set_machine('pc-i440fx-4.0')
>           self.vm.launch()
>           cpus = dict((m['name'], m) for m in self.vm.command('query-cpu-definitions'))
>   
> @@ -105,9 +108,12 @@ class X86CPUModelAliases(avocado_qemu.Test):
>               self.assertNotIn('alias-of', c, "%s shouldn't be an alias" % (name))
>   
>       def test_4_1_alias(self):
> -        """Check if unversioned CPU model is an alias pointing to right version"""
> +        """
> +        Check if unversioned CPU model is an alias pointing to right version
> +
> +        :avocado: tags=machine:pc-i440fx-4.1
> +        """
>           self.vm.add_args('-S')
> -        self.vm.set_machine('pc-i440fx-4.1')
>           self.vm.launch()
>   
>           cpus = dict((m['name'], m) for m in self.vm.command('query-cpu-definitions'))
> @@ -207,9 +213,12 @@ class X86CPUModelAliases(avocado_qemu.Test):
>           self.validate_aliases(cpus)
>   
>       def test_none_alias(self):
> -        """Check if unversioned CPU model is an alias pointing to some version"""
> +        """
> +        Check if unversioned CPU model is an alias pointing to some version
> +
> +        :avocado: tags=machine:none
> +        """
>           self.vm.add_args('-S')
> -        self.vm.set_machine('none')
>           self.vm.launch()
>   
>           cpus = dict((m['name'], m) for m in self.vm.command('query-cpu-definitions'))
> @@ -242,68 +251,84 @@ class CascadelakeArchCapabilities(avocado_qemu.Test):
>           return self.vm.command('qom-get', path=cpu_path, property=prop)
>   
>       def test_4_1(self):
> +        """
> +        :avocado: tags=machine:pc-i440fx-4.1
> +        """
>           # machine-type only:
>           self.vm.add_args('-S')
> -        self.vm.set_machine('pc-i440fx-4.1')
>           self.vm.add_args('-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')
>   
>       def test_4_0(self):
> +        """
> +        :avocado: tags=machine:pc-i440fx-4.0
> +        """
>           self.vm.add_args('-S')
> -        self.vm.set_machine('pc-i440fx-4.0')
>           self.vm.add_args('-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')
>   
>       def test_set_4_0(self):
> +        """
> +        :avocado: tags=machine:pc-i440fx-4.0
> +        """
>           # command line must override machine-type if CPU model is not versioned:
>           self.vm.add_args('-S')
> -        self.vm.set_machine('pc-i440fx-4.0')
>           self.vm.add_args('-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')
>   
>       def test_unset_4_1(self):
> +        """
> +        :avocado: tags=machine:pc-i440fx-4.1
> +        """
>           self.vm.add_args('-S')
> -        self.vm.set_machine('pc-i440fx-4.1')
>           self.vm.add_args('-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')
>   
>       def test_v1_4_0(self):
> +        """
> +        :avocado: tags=machine:pc-i440fx-4.0
> +        """
>           # versioned CPU model overrides machine-type:
>           self.vm.add_args('-S')
> -        self.vm.set_machine('pc-i440fx-4.0')
>           self.vm.add_args('-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')
>   
>       def test_v2_4_0(self):
> +        """
> +        :avocado: tags=machine:pc-i440fx-4.0
> +        """
>           self.vm.add_args('-S')
> -        self.vm.set_machine('pc-i440fx-4.0')
>           self.vm.add_args('-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')
>   
>       def test_v1_set_4_0(self):
> +        """
> +        :avocado: tags=machine:pc-i440fx-4.0
> +        """
>           # command line must override machine-type and versioned CPU model:
>           self.vm.add_args('-S')
> -        self.vm.set_machine('pc-i440fx-4.0')
>           self.vm.add_args('-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')
>   
>       def test_v2_unset_4_1(self):
> +        """
> +        :avocado: tags=machine:pc-i440fx-4.1
> +        """
>           self.vm.add_args('-S')
> -        self.vm.set_machine('pc-i440fx-4.1')
>           self.vm.add_args('-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'),
> 

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Cleber Rosa Nov. 11, 2019, 9:49 p.m. UTC | #2
On Fri, Nov 08, 2019 at 02:20:45PM +0100, Philippe Mathieu-Daudé wrote:
> > @@ -310,7 +302,7 @@ class BootLinuxConsole(Test):
> >       def test_arm_emcraft_sf2(self):
> >           """
> >           :avocado: tags=arch:arm
> > -        :avocado: tags=machine:emcraft_sf2
> > +        :avocado: tags=machine:emcraft-sf2
> 
> Maybe add a comment about this change, "Since avocado 72(?) we can ... so
> use ..."
> 

You mean on this specific test docstring?  I'm confused if there's a
special reason for doing it here, of if you're suggesting adding a
similar command to all tag entries which make use of the extended
character set (which I think would be too verbose, repetitve, and hard
to maintain).

> > diff --git a/tests/acceptance/cpu_queries.py b/tests/acceptance/cpu_queries.py
> > index af47d2795a..293dccb89a 100644
> > --- a/tests/acceptance/cpu_queries.py
> > +++ b/tests/acceptance/cpu_queries.py
> > @@ -20,8 +20,8 @@ class QueryCPUModelExpansion(Test):
> >       def test(self):
> >           """
> >           :avocado: tags=arch:x86_64
> > +        :avocado: tags=machine:none
> 
> Not to confuse with None :)
> 

Yep! :)

- Cleber.
Cleber Rosa Nov. 12, 2019, 1:59 a.m. UTC | #3
On Fri, Nov 08, 2019 at 02:20:45PM +0100, Philippe Mathieu-Daudé wrote:
> On 11/4/19 4:13 PM, Cleber Rosa wrote:
> >           """
> > -        self.vm.set_machine('none')
> >           self.vm.add_args('-S')
> >           self.vm.launch()
> > diff --git a/tests/acceptance/linux_initrd.py b/tests/acceptance/linux_initrd.py
> > index c61d9826a4..3a0ff7b098 100644
> > --- a/tests/acceptance/linux_initrd.py
> > +++ b/tests/acceptance/linux_initrd.py
> > @@ -20,6 +20,7 @@ class LinuxInitrd(Test):
> >       Checks QEMU evaluates correctly the initrd file passed as -initrd option.
> >       :avocado: tags=arch:x86_64
> > +    :avocado: tags=machine:pc
> 
> For some tests we can run on multiple machines (here q35), I was tempted to
> use multiple tags. How could I do that now?
>

I missed this comment: you can add many tag values here to *classify*
the test as being "q35 machine type capable".

But, Avocado will only run a test multiple times with a varianter
plugin active.  In that case, a "machine" *parameter* with different
values will be passed to the tests.  This tag value is being used
as a default value for the parameter, so it has a lower precedence.

We have a pending task[1] to create an initial CIT file for arch and
machine types.

CC'ing Jan Richter, who is supposed to start working on it soon.

- Cleber.

[1] - https://trello.com/c/1wvzcxHY/105-create-cit-parameter-for-acceptance-tests
Philippe Mathieu-Daudé Nov. 12, 2019, 6:15 p.m. UTC | #4
On 11/11/19 10:49 PM, Cleber Rosa wrote:
> On Fri, Nov 08, 2019 at 02:20:45PM +0100, Philippe Mathieu-Daudé wrote:
>>> @@ -310,7 +302,7 @@ class BootLinuxConsole(Test):
>>>        def test_arm_emcraft_sf2(self):
>>>            """
>>>            :avocado: tags=arch:arm
>>> -        :avocado: tags=machine:emcraft_sf2
>>> +        :avocado: tags=machine:emcraft-sf2
>>
>> Maybe add a comment about this change, "Since avocado 72(?) we can ... so
>> use ..."
>>
> 
> You mean on this specific test docstring?  I'm confused if there's a

No! Just in the commit description :)

> special reason for doing it here, of if you're suggesting adding a
> similar command to all tag entries which make use of the extended
> character set (which I think would be too verbose, repetitve, and hard
> to maintain).
> 
>>> diff --git a/tests/acceptance/cpu_queries.py b/tests/acceptance/cpu_queries.py
>>> index af47d2795a..293dccb89a 100644
>>> --- a/tests/acceptance/cpu_queries.py
>>> +++ b/tests/acceptance/cpu_queries.py
>>> @@ -20,8 +20,8 @@ class QueryCPUModelExpansion(Test):
>>>        def test(self):
>>>            """
>>>            :avocado: tags=arch:x86_64
>>> +        :avocado: tags=machine:none
>>
>> Not to confuse with None :)
>>
> 
> Yep! :)
> 
> - Cleber.
>
Philippe Mathieu-Daudé Nov. 12, 2019, 6:15 p.m. UTC | #5
On 11/12/19 2:59 AM, Cleber Rosa wrote:
> On Fri, Nov 08, 2019 at 02:20:45PM +0100, Philippe Mathieu-Daudé wrote:
>> On 11/4/19 4:13 PM, Cleber Rosa wrote:
>>>            """
>>> -        self.vm.set_machine('none')
>>>            self.vm.add_args('-S')
>>>            self.vm.launch()
>>> diff --git a/tests/acceptance/linux_initrd.py b/tests/acceptance/linux_initrd.py
>>> index c61d9826a4..3a0ff7b098 100644
>>> --- a/tests/acceptance/linux_initrd.py
>>> +++ b/tests/acceptance/linux_initrd.py
>>> @@ -20,6 +20,7 @@ class LinuxInitrd(Test):
>>>        Checks QEMU evaluates correctly the initrd file passed as -initrd option.
>>>        :avocado: tags=arch:x86_64
>>> +    :avocado: tags=machine:pc
>>
>> For some tests we can run on multiple machines (here q35), I was tempted to
>> use multiple tags. How could I do that now?
>>
> 
> I missed this comment: you can add many tag values here to *classify*
> the test as being "q35 machine type capable".
> 
> But, Avocado will only run a test multiple times with a varianter
> plugin active.  In that case, a "machine" *parameter* with different
> values will be passed to the tests.  This tag value is being used
> as a default value for the parameter, so it has a lower precedence.
> 
> We have a pending task[1] to create an initial CIT file for arch and
> machine types.
> 
> CC'ing Jan Richter, who is supposed to start working on it soon.
> 
> - Cleber.
> 
> [1] - https://trello.com/c/1wvzcxHY/105-create-cit-parameter-for-acceptance-tests

Good news, thanks for the trello link.
diff mbox series

Patch

diff --git a/docs/devel/testing.rst b/docs/devel/testing.rst
index 8e981e062d..27f286858a 100644
--- a/docs/devel/testing.rst
+++ b/docs/devel/testing.rst
@@ -746,6 +746,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``.
 
+machine
+~~~~~~~
+
+The machine type that will be set to all QEMUMachine instances created
+by the test.
+
+The ``machine`` 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=machine:VALUE`` tag, it will be set to ``VALUE``.
+
 qemu_bin
 ~~~~~~~~
 
@@ -781,6 +792,13 @@  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.
 
+machine
+~~~~~~~
+
+The machine type that will be set to all QEMUMachine instances created
+by the test.
+
+
 qemu_bin
 ~~~~~~~~
 
diff --git a/tests/acceptance/avocado_qemu/__init__.py b/tests/acceptance/avocado_qemu/__init__.py
index e676d9c4e7..6618ea67c1 100644
--- a/tests/acceptance/avocado_qemu/__init__.py
+++ b/tests/acceptance/avocado_qemu/__init__.py
@@ -115,6 +115,9 @@  class Test(avocado.Test):
         self.arch = self.params.get('arch',
                                     default=self._get_unique_tag_val('arch'))
 
+        self.machine = self.params.get('machine',
+                                       default=self._get_unique_tag_val('machine'))
+
         default_qemu_bin = pick_default_qemu_bin(arch=self.arch)
         self.qemu_bin = self.params.get('qemu_bin',
                                         default=default_qemu_bin)
@@ -136,6 +139,8 @@  class Test(avocado.Test):
             name = str(uuid.uuid4())
         if self._vms.get(name) is None:
             self._vms[name] = self._new_vm(*args)
+            if self.machine is not None:
+                self._vms[name].set_machine(self.machine)
         return self._vms[name]
 
     def tearDown(self):
diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py
index 7e41cebd47..6732cc59ca 100644
--- a/tests/acceptance/boot_linux_console.py
+++ b/tests/acceptance/boot_linux_console.py
@@ -62,7 +62,6 @@  class BootLinuxConsole(Test):
         kernel_hash = '23bebd2680757891cf7adedb033532163a792495'
         kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
 
-        self.vm.set_machine('pc')
         self.vm.set_console()
         kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0'
         self.vm.add_args('-kernel', kernel_path,
@@ -85,7 +84,6 @@  class BootLinuxConsole(Test):
         kernel_path = self.extract_from_deb(deb_path,
                                             '/boot/vmlinux-2.6.32-5-4kc-malta')
 
-        self.vm.set_machine('malta')
         self.vm.set_console()
         kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0'
         self.vm.add_args('-kernel', kernel_path,
@@ -118,7 +116,6 @@  class BootLinuxConsole(Test):
         kernel_path = self.extract_from_deb(deb_path,
                                             '/boot/vmlinux-2.6.32-5-5kc-malta')
 
-        self.vm.set_machine('malta')
         self.vm.set_console()
         kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0'
         self.vm.add_args('-kernel', kernel_path,
@@ -148,7 +145,6 @@  class BootLinuxConsole(Test):
         initrd_path = self.workdir + "rootfs.cpio"
         archive.gzip_uncompress(initrd_path_gz, initrd_path)
 
-        self.vm.set_machine('malta')
         self.vm.set_console()
         kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE
                                + 'console=ttyS0 console=tty '
@@ -188,7 +184,6 @@  class BootLinuxConsole(Test):
         initrd_path = self.workdir + "rootfs.cpio"
         archive.gzip_uncompress(initrd_path_gz, initrd_path)
 
-        self.vm.set_machine('malta')
         self.vm.set_console()
         kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE
                                + 'console=ttyS0 console=tty '
@@ -215,7 +210,6 @@  class BootLinuxConsole(Test):
             with open(kernel_path, 'wb') as f_out:
                 shutil.copyfileobj(f_in, f_out)
 
-        self.vm.set_machine('malta')
         self.vm.set_console()
         kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE
                                + 'mem=256m@@0x0 '
@@ -275,7 +269,6 @@  class BootLinuxConsole(Test):
         kernel_hash = '8c73e469fc6ea06a58dc83a628fc695b693b8493'
         kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
 
-        self.vm.set_machine('virt')
         self.vm.set_console()
         kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
                                'console=ttyAMA0')
@@ -297,7 +290,6 @@  class BootLinuxConsole(Test):
         kernel_hash = 'e9826d741b4fb04cadba8d4824d1ed3b7fb8b4d4'
         kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
 
-        self.vm.set_machine('virt')
         self.vm.set_console()
         kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
                                'console=ttyAMA0')
@@ -310,7 +302,7 @@  class BootLinuxConsole(Test):
     def test_arm_emcraft_sf2(self):
         """
         :avocado: tags=arch:arm
-        :avocado: tags=machine:emcraft_sf2
+        :avocado: tags=machine:emcraft-sf2
         :avocado: tags=endian:little
         """
         uboot_url = ('https://raw.githubusercontent.com/'
@@ -324,7 +316,6 @@  class BootLinuxConsole(Test):
         spi_hash = '85f698329d38de63aea6e884a86fbde70890a78a'
         spi_path = self.fetch_asset(spi_url, asset_hash=spi_hash)
 
-        self.vm.set_machine('emcraft-sf2')
         self.vm.set_console()
         kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE
         self.vm.add_args('-kernel', uboot_path,
@@ -351,7 +342,6 @@  class BootLinuxConsole(Test):
         kernel_path = self.extract_from_deb(deb_path, '/boot/kernel7.img')
         dtb_path = self.extract_from_deb(deb_path, '/boot/bcm2709-rpi-2-b.dtb')
 
-        self.vm.set_machine('raspi2')
         self.vm.set_console()
         kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
                                serial_kernel_cmdline[uart_id])
@@ -393,7 +383,6 @@  class BootLinuxConsole(Test):
         initrd_path = os.path.join(self.workdir, 'rootfs.cpio')
         archive.gzip_uncompress(initrd_path_gz, initrd_path)
 
-        self.vm.set_machine('smdkc210')
         self.vm.set_console()
         kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
                                'earlycon=exynos4210,0x13800000 earlyprintk ' +
@@ -414,7 +403,7 @@  class BootLinuxConsole(Test):
     def test_s390x_s390_ccw_virtio(self):
         """
         :avocado: tags=arch:s390x
-        :avocado: tags=machine:s390_ccw_virtio
+        :avocado: tags=machine:s390-ccw-virtio
         """
         kernel_url = ('https://archives.fedoraproject.org/pub/archive'
                       '/fedora-secondary/releases/29/Everything/s390x/os/images'
@@ -422,7 +411,6 @@  class BootLinuxConsole(Test):
         kernel_hash = 'e8e8439103ef8053418ef062644ffd46a7919313'
         kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
 
-        self.vm.set_machine('s390-ccw-virtio')
         self.vm.set_console()
         kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=sclp0'
         self.vm.add_args('-nodefaults',
@@ -444,7 +432,6 @@  class BootLinuxConsole(Test):
 
         uncompressed_kernel = archive.uncompress(kernel_path, self.workdir)
 
-        self.vm.set_machine('clipper')
         self.vm.set_console()
         kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0'
         self.vm.add_args('-vga', 'std',
@@ -465,7 +452,6 @@  class BootLinuxConsole(Test):
         kernel_hash = '3fe04abfc852b66653b8c3c897a59a689270bc77'
         kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
 
-        self.vm.set_machine('pseries')
         self.vm.set_console()
         kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=hvc0'
         self.vm.add_args('-kernel', kernel_path,
@@ -489,7 +475,6 @@  class BootLinuxConsole(Test):
         kernel_path = self.extract_from_deb(deb_path,
                                             '/boot/vmlinux-5.3.0-1-m68k')
 
-        self.vm.set_machine('q800')
         self.vm.set_console()
         kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
                                'console=ttyS0 vga=off')
diff --git a/tests/acceptance/cpu_queries.py b/tests/acceptance/cpu_queries.py
index af47d2795a..293dccb89a 100644
--- a/tests/acceptance/cpu_queries.py
+++ b/tests/acceptance/cpu_queries.py
@@ -20,8 +20,8 @@  class QueryCPUModelExpansion(Test):
     def test(self):
         """
         :avocado: tags=arch:x86_64
+        :avocado: tags=machine:none
         """
-        self.vm.set_machine('none')
         self.vm.add_args('-S')
         self.vm.launch()
 
diff --git a/tests/acceptance/linux_initrd.py b/tests/acceptance/linux_initrd.py
index c61d9826a4..3a0ff7b098 100644
--- a/tests/acceptance/linux_initrd.py
+++ b/tests/acceptance/linux_initrd.py
@@ -20,6 +20,7 @@  class LinuxInitrd(Test):
     Checks QEMU evaluates correctly the initrd file passed as -initrd option.
 
     :avocado: tags=arch:x86_64
+    :avocado: tags=machine:pc
     """
 
     timeout = 300
@@ -66,7 +67,6 @@  class LinuxInitrd(Test):
             initrd.write(b'\0')
             initrd.flush()
 
-            self.vm.set_machine('pc')
             self.vm.set_console()
             kernel_command_line = 'console=ttyS0'
             self.vm.add_args('-kernel', kernel_path,
diff --git a/tests/acceptance/linux_ssh_mips_malta.py b/tests/acceptance/linux_ssh_mips_malta.py
index fc13f9e4d4..1d570deb00 100644
--- a/tests/acceptance/linux_ssh_mips_malta.py
+++ b/tests/acceptance/linux_ssh_mips_malta.py
@@ -111,7 +111,6 @@  class LinuxSSH(Test):
         image_url, image_hash = self.get_image_info(endianess)
         image_path = self.fetch_asset(image_url, asset_hash=image_hash)
 
-        self.vm.set_machine('malta')
         self.vm.set_console()
         kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE
                                + 'console=ttyS0 root=/dev/sda1')
@@ -215,7 +214,6 @@  class LinuxSSH(Test):
     def test_mips_malta32eb_kernel3_2_0(self):
         """
         :avocado: tags=arch:mips
-        :avocado: tags=machine:malta
         :avocado: tags=endian:big
         :avocado: tags=device:pcnet32
         """
@@ -224,7 +222,6 @@  class LinuxSSH(Test):
     def test_mips_malta32el_kernel3_2_0(self):
         """
         :avocado: tags=arch:mipsel
-        :avocado: tags=machine:malta
         :avocado: tags=endian:little
         :avocado: tags=device:pcnet32
         """
@@ -233,7 +230,6 @@  class LinuxSSH(Test):
     def test_mips_malta64eb_kernel3_2_0(self):
         """
         :avocado: tags=arch:mips64
-        :avocado: tags=machine:malta
         :avocado: tags=endian:big
         :avocado: tags=device:pcnet32
         """
@@ -242,7 +238,6 @@  class LinuxSSH(Test):
     def test_mips_malta64el_kernel3_2_0(self):
         """
         :avocado: tags=arch:mips64el
-        :avocado: tags=machine:malta
         :avocado: tags=endian:little
         :avocado: tags=device:pcnet32
         """
diff --git a/tests/acceptance/machine_m68k_nextcube.py b/tests/acceptance/machine_m68k_nextcube.py
index fcd2c58ee7..32cf571f94 100644
--- a/tests/acceptance/machine_m68k_nextcube.py
+++ b/tests/acceptance/machine_m68k_nextcube.py
@@ -43,6 +43,11 @@  def tesseract_available(expected_version):
 
 
 class NextCubeMachine(Test):
+    """
+    :avocado: tags=arch:m68k
+    :avocado: tags=machine:next-cube
+    :avocado: tags=device:framebuffer
+    """
 
     timeout = 15
 
@@ -52,7 +57,6 @@  class NextCubeMachine(Test):
         rom_hash = 'b3534796abae238a0111299fc406a9349f7fee24'
         rom_path = self.fetch_asset(rom_url, asset_hash=rom_hash)
 
-        self.vm.set_machine('next-cube')
         self.vm.add_args('-bios', rom_path)
         self.vm.launch()
 
@@ -66,11 +70,6 @@  class NextCubeMachine(Test):
 
     @skipUnless(PIL_AVAILABLE, 'Python PIL not installed')
     def test_bootrom_framebuffer_size(self):
-        """
-        :avocado: tags=arch:m68k
-        :avocado: tags=machine:next_cube
-        :avocado: tags=device:framebuffer
-        """
         screenshot_path = os.path.join(self.workdir, "dump.png")
         self.check_bootrom_framebuffer(screenshot_path)
 
@@ -80,11 +79,6 @@  class NextCubeMachine(Test):
 
     @skipUnless(tesseract_available(3), 'tesseract v3 OCR tool not available')
     def test_bootrom_framebuffer_ocr_with_tesseract_v3(self):
-        """
-        :avocado: tags=arch:m68k
-        :avocado: tags=machine:next_cube
-        :avocado: tags=device:framebuffer
-        """
         screenshot_path = os.path.join(self.workdir, "dump.png")
         self.check_bootrom_framebuffer(screenshot_path)
 
@@ -101,11 +95,6 @@  class NextCubeMachine(Test):
     # that it is still alpha-level software.
     @skipUnless(tesseract_available(4), 'tesseract v4 OCR tool not available')
     def test_bootrom_framebuffer_ocr_with_tesseract_v4(self):
-        """
-        :avocado: tags=arch:m68k
-        :avocado: tags=machine:next_cube
-        :avocado: tags=device:framebuffer
-        """
         screenshot_path = os.path.join(self.workdir, "dump.png")
         self.check_bootrom_framebuffer(screenshot_path)
 
diff --git a/tests/acceptance/machine_sparc_leon3.py b/tests/acceptance/machine_sparc_leon3.py
index 298f1e25e6..f77e210ccb 100644
--- a/tests/acceptance/machine_sparc_leon3.py
+++ b/tests/acceptance/machine_sparc_leon3.py
@@ -16,7 +16,7 @@  class Leon3Machine(Test):
     def test_leon3_helenos_uimage(self):
         """
         :avocado: tags=arch:sparc
-        :avocado: tags=machine:leon3
+        :avocado: tags=machine:leon3_generic
         :avocado: tags=binfmt:uimage
         """
         kernel_url = ('http://www.helenos.org/releases/'
@@ -24,7 +24,6 @@  class Leon3Machine(Test):
         kernel_hash = 'a88c9cfdb8430c66650e5290a08765f9bf049a30'
         kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
 
-        self.vm.set_machine('leon3_generic')
         self.vm.set_console()
         self.vm.add_args('-kernel', kernel_path)
 
diff --git a/tests/acceptance/ppc_prep_40p.py b/tests/acceptance/ppc_prep_40p.py
index 6f507fb0a6..b27572f212 100644
--- a/tests/acceptance/ppc_prep_40p.py
+++ b/tests/acceptance/ppc_prep_40p.py
@@ -39,7 +39,6 @@  class IbmPrep40pMachine(Test):
         drive_hash = 'dbcfc09912e71bd5f0d82c7c1ee43082fb596ceb'
         drive_path = self.fetch_asset(drive_url, asset_hash=drive_hash)
 
-        self.vm.set_machine('40p')
         self.vm.set_console()
         self.vm.add_args('-bios', bios_path,
                          '-fda', drive_path)
@@ -53,7 +52,6 @@  class IbmPrep40pMachine(Test):
         :avocado: tags=arch:ppc
         :avocado: tags=machine:40p
         """
-        self.vm.set_machine('40p')
         self.vm.set_console()
         self.vm.add_args('-m', '192') # test fw_cfg
 
@@ -73,7 +71,6 @@  class IbmPrep40pMachine(Test):
         drive_hash = 'ac6fa2707d888b36d6fa64de6e7fe48e'
         drive_path = self.fetch_asset(drive_url, asset_hash=drive_hash,
                                       algorithm='md5')
-        self.vm.set_machine('40p')
         self.vm.set_console()
         self.vm.add_args('-cdrom', drive_path,
                          '-boot', 'd')
diff --git a/tests/acceptance/x86_cpu_model_versions.py b/tests/acceptance/x86_cpu_model_versions.py
index 6eb977954d..90558d9a71 100644
--- a/tests/acceptance/x86_cpu_model_versions.py
+++ b/tests/acceptance/x86_cpu_model_versions.py
@@ -75,12 +75,15 @@  class X86CPUModelAliases(avocado_qemu.Test):
                          "EPYC-IBPB shouldn't be versioned")
 
     def test_4_0_alias_compatibility(self):
-        """Check if pc-*-4.0 unversioned CPU model won't be reported as aliases"""
+        """
+        Check if pc-*-4.0 unversioned CPU model won't be reported as aliases
+
+        :avocado: tags=machine:pc-i440fx-4.0
+        """
         # pc-*-4.0 won't expose non-versioned CPU models as aliases
         # We do this to help management software to keep compatibility
         # with older QEMU versions that didn't have the versioned CPU model
         self.vm.add_args('-S')
-        self.vm.set_machine('pc-i440fx-4.0')
         self.vm.launch()
         cpus = dict((m['name'], m) for m in self.vm.command('query-cpu-definitions'))
 
@@ -105,9 +108,12 @@  class X86CPUModelAliases(avocado_qemu.Test):
             self.assertNotIn('alias-of', c, "%s shouldn't be an alias" % (name))
 
     def test_4_1_alias(self):
-        """Check if unversioned CPU model is an alias pointing to right version"""
+        """
+        Check if unversioned CPU model is an alias pointing to right version
+
+        :avocado: tags=machine:pc-i440fx-4.1
+        """
         self.vm.add_args('-S')
-        self.vm.set_machine('pc-i440fx-4.1')
         self.vm.launch()
 
         cpus = dict((m['name'], m) for m in self.vm.command('query-cpu-definitions'))
@@ -207,9 +213,12 @@  class X86CPUModelAliases(avocado_qemu.Test):
         self.validate_aliases(cpus)
 
     def test_none_alias(self):
-        """Check if unversioned CPU model is an alias pointing to some version"""
+        """
+        Check if unversioned CPU model is an alias pointing to some version
+
+        :avocado: tags=machine:none
+        """
         self.vm.add_args('-S')
-        self.vm.set_machine('none')
         self.vm.launch()
 
         cpus = dict((m['name'], m) for m in self.vm.command('query-cpu-definitions'))
@@ -242,68 +251,84 @@  class CascadelakeArchCapabilities(avocado_qemu.Test):
         return self.vm.command('qom-get', path=cpu_path, property=prop)
 
     def test_4_1(self):
+        """
+        :avocado: tags=machine:pc-i440fx-4.1
+        """
         # machine-type only:
         self.vm.add_args('-S')
-        self.vm.set_machine('pc-i440fx-4.1')
         self.vm.add_args('-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')
 
     def test_4_0(self):
+        """
+        :avocado: tags=machine:pc-i440fx-4.0
+        """
         self.vm.add_args('-S')
-        self.vm.set_machine('pc-i440fx-4.0')
         self.vm.add_args('-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')
 
     def test_set_4_0(self):
+        """
+        :avocado: tags=machine:pc-i440fx-4.0
+        """
         # command line must override machine-type if CPU model is not versioned:
         self.vm.add_args('-S')
-        self.vm.set_machine('pc-i440fx-4.0')
         self.vm.add_args('-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')
 
     def test_unset_4_1(self):
+        """
+        :avocado: tags=machine:pc-i440fx-4.1
+        """
         self.vm.add_args('-S')
-        self.vm.set_machine('pc-i440fx-4.1')
         self.vm.add_args('-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')
 
     def test_v1_4_0(self):
+        """
+        :avocado: tags=machine:pc-i440fx-4.0
+        """
         # versioned CPU model overrides machine-type:
         self.vm.add_args('-S')
-        self.vm.set_machine('pc-i440fx-4.0')
         self.vm.add_args('-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')
 
     def test_v2_4_0(self):
+        """
+        :avocado: tags=machine:pc-i440fx-4.0
+        """
         self.vm.add_args('-S')
-        self.vm.set_machine('pc-i440fx-4.0')
         self.vm.add_args('-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')
 
     def test_v1_set_4_0(self):
+        """
+        :avocado: tags=machine:pc-i440fx-4.0
+        """
         # command line must override machine-type and versioned CPU model:
         self.vm.add_args('-S')
-        self.vm.set_machine('pc-i440fx-4.0')
         self.vm.add_args('-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')
 
     def test_v2_unset_4_1(self):
+        """
+        :avocado: tags=machine:pc-i440fx-4.1
+        """
         self.vm.add_args('-S')
-        self.vm.set_machine('pc-i440fx-4.1')
         self.vm.add_args('-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'),