Message ID | 20200129212345.20547-10-philmd@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | tests/acceptance/virtio_seg_max_adjust: Restrict it to Linux/X86 | expand |
On Wed, 29 Jan 2020 22:23:25 +0100 Philippe Mathieu-Daudé <philmd@redhat.com> wrote: > We already use the 'machine' tag in Avocado tests. > If the requested machine is not available in the QEMU binary, > the tests will be cancelled (skipped): > > $ python -m avocado --show=app run tests/acceptance/x86_cpu_model_versions.py > ... > (04/11) CascadelakeArchCapabilities.test_4_1: CANCEL: Test expects machine 'pc-i440fx-4.1' which is missing from QEMU binary (0.10 s) > (05/11) CascadelakeArchCapabilities.test_4_0: CANCEL: Test expects machine 'pc-i440fx-4.0' which is missing from QEMU binary (0.11 s) > ... > > Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> > --- > tests/acceptance/avocado_qemu/__init__.py | 13 ++++++++++--- > 1 file changed, 10 insertions(+), 3 deletions(-) Reviewed-by: Cornelia Huck <cohuck@redhat.com>
On 29/01/2020 21:23, Philippe Mathieu-Daudé wrote: > We already use the 'machine' tag in Avocado tests. > If the requested machine is not available in the QEMU binary, > the tests will be cancelled (skipped): > > $ python -m avocado --show=app run tests/acceptance/x86_cpu_model_versions.py > ... > (04/11) CascadelakeArchCapabilities.test_4_1: CANCEL: Test expects machine 'pc-i440fx-4.1' which is missing from QEMU binary (0.10 s) > (05/11) CascadelakeArchCapabilities.test_4_0: CANCEL: Test expects machine 'pc-i440fx-4.0' which is missing from QEMU binary (0.11 s) > ... > > Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> > --- > tests/acceptance/avocado_qemu/__init__.py | 13 ++++++++++--- > 1 file changed, 10 insertions(+), 3 deletions(-) > > diff --git a/tests/acceptance/avocado_qemu/__init__.py b/tests/acceptance/avocado_qemu/__init__.py > index e7d5affe24..53ec8512d1 100644 > --- a/tests/acceptance/avocado_qemu/__init__.py > +++ b/tests/acceptance/avocado_qemu/__init__.py > @@ -20,6 +20,7 @@ SRC_ROOT_DIR = os.path.join(os.path.dirname(__file__), '..', '..', '..') > sys.path.append(os.path.join(SRC_ROOT_DIR, 'python')) > > from qemu.binutils import binary_get_arch > +from qemu.binutils import binary_get_machines > from qemu.binutils import binary_get_version > from qemu.machine import QEMUMachine > > @@ -118,9 +119,6 @@ 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')) > - > # Verify qemu_bin > default_qemu_bin = pick_default_qemu_bin(arch=self.arch) > self.qemu_bin = self.params.get('qemu_bin', > @@ -151,6 +149,15 @@ class Test(avocado.Test): > if bin_arch != self.arch: > self.cancel(fmt.format(self.arch, bin_arch)) > > + # Verify machine > + self.machine = self.params.get('machine', > + default=self._get_unique_tag_val('machine')) > + logger.debug('machine: {}'.format(self.machine)) > + if self.machine: > + fmt = "Test expects machine '{}' which is missing from QEMU binary" > + if self.machine not in binary_get_machines(self.qemu_bin): > + self.cancel(fmt.format(self.machine)) > + Starting with this patch: $ avocado run --filter-by-tags arch:x86_64 tests/acceptance ... /boot_linux_console.py:BootLinuxConsole.test_x86_64_pc: CANCEL: Test expects machine 'pc' which is missing from QEMU binary (0.05 s) ... $ x86_64-softmmu/qemu-system-x86_64 -machine help Supported machines are: microvm microvm (i386) pc Standard PC (i440FX + PIIX, 1996) (alias of pc-i440fx-5.0) ... but checking via QMP, 'pc' (and 'q35') is listed as 'alias' ... { "hotpluggable-cpus": true, "name": "pc-i440fx-5.0", "numa-mem-supported": true, "default-cpu-type": "qemu64-x86_64-cpu", "is-default": true, "cpu-max": 255, "deprecated": false, "alias": "pc" }, ... Does 'alias' need to be checked by binary_get_machines() in Patch8 as well as 'name'? Regards, Liam
On 06/02/2020 18:17, Liam Merwick wrote: > On 29/01/2020 21:23, Philippe Mathieu-Daudé wrote: >> We already use the 'machine' tag in Avocado tests. >> If the requested machine is not available in the QEMU binary, >> the tests will be cancelled (skipped): >> >> $ python -m avocado --show=app run >> tests/acceptance/x86_cpu_model_versions.py >> ... >> (04/11) CascadelakeArchCapabilities.test_4_1: CANCEL: Test expects >> machine 'pc-i440fx-4.1' which is missing from QEMU binary (0.10 s) >> (05/11) CascadelakeArchCapabilities.test_4_0: CANCEL: Test expects >> machine 'pc-i440fx-4.0' which is missing from QEMU binary (0.11 s) >> ... >> >> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> >> --- >> tests/acceptance/avocado_qemu/__init__.py | 13 ++++++++++--- >> 1 file changed, 10 insertions(+), 3 deletions(-) >> >> diff --git a/tests/acceptance/avocado_qemu/__init__.py >> b/tests/acceptance/avocado_qemu/__init__.py >> index e7d5affe24..53ec8512d1 100644 >> --- a/tests/acceptance/avocado_qemu/__init__.py >> +++ b/tests/acceptance/avocado_qemu/__init__.py >> @@ -20,6 +20,7 @@ SRC_ROOT_DIR = >> os.path.join(os.path.dirname(__file__), '..', '..', '..') >> sys.path.append(os.path.join(SRC_ROOT_DIR, 'python')) >> from qemu.binutils import binary_get_arch >> +from qemu.binutils import binary_get_machines >> from qemu.binutils import binary_get_version >> from qemu.machine import QEMUMachine >> @@ -118,9 +119,6 @@ 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')) >> - >> # Verify qemu_bin >> default_qemu_bin = pick_default_qemu_bin(arch=self.arch) >> self.qemu_bin = self.params.get('qemu_bin', >> @@ -151,6 +149,15 @@ class Test(avocado.Test): >> if bin_arch != self.arch: >> self.cancel(fmt.format(self.arch, bin_arch)) >> + # Verify machine >> + self.machine = self.params.get('machine', >> + >> default=self._get_unique_tag_val('machine')) >> + logger.debug('machine: {}'.format(self.machine)) >> + if self.machine: >> + fmt = "Test expects machine '{}' which is missing from >> QEMU binary" >> + if self.machine not in binary_get_machines(self.qemu_bin): >> + self.cancel(fmt.format(self.machine)) >> + > > Starting with this patch: > > $ avocado run --filter-by-tags arch:x86_64 tests/acceptance > ... > /boot_linux_console.py:BootLinuxConsole.test_x86_64_pc: CANCEL: Test > expects machine 'pc' which is missing from QEMU binary (0.05 s) > ... > > $ x86_64-softmmu/qemu-system-x86_64 -machine help > Supported machines are: > microvm microvm (i386) > pc Standard PC (i440FX + PIIX, 1996) (alias of > pc-i440fx-5.0) > ... > > but checking via QMP, 'pc' (and 'q35') is listed as 'alias' > ... > { > "hotpluggable-cpus": true, > "name": "pc-i440fx-5.0", > "numa-mem-supported": true, > "default-cpu-type": "qemu64-x86_64-cpu", > "is-default": true, > "cpu-max": 255, > "deprecated": false, > "alias": "pc" > }, > ... > > Does 'alias' need to be checked by binary_get_machines() in Patch8 as > well as 'name'? > When I made this change (I'm sure there is a more Pythonesque way) --- a/python/qemu/binutils.py +++ b/python/qemu/binutils.py @@ -65,7 +65,12 @@ def binary_get_machines(qemu_bin): res = vm.command('query-machines') LOG.info(res) vm.shutdown() - return [m['name'] for m in res] + d = [] + for m in res: + d += [m['name']] + if 'alias' in m: + d += [m['alias']] + return d I can then use binary_get_machines() in my PVH acceptance test patches. @@ -72,11 +74,16 @@ class BootLinuxConsole(Test): os.chdir(cwd) return os.path.normpath(os.path.join(self.workdir, path)) - def test_x86_64_pc(self): + def do_test_x86_64_machine(self): """ - :avocado: tags=arch:x86_64 - :avocado: tags=machine:pc + Common routine to boot an x86_64 guest. + Caller must specify tags=arch and tags=machine """ + + if self.machine not in binary_get_machines(self.qemu_bin): + raise TestCancel('QEMU binary %s does not support machine class %s' + % (self.qemu_bin, self.machine)) + otherwise I was getting (1/7) tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_x86_64_pc: CANCEL: Test expects machine 'pc' which is missing from QEMU binary (0.03 s) Regards, Liam
diff --git a/tests/acceptance/avocado_qemu/__init__.py b/tests/acceptance/avocado_qemu/__init__.py index e7d5affe24..53ec8512d1 100644 --- a/tests/acceptance/avocado_qemu/__init__.py +++ b/tests/acceptance/avocado_qemu/__init__.py @@ -20,6 +20,7 @@ SRC_ROOT_DIR = os.path.join(os.path.dirname(__file__), '..', '..', '..') sys.path.append(os.path.join(SRC_ROOT_DIR, 'python')) from qemu.binutils import binary_get_arch +from qemu.binutils import binary_get_machines from qemu.binutils import binary_get_version from qemu.machine import QEMUMachine @@ -118,9 +119,6 @@ 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')) - # Verify qemu_bin default_qemu_bin = pick_default_qemu_bin(arch=self.arch) self.qemu_bin = self.params.get('qemu_bin', @@ -151,6 +149,15 @@ class Test(avocado.Test): if bin_arch != self.arch: self.cancel(fmt.format(self.arch, bin_arch)) + # Verify machine + self.machine = self.params.get('machine', + default=self._get_unique_tag_val('machine')) + logger.debug('machine: {}'.format(self.machine)) + if self.machine: + fmt = "Test expects machine '{}' which is missing from QEMU binary" + if self.machine not in binary_get_machines(self.qemu_bin): + self.cancel(fmt.format(self.machine)) + def _new_vm(self, *args): vm = QEMUMachine(self.qemu_bin, sock_dir=tempfile.mkdtemp()) if args:
We already use the 'machine' tag in Avocado tests. If the requested machine is not available in the QEMU binary, the tests will be cancelled (skipped): $ python -m avocado --show=app run tests/acceptance/x86_cpu_model_versions.py ... (04/11) CascadelakeArchCapabilities.test_4_1: CANCEL: Test expects machine 'pc-i440fx-4.1' which is missing from QEMU binary (0.10 s) (05/11) CascadelakeArchCapabilities.test_4_0: CANCEL: Test expects machine 'pc-i440fx-4.0' which is missing from QEMU binary (0.11 s) ... Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> --- tests/acceptance/avocado_qemu/__init__.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)