All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Thomas Huth <thuth@redhat.com>
Cc: "Alex Bennée" <alex.bennee@linaro.org>,
	qemu-devel@nongnu.org,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Ani Sinha" <anisinha@redhat.com>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"John Snow" <jsnow@redhat.com>, "Cédric Le Goater" <clg@kaod.org>,
	"Fabiano Rosas" <farosas@suse.de>
Subject: Re: [PATCH v1 00/11] Convert avocado tests to normal Python unittests
Date: Wed, 17 Jul 2024 09:37:25 +0100	[thread overview]
Message-ID: <ZpeCxWhEglM_w_5l@redhat.com> (raw)
In-Reply-To: <2cae80ea-dbf6-4b1c-a086-756a5c6f15e0@redhat.com>

On Wed, Jul 17, 2024 at 10:04:19AM +0200, Thomas Huth wrote:
> On 16/07/2024 19.03, Thomas Huth wrote:
> > On 16/07/2024 18.51, Daniel P. Berrangé wrote:
> > > On Tue, Jul 16, 2024 at 01:26:03PM +0200, Thomas Huth wrote:
> > ...
> > > > So instead of trying to update the python-based test suite in QEMU
> > > > to a newer version of Avocado, we should maybe try to better integrate
> > > > it with the meson test runner instead. Indeed most tests work quite
> > > > nicely without the Avocado framework already, as you can see with
> > > > this patch series - it does not convert all tests, just a subset so
> > > > far, but this already proves that many tests only need small modifi-
> > > > cations to work without Avocado.
> > ...
> > > > Now if you want to try out these patches: Apply the patches, then
> > > > recompile and then run:
> > > > 
> > > >   make check-functional
> > > > 
> > > > You can also run single targets e.g. with:
> > > > 
> > > >   make check-functional-ppc
> > > > 
> > > > You can also run the tests without any test runner now by
> > > > setting the PYTHONPATH environment variable to the "python" folder
> > > > of your source tree, and by specifying the build directory via
> > > > QEMU_BUILD_ROOT (if autodetection fails) and by specifying the
> > > > QEMU binary via QEMU_TEST_QEMU_BINARY. For example:
> > > > 
> > > >   export PYTHONPATH=$HOME/qemu/python
> > > >   export QEMU_TEST_QEMU_BINARY=qemu-system-x86_64
> > > >   export PYTHONPATH=$HOME/qemu/build
> > > >   ~/qemu/tests/functional/test_virtio_version.py
> > > 
> > > For the whole series as is
> > > 
> > >   Tested-by: Daniel P. Berrangé <berrange@redhat.com>
> > > 
> > > as it does what you claim it does here when I tried it.
> > 
> > Thanks!
> > 
> > > > The logs of the tests can be found in the build directory under
> > > > tests/functional/<testname> - console log and general logs will
> > > > be put in separate files there.
> > > 
> > > As an example, one dir name appears to be:
> > > 
> > >    __main__.MemAddrCheck.test_phybits_ok_pentium_pae
> > > 
> > > I'd rather prefer it if the dir name matched the test script
> > > file name - in this case test_mem_addr_space.py, as I don't
> > > want to have to lookup which class names were defined inside
> > > each test script. We could drop the "test_" prefix from the
> > > method name too
> > > 
> > > IOW, could we make this dir name be:
> > > 
> > >    test_mem_addr_space.phybits_ok_pentium_pae
> > 
> > I can try to change that, indeed ... but the boilerplate code will
> > increase a little bit, I guess, since I cannot simply rely on the
> > unittest.id() function in that case anymore...
> 
> After looking at this for a while, I think it's maybe best to ditch the idea
> of making the .py files directly runnable and run the tests via a simple
> pycotap runner instead. Then you get proper module names:

I'd really not want to loose that. To me, eliminating the test harness
entirely when debugging is the single biggest improvement of this new
approach, especially when I want to 'strace' the test without
extraneous processes.

> $ pyvenv/bin/python3 -m pycotap test_virtio_version
> TAP version 13
> ok 1 test_virtio_version.VirtioVersionCheck.test_conventional_devs
> ok 2 test_virtio_version.VirtioVersionCheck.test_modern_only_devs
> 1..

With the following change, you get the same output with direct
execution, by making argv look the same as you'd get when
running your pycotap example.

