qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Ani Sinha <ani@anisinha.ca>
Cc: Thomas Huth <thuth@redhat.com>,
	qemu-devel@nongnu.org, Laurent Vivier <lvivier@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	imammedo@redhat.com, John Snow <jsnow@redhat.com>
Subject: Re: [PATCH 09/12] acpi/tests/bits: add acpi and smbios python tests that uses biosbits
Date: Tue, 28 Jun 2022 05:55:06 -0400	[thread overview]
Message-ID: <20220628055416-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <CAARzgwz2oNiR56j7UYstEVweianLUwy8AqC5yRccyR2f4iWipA@mail.gmail.com>

On Tue, Jun 28, 2022 at 12:56:52PM +0530, Ani Sinha wrote:
> On Tue, Jun 28, 2022 at 12:50 PM Thomas Huth <thuth@redhat.com> wrote:
> >
> > On 27/06/2022 09.28, Ani Sinha wrote:
> > > This change adds python based qtest framework that can be used to run
> > > qtests from within a virtual environment. A bash script creates the virtual
> > > environment and then runs the python based tests from within that environment.
> > > All dependent python packages are installed in the virtual environment using
> > > pip module. QEMU python test modules are also available in the environment for
> > > spawning the QEMU based VMs.
> > >
> > > It also introduces QEMU acpi/smbios biosbits python test script which is run
> > > from within the python virtual environment.
> > >
> > > Signed-off-by: Ani Sinha <ani@anisinha.ca>
> > > ---
> > >   tests/qtest/acpi-bits/acpi-bits-test-venv.sh |  59 ++++
> > >   tests/qtest/acpi-bits/acpi-bits-test.py      | 327 +++++++++++++++++++
> > >   tests/qtest/acpi-bits/meson.build            |  39 +++
> > >   tests/qtest/acpi-bits/requirements.txt       |   1 +
> > >   4 files changed, 426 insertions(+)
> > >   create mode 100644 tests/qtest/acpi-bits/acpi-bits-test-venv.sh
> > >   create mode 100644 tests/qtest/acpi-bits/acpi-bits-test.py
> > >   create mode 100644 tests/qtest/acpi-bits/meson.build
> > >   create mode 100644 tests/qtest/acpi-bits/requirements.txt
> > >
> > > diff --git a/tests/qtest/acpi-bits/acpi-bits-test-venv.sh b/tests/qtest/acpi-bits/acpi-bits-test-venv.sh
> > > new file mode 100644
> > > index 0000000000..124e03ce18
> > > --- /dev/null
> > > +++ b/tests/qtest/acpi-bits/acpi-bits-test-venv.sh
> > > @@ -0,0 +1,59 @@
> > > +#!/usr/bin/env bash
> > > +# Generates a python virtual environment for the test to run.
> > > +# Then runs python test scripts from within that virtual environment.
> > > +#
> > > +# 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 <ani@anisinha.ca>
> > > +
> > > +set -e
> > > +
> > > +MYPATH=$(realpath ${BASH_SOURCE:-$0})
> > > +MYDIR=$(dirname $MYPATH)
> > > +
> > > +if [ -z "$QTEST_SOURCE_ROOT" ]; then
> > > +    echo -n "Please set QTEST_SOURCE_ROOT env pointing"
> > > +    echo " to the root of the qemu source tree."
> > > +    echo -n "This is required so that the test can find the "
> > > +    echo "python modules that it needs for execution."
> > > +    exit 1
> > > +fi
> > > +SRCDIR=$QTEST_SOURCE_ROOT
> > > +TESTSCRIPTS=("acpi-bits-test.py")
> > > +PIPCMD="-m pip -q --disable-pip-version-check"
> > > +# we need to save the old value of PWD before we do a change-dir later
> > > +QTEST_PWD=$PWD
> > > +
> > > +TESTS_PYTHON=/usr/bin/python3
> > > +TESTS_VENV_REQ=requirements.txt
> > > +
> > > +# sadly for pip -e and -t options do not work together.
> > > +# please see https://github.com/pypa/pip/issues/562
> > > +cd $MYDIR
> > > +
> > > +$TESTS_PYTHON -m venv .
> > > +$TESTS_PYTHON $PIPCMD install -e $SRCDIR/python/
> > > +[ -f $TESTS_VENV_REQ ] && \
> > > +    $TESTS_PYTHON $PIPCMD install -r $TESTS_VENV_REQ
> > > +
> > > +# venv is activated at this point.
> > > +
> > > +# run the test
> > > +for testscript in ${TESTSCRIPTS[@]} ; do
> > > +    export QTEST_PWD; python3 $testscript
> > > +done
> > > +
> > > +cd $QTEST_PWD
> > > +
> > > +exit 0
> > > diff --git a/tests/qtest/acpi-bits/acpi-bits-test.py b/tests/qtest/acpi-bits/acpi-bits-test.py
> > > new file mode 100644
> > > index 0000000000..673567bf8e
> > > --- /dev/null
> > > +++ b/tests/qtest/acpi-bits/acpi-bits-test.py
> > > @@ -0,0 +1,327 @@
> > > +#!/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/>.
> > > +#
> > > +# Some parts are slightly taken from qtest.py and iotests.py
> > > +#
> > > +# Authors:
> > > +#  Ani Sinha <ani@anisinha.ca>
> > > +
> > > +# pylint: disable=invalid-name
> > > +
> > > +"""
> > > +QEMU bios tests using biosbits available at
> > > +https://biosbits.org/.
> > > +"""
> > > +
> > > +import logging
> > > +import os
> > > +import re
> > > +import shutil
> > > +import subprocess
> > > +import sys
> > > +import tarfile
> > > +import tempfile
> > > +import time
> > > +import unittest
> > > +import zipfile
> > > +from typing import (
> > > +    List,
> > > +    Optional,
> > > +    Sequence,
> > > +)
> > > +from tap import TAPTestRunner
> > > +from qemu.machine import QEMUMachine
> > > +
> > > +QTESTQEMUPROG = os.getenv('QTEST_QEMU_BINARY')
> > > +QTEST_PWD = os.getenv('QTEST_PWD')
> > > +
> > > +def get_arch():
> > > +    """finds the arch from the qemu binary name"""
> > > +    match = re.search('.*qemu-system-(.*)', QTESTQEMUPROG)
> > > +    if match:
> > > +        return match.group(1)
> > > +    return 'x86_64'
> > > +
> > > +ARCH = get_arch()
> > > +
> > > +class QEMUBitsMachine(QEMUMachine):
> > > +    """
> > > +    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
> >
> > So is this patch series *really* related to qtests? qtests are using a
> > special "accelerator" mode of QEMU where it gets launched with the "-qtest"
> > parameter. I can't see that you're using "-qtest" here or anywhere else, so
> > this rather looks like another framework to me to run python-based QEMU
> > tests (similar to the avocado tests).
> 
> yes you are right. This does not use or need the qtest accelerator
> because we are not inspecting the guest memory for anything.

Same is true for e.g. ./tests/qtest/bios-tables-test.c ...


> >
> > Thus if this is really not related to qtests, may I suggest to move this
> > into another folder instead? Maybe tests/pytests/acpi-bits or something similar?
> 
> The problem I faced with this test is that it does not quite fall into
> the qtest category. Nor does it fall into the integration test
> category. I asked Igor and he suggested I use the qtest framework.
> Should we invent a new class of tests then? How many such tests are we
> going to have in the future?  Lets see what others think.
> 
> >
> >   Thomas
> >



  parent reply	other threads:[~2022-06-28  9:56 UTC|newest]

Thread overview: 118+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-27  7:28 [PATCH 00/12] Introduce new acpi/smbios qtests using biosbits Ani Sinha
2022-06-27  7:28 ` [PATCH 01/12] qtest: meson.build changes required to integrate python based qtests Ani Sinha
2022-06-27  7:28 ` [PATCH 04/12] acpi/tests/bits: initial commit of test scripts that are run by biosbits Ani Sinha
2022-06-28  7:24   ` Thomas Huth
2022-06-28  9:52     ` Michael S. Tsirkin
2022-06-27  7:28 ` [PATCH 05/12] acpi/tests/bits: disable acpi PSS tests that are failing in biosbits Ani Sinha
2022-06-27  7:28 ` [PATCH 06/12] acpi/tests/bits: add smilatency test suite from bits in order to disable it Ani Sinha
2022-06-27  7:28 ` [PATCH 07/12] acpi/tests/bits: disable smilatency test since it does not pass everytime Ani Sinha
2022-06-27  7:28 ` [PATCH 08/12] acpi/tests/bits: add biosbits config file for running bios tests Ani Sinha
2022-06-27  7:28 ` [PATCH 09/12] acpi/tests/bits: add acpi and smbios python tests that uses biosbits Ani Sinha
2022-06-28  7:20   ` Thomas Huth
2022-06-28  7:26     ` Ani Sinha
2022-06-28  7:36       ` Thomas Huth
2022-06-28  9:55       ` Michael S. Tsirkin [this message]
2022-06-28 10:00         ` Thomas Huth
2022-06-27  7:28 ` [PATCH 10/12] acpi/tests/bits: add acpi bits qtest directory in meson for running tests Ani Sinha
2022-06-27  7:28 ` [PATCH 11/12] acpi/tests/bits: add README file for bits qtests Ani Sinha
2022-06-27 22:26   ` Michael S. Tsirkin
2022-06-28  4:57     ` Ani Sinha
2022-06-28  6:06       ` Michael S. Tsirkin
2022-06-28  6:16         ` Ani Sinha
2022-06-28  6:20           ` Michael S. Tsirkin
2022-06-28  6:36             ` Ani Sinha
2022-06-28  6:50               ` Michael S. Tsirkin
2022-06-28  6:57                 ` Ani Sinha
2022-06-28  7:03                   ` venv for python qtest bits? (was: Re: [PATCH 11/12] acpi/tests/bits: add README file for bits qtests) Thomas Huth
2022-06-28  7:10                     ` Michael S. Tsirkin
2022-06-28  7:25                       ` Thomas Huth
2022-06-28  7:48                         ` Daniel P. Berrangé
2022-06-28  7:51                           ` Ani Sinha
2022-06-28  8:23                             ` Daniel P. Berrangé
2022-06-28  8:28                               ` Thomas Huth
2022-06-28  8:35                                 ` Ani Sinha
2022-06-28  8:49                                   ` Ani Sinha
2022-06-28 10:03                                     ` Michael S. Tsirkin
2022-06-28 10:21                                       ` Why we should avoid new submodules if possible Thomas Huth
2022-06-28 10:30                                         ` Michael S. Tsirkin
2022-06-28 10:43                                           ` Peter Maydell
2022-06-28 11:00                                             ` Michael S. Tsirkin
2022-06-28 14:54                                               ` Warner Losh
2022-09-28 20:48                                               ` Michal Suchánek
2022-09-28 21:07                                                 ` Michael S. Tsirkin
2022-09-28 21:43                                                   ` Michal Suchánek
2022-06-28 10:50                                           ` Thomas Huth
2022-06-28 11:14                                             ` Michael S. Tsirkin
2022-06-28 12:39                                               ` Thomas Huth
2022-06-28 14:45                                                 ` Michael S. Tsirkin
2022-06-28 15:54                                                 ` Ani Sinha
2022-06-28 16:15                                                   ` Daniel P. Berrangé
2022-06-28 18:00                                                     ` Michael S. Tsirkin
2022-06-29  6:28                                                       ` Ani Sinha
2022-07-01  3:34                                                         ` Thomas Huth
2022-07-02  0:05                                                           ` Philippe Mathieu-Daudé via
2022-09-28  9:26                                         ` Michael S. Tsirkin
2022-09-28  9:33                                           ` Thomas Huth
2022-09-28  9:47                                             ` Michael S. Tsirkin
2022-09-28  9:55                                               ` Thomas Huth
2022-09-28  9:37                                           ` Daniel P. Berrangé
2022-09-28  9:53                                             ` Michael S. Tsirkin
2022-09-28  9:57                                               ` Daniel P. Berrangé
2022-09-28 10:07                                                 ` Michael S. Tsirkin
2022-09-28 13:15                                                 ` Warner Losh
2022-09-28 13:22                                                   ` Michael S. Tsirkin
2022-09-28 10:13                                             ` Michael S. Tsirkin
2022-09-28 10:18                                               ` Daniel P. Berrangé
2022-09-28 13:12                                                 ` Michael S. Tsirkin
2022-09-28 15:07                                                   ` Peter Maydell
2022-09-28 19:59                                                     ` Michael S. Tsirkin
2022-09-28 13:06                                               ` Warner Losh
2022-06-28 10:04                                   ` venv for python qtest bits? (was: Re: [PATCH 11/12] acpi/tests/bits: add README file for bits qtests) Daniel P. Berrangé
2022-06-28 10:07                                     ` Michael S. Tsirkin
2022-06-28 10:18                                       ` Daniel P. Berrangé
2022-06-28 10:25                                         ` Michael S. Tsirkin
2022-06-28 10:41                                         ` Ani Sinha
2022-06-28 10:28                                       ` Ani Sinha
2022-06-28 10:42                                         ` Daniel P. Berrangé
2022-06-28 11:18                                           ` Michael S. Tsirkin
2022-06-28 11:28                                           ` Michael S. Tsirkin
2022-06-28 12:10                                             ` Peter Maydell
2022-06-28 12:36                                               ` Ani Sinha
2022-06-28 12:42                                                 ` Thomas Huth
2022-06-28 12:55                                                 ` Daniel P. Berrangé
2022-06-28 13:22                                                   ` Ani Sinha
2022-06-28 13:44                                                     ` Peter Maydell
2022-06-28 13:53                                                       ` Ani Sinha
2022-06-28 13:55                                                         ` Peter Maydell
2022-07-01  4:12                                                         ` Thomas Huth
2022-07-01  6:53                                                           ` Michael S. Tsirkin
2022-07-01  7:28                                                             ` Ani Sinha
2022-07-01  7:38                                                               ` Michael S. Tsirkin
2022-07-01  7:50                                                                 ` Ani Sinha
2022-07-01  9:42                                                                   ` Michael S. Tsirkin
2022-07-01 10:14                                                                     ` Ani Sinha
2022-07-01 12:54                                                                       ` Michael S. Tsirkin
2022-07-04 13:32                                                                         ` Ani Sinha
2022-07-05 13:48                                                                           ` Ani Sinha
2022-07-07 12:49                                                                 ` Ani Sinha
2022-06-28 14:41                                                     ` Michael S. Tsirkin
2022-06-28 14:38                                                   ` Michael S. Tsirkin
2022-06-28 10:14                                 ` Daniel P. Berrangé
2022-06-28 10:21                                   ` Michael S. Tsirkin
2022-06-28 10:30                                     ` Thomas Huth
2022-06-28 10:30                                   ` Ani Sinha
2022-06-28 10:49                                     ` Ani Sinha
2022-06-28 10:12                               ` Michael S. Tsirkin
2022-06-28 10:16                                 ` Daniel P. Berrangé
2022-06-28 10:00                           ` Michael S. Tsirkin
2022-06-28  7:49                         ` Ani Sinha
2022-06-28  7:53                           ` Thomas Huth
2022-06-28  9:53                         ` Michael S. Tsirkin
2022-06-28  7:05                   ` [PATCH 11/12] acpi/tests/bits: add README file for bits qtests Ani Sinha
2022-06-27  7:28 ` [PATCH 12/12] MAINTAINERS: add myself as the maintainer for acpi biosbits qtests Ani Sinha
2022-06-28  8:09 ` [PATCH 00/12] Introduce new acpi/smbios qtests using biosbits Daniel P. Berrangé
2022-06-28  8:33   ` Ani Sinha
2022-06-28 10:06     ` Daniel P. Berrangé
2022-06-28 10:16       ` Michael S. Tsirkin
2022-06-28 10:21         ` Daniel P. Berrangé
2022-06-28 10:35           ` Michael S. Tsirkin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220628055416-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=ani@anisinha.ca \
    --cc=imammedo@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=lvivier@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).