On Wed, Oct 19, 2022 at 11:59 AM Ani Sinha <a...@anisinha.ca> wrote:
>
> On Wed, Oct 19, 2022 at 8:29 AM Ani Sinha <a...@anisinha.ca> wrote:
> >
> > This introduces QEMU acpi/smbios biosbits avocado test which is run
> > from within the python virtual environment. When the bits tests are run, 
> > bits
> > binaries are downloaded from an external repo/location, bios bits iso is
> > regenerated containing the acpi/smbios bits tests that are maintained as a 
> > part
> > of the QEMU source under tests/avocado/acpi-bits/bits-test . When the VM is
> > spawned with the iso, it runs the tests in batch mode and the results are 
> > pushed
> > out from the VM to the test machine where they are analyzed by this script 
> > and
> > pass/fail results are reported.
> >
> > Cc: Daniel P. Berrangé <berra...@redhat.com>
> > Cc: Paolo Bonzini <pbonz...@redhat.com>
> > Cc: Maydell Peter <peter.mayd...@linaro.org>
> > Cc: John Snow <js...@redhat.com>
> > Cc: Thomas Huth <th...@redhat.com>
> > Cc: Alex Bennée <alex.ben...@linaro.org>
> > Cc: Igor Mammedov <imamm...@redhat.com>
> > Cc: Michael Tsirkin <m...@redhat.com>
> > Signed-off-by: Ani Sinha <a...@anisinha.ca>
> > ---
> >  tests/avocado/acpi-bits.py | 363 +++++++++++++++++++++++++++++++++++++
> >  1 file changed, 363 insertions(+)
> >  create mode 100644 tests/avocado/acpi-bits.py
> >
> > diff --git a/tests/avocado/acpi-bits.py b/tests/avocado/acpi-bits.py
> > new file mode 100644
> > index 0000000000..4365537fa8
> > --- /dev/null
> > +++ b/tests/avocado/acpi-bits.py
> > @@ -0,0 +1,363 @@
> > +#!/usr/bin/env python3
> > +# group: rw quick
> > +# Exercize QEMU generated ACPI/SMBIOS tables using biosbits,
> > +# https://biosbits.org/
> > +#
> > +# This program is free software; you can redistribute it and/or modify
> > +# it under the terms of the GNU General Public License as published by
> > +# the Free Software Foundation; either version 2 of the License, or
> > +# (at your option) any later version.
> > +#
> > +# This program is distributed in the hope that it will be useful,
> > +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> > +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> > +# GNU General Public License for more details.
> > +#
> > +# You should have received a copy of the GNU General Public License
> > +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
> > +#
> > +#
> > +# Author:
> > +#  Ani Sinha <a...@anisinha.ca>
> > +
> > +# pylint: disable=invalid-name
> > +# pylint: disable=consider-using-f-string
> > +
> > +"""
> > +This is QEMU ACPI/SMBIOS avocado tests using biosbits.
> > +Biosbits is available originally at https://biosbits.org/.
> > +This test uses a fork of the upstream bits and has numerous fixes
> > +including an upgraded acpica. The fork is located here:
> > +https://gitlab.com/qemu-project/biosbits-bits .
> > +"""
> > +
> > +import logging
> > +import os
> > +import re
> > +import shutil
> > +import subprocess
> > +import tarfile
> > +import tempfile
> > +import time
> > +import zipfile
> > +from typing import (
> > +    List,
> > +    Optional,
> > +    Sequence,
> > +)
> > +from qemu.machine import QEMUMachine
> > +from avocado import skipIf
> > +from avocado_qemu import QemuBaseTest
> > +
> > +def _print_log(log):
> > +    print('\nlogs from biosbits follows:')
> > +    print('==========================================\n')
> > +    print(log)
> > +    print('==========================================\n')
> > +
> > +class QEMUBitsMachine(QEMUMachine): # pylint: 
> > disable=too-few-public-methods
> > +    """
> > +    A QEMU VM, with isa-debugcon enabled and bits iso passed
> > +    using -cdrom to QEMU commandline.
> > +
> > +    """
> > +    def __init__(self,
> > +                 binary: str,
> > +                 args: Sequence[str] = (),
> > +                 wrapper: Sequence[str] = (),
> > +                 name: Optional[str] = None,
> > +                 base_temp_dir: str = "/var/tmp",
> > +                 debugcon_log: str = "debugcon-log.txt",
> > +                 debugcon_addr: str = "0x403",
> > +                 sock_dir: Optional[str] = None,
> > +                 qmp_timer: Optional[float] = None):
> > +        # pylint: disable=too-many-arguments
> > +
> > +        if name is None:
> > +            name = "qemu-bits-%d" % os.getpid()
> > +        if sock_dir is None:
> > +            sock_dir = base_temp_dir
> > +        super().__init__(binary, args, wrapper=wrapper, name=name,
> > +                         base_temp_dir=base_temp_dir,
> > +                         sock_dir=sock_dir, qmp_timer=qmp_timer)
> > +        self.debugcon_log = debugcon_log
> > +        self.debugcon_addr = debugcon_addr
> > +        self.base_temp_dir = base_temp_dir
> > +
> > +    @property
> > +    def _base_args(self) -> List[str]:
> > +        args = super()._base_args
> > +        args.extend([
> > +            '-chardev',
> > +            'file,path=%s,id=debugcon' %os.path.join(self.base_temp_dir,
> > +                                                     self.debugcon_log),
> > +            '-device',
> > +            'isa-debugcon,iobase=%s,chardev=debugcon' %self.debugcon_addr,
> > +        ])
> > +        return args
> > +
> > +    def base_args(self):
> > +        """return the base argument to QEMU binary"""
> > +        return self._base_args
> > +
> > +@skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab')
> > +class AcpiBitsTest(QemuBaseTest): #pylint: 
> > disable=too-many-instance-attributes
> > +    """
> > +    ACPI and SMBIOS tests using biosbits.

 <snip>

> > +
> > +    def setUp(self): # pylint: disable=arguments-differ
> > +        super().setUp('qemu-system-')
> > +
> > +        if shutil.which('xorriso') is None:
> > +            logging.error('xorriso is required to run this test.')
> > +            self.skipTest("xorriso is not installed. Please install it.")
>
> This would result in output like this when xorriso is not found:
>
> $ which xorriso
> /usr/bin/which: no xorriso in
> (/home/anisinha/.local/bin:/home/anisinha/bin:/usr/share/Modules/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin)
> [anisinha@centos8 build]$ ./tests/venv/bin/avocado run -t acpi tests/avocado
> Fetching asset from
> tests/avocado/acpi-bits.py:AcpiBitsTest.test_acpi_smbios_bits
> JOB ID     : 95aba043201755ed888ef7d1598402c555118df4
> JOB LOG    : 
> /home/anisinha/avocado/job-results/job-2022-10-19T02.27-95aba04/job.log
>  (1/1) tests/avocado/acpi-bits.py:AcpiBitsTest.test_acpi_smbios_bits:
> ERROR: xorriso is not installed. Please install it. (0.00 s)
> RESULTS    : PASS 0 | ERROR 1 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0
> | CANCEL 0
> JOB TIME   : 0.61 s
>
>

skipIf() was not working for me, hence I had to resort to this. I got
skipIf() working now so in v6 I will remove the above hunk and add the
conditional as @skipIf decorator.

For the records,
> @skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab')
does not work for me.
> @skipIf(os.getenv('GITLAB_CI') is not None, 'Running on GitLab')
works.
A quick grep indicates that the former is used all over the place!

$ grep GITLAB_CI *
grep: acpi-bits: Is a directory
acpi-bits.py:@skipIf(os.getenv('GITLAB_CI') is not None, 'Running on GitLab')
grep: avocado_qemu: Is a directory
boot_linux.py:    @skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab')
intel_iommu.py:@skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab')
linux_initrd.py:    @skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab')
machine_aspeed.py:    @skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab')
machine_aspeed.py:    @skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab')
machine_mips_malta.py:    @skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab')
machine_mips_malta.py:    @skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab')
machine_rx_gdbsim.py:    @skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab')
machine_rx_gdbsim.py:    @skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab')
machine_s390_ccw_virtio.py:    @skipIf(os.getenv('GITLAB_CI'),
'Running on GitLab')
grep: __pycache__: Is a directory
replay_kernel.py:    @skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab')
replay_kernel.py:    @skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab')
reverse_debugging.py:    @skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab')
reverse_debugging.py:    @skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab')
smmu.py:@skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab')

Reply via email to