diff --git a/tests/functional/qemu_test/__init__.py b/tests/functional/qemu_test/__init__.py
index cc49fd4c94..3a3e65252d 100644
--- a/tests/functional/qemu_test/__init__.py
+++ b/tests/functional/qemu_test/__init__.py
@@ -266,7 +266,10 @@ def fetch_asset(self, url, asset_hash):
     def main():
         tr = pycotap.TAPTestRunner(message_log = pycotap.LogMode.LogToError,
                                    test_output_log = pycotap.LogMode.LogToError)
-        unittest.main(testRunner = tr)
+        import sys
+        import os.path
+        path = os.path.basename(sys.argv[0])[:-3]
+        unittest.main(module = None, testRunner = tr, argv=["__dummy__", path])
 
 
 class QemuSystemTest(QemuBaseTest):

With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|



  reply	other threads:[~2024-07-17  8:39 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-16 11:26 [PATCH v1 00/11] Convert avocado tests to normal Python unittests Thomas Huth
2024-07-16 11:26 ` [PATCH 01/11] tests/functional: Add base classes for the upcoming pytest-based tests Thomas Huth
2024-07-16 11:26 ` [PATCH 02/11] tests/functional: Convert simple avocado tests into standalone python tests Thomas Huth
2024-07-16 18:14   ` Daniel P. Berrangé
2024-07-16 11:26 ` [PATCH 03/11] tests/functional: Convert avocado tests that just need a small adjustment Thomas Huth
2024-07-16 18:15   ` Daniel P. Berrangé
2024-07-16 11:26 ` [PATCH 04/11] tests/functional: Add python-based tests to the meson build system Thomas Huth
2024-07-16 15:15   ` Fabiano Rosas
2024-07-17  9:20     ` Thomas Huth
2024-07-16 16:55   ` Daniel P. Berrangé
2024-07-16 11:26 ` [PATCH 05/11] tests/functional: Implement fetch_asset() method for downloading assets Thomas Huth
2024-07-16 18:17   ` Daniel P. Berrangé
2024-07-16 11:26 ` [PATCH 06/11] tests/functional: Convert some tests that download files via fetch_asset() Thomas Huth
2024-07-16 18:19   ` Daniel P. Berrangé
2024-07-16 11:26 ` [PATCH 07/11] tests/functional: Add a function for extracting files from an archive Thomas Huth
2024-07-16 18:20   ` Daniel P. Berrangé
2024-07-16 11:26 ` [PATCH 08/11] tests/functional: Convert some avocado tests that needed avocado.utils.archive Thomas Huth
2024-07-16 18:20   ` Daniel P. Berrangé
2024-07-16 11:26 ` [PATCH 09/11] tests/functional: Set up logging Thomas Huth
2024-07-16 18:22   ` Daniel P. Berrangé
2024-07-16 11:26 ` [PATCH 10/11] tests/functional: Convert the s390x avocado tests into standalone tests Thomas Huth
2024-07-16 18:24   ` Daniel P. Berrangé
2024-07-16 11:26 ` [PATCH 11/11] gitlab-ci: Add "check-functional" to the build tests Thomas Huth
2024-07-16 18:25   ` Daniel P. Berrangé
2024-07-16 16:51 ` [PATCH v1 00/11] Convert avocado tests to normal Python unittests Daniel P. Berrangé
2024-07-16 17:03   ` Thomas Huth
2024-07-17  8:04     ` Thomas Huth
2024-07-17  8:37       ` Daniel P. Berrangé [this message]
2024-07-17  8:53         ` Thomas Huth
2024-07-16 17:57 ` Paolo Bonzini
2024-07-24 11:43   ` Thomas Huth
2024-07-25 14:21 ` Cleber Rosa
2024-07-26 10:07   ` Thomas Huth
2024-07-26 13:56     ` Cleber Rosa
2024-07-29 12:44   ` Daniel P. Berrangé
2024-07-29 14:01     ` Cleber Rosa

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=ZpeCxWhEglM_w_5l@redhat.com \
    --to=berrange@redhat.com \
    --cc=alex.bennee@linaro.org \
    --cc=anisinha@redhat.com \
    --cc=clg@kaod.org \
    --cc=farosas@suse.de \
    --cc=jsnow@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.