From 359b8b4e10575646a2efa1bcb58ab74053233514 Mon Sep 17 00:00:00 2001 From: Cleber Rosa Date: Fri, 19 Oct 2018 18:46:08 -0400 Subject: [PATCH] WIP: use arch tags on test setup Not defaulting to os.uname() to set a default arch, checking for valid archs based on the tags, and finally setting a default arch if one and only one arch is given as a tag. Signed-off-by: Cleber Rosa --- tests/acceptance/avocado_qemu/__init__.py | 16 ++++++++++++++-- tests/acceptance/boot_linux_console.py | 8 +++----- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/tests/acceptance/avocado_qemu/__init__.py b/tests/acceptance/avocado_qemu/__init__.py index 9329d9b9ecf0..a6f84ccb088a 100644 --- a/tests/acceptance/avocado_qemu/__init__.py +++ b/tests/acceptance/avocado_qemu/__init__.py @@ -52,8 +52,20 @@ def pick_default_qemu_bin(arch=None): class Test(avocado.Test): def setUp(self): - self.vm = None - self.arch = self.params.get('arch', default=os.uname()[4]) + arches = [tag.split(':', 1)[1] for tag in self.tags if tag.startswith('arch:')] + + # Do not set a default arch based on the host - see discussion on qemu-devel + self.arch = self.params.get('arch', None) + + # If a arch parameter is *not* given, and one, and only one "arch:" tag is + # given, default to that + if self.arch is None and len(arches) == 1: + self.arch = arches[0] + + # If arch is still not set, cancel the test + if self.arch not in arches: + self.cancel('Currently specific to the targets: %s' % ", ".join(arches)) + self.qemu_bin = self.params.get('qemu_bin', default=pick_default_qemu_bin(self.arch)) if self.qemu_bin is None: diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py index 66cb29e97806..0b8eb5f753d4 100644 --- a/tests/acceptance/boot_linux_console.py +++ b/tests/acceptance/boot_linux_console.py @@ -25,8 +25,9 @@ class BootLinuxConsole(Test): timeout = 60 def test_x86_64_pc(self): - if self.arch != 'x86_64': - self.cancel('Currently specific to the x86_64 arch') + """ + :avocado: tags=arch:x86_64 + """ kernel_url = ('https://mirrors.kernel.org/fedora/releases/28/' 'Everything/x86_64/os/images/pxeboot/vmlinuz') kernel_hash = '238e083e114c48200f80d889f7e32eeb2793e02a' @@ -62,9 +63,6 @@ def test_mips_4kc_malta(self): :avocado: tags=arch:mips """ - if self.arch != 'mips': # FIXME use 'arch' tag in parent class? - self.cancel('Currently specific to the %s target arch' % self.arch) - deb_url = ('http://snapshot.debian.org/archive/debian/20130217T032700Z/' 'pool/main/l/linux-2.6/' 'linux-image-2.6.32-5-4kc-malta_2.6.32-48_mips.deb')