qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@redhat.com>
To: Nir Soffer <nirsof@gmail.com>
Cc: "Philippe Mathieu-Daudé" <f4bug@amsat.org>,
	"Edgar E . Iglesias" <edgar.iglesias@xilinx.com>,
	"Kevin Wolf" <kwolf@redhat.com>, "Thomas Huth" <thuth@redhat.com>,
	"Daniel P . Berrange" <berrange@redhat.com>,
	"Eduardo Habkost" <ehabkost@redhat.com>,
	qemu-block@nongnu.org, qemu-devel@nongnu.org,
	"Max Reitz" <mreitz@redhat.com>,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Cleber Rosa" <crosa@redhat.com>,
	"Lukáš Doktor" <ldoktor@redhat.com>,
	"Fam Zheng" <famz@redhat.com>,
	"Alistair Francis" <alistair.francis@xilinx.com>
Subject: Re: [Qemu-devel] [Qemu-block] [PATCH 0/6] QTests: use Python to run complex tests
Date: Mon, 18 Dec 2017 13:59:04 +0000	[thread overview]
Message-ID: <20171218135904.GF16653@stefanha-x1.localdomain> (raw)
In-Reply-To: <CAMr-obtBNF8eetFgz=s8vJGqnzGa8+9n4VnF40vZYy5yeFZ3wQ@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 3189 bytes --]

On Thu, Dec 14, 2017 at 03:35:07PM +0000, Nir Soffer wrote:
> On Thu, Dec 14, 2017 at 11:39 AM Stefan Hajnoczi <stefanha@redhat.com>
> wrote:
> 
> > On Wed, Dec 13, 2017 at 06:35:51PM -0300, Philippe Mathieu-Daudé wrote:
> > > Hi,
> > >
> > > With this series we can now write tests using Python rather than C.
> > > For complex tests this can reduce the test development time, we can
> > focus on
> > > the test purposes instead of his implementation details.
> > >
> > > - 1,2: we already have Python classes to run Block tests, move all the
> > >   non Block-related methods to qtest.py,
> > > - 3: default TEST_DIR to TMPDIR,
> > > - 4: add a method to restrict tests to a list of supported machines,
> > > - 5: since the Block tests are output sensitive, do not mess with their
> > >   current tuned iotests::main(unittest), add a more generic one in
> > qtest.py,
> > > - 6: finally modify the tests Makefile to run C/Python tests with the
> > same
> > >   rule.
> >
> > Python tests are great for functional tests of qemu-system-* that
> > interact via the command-line and QMP monitor.  From this perspective I
> > think the series is good.
> >
> > > to have a better idea, here is a snippet from the next series:
> > >
> > >     class TestSdCardSpecV2(qtest.QMPTestCase):
> > >         [...]
> > >         def test_power_on_spec_v2(self):
> > >             self.bus.do_cmd(GO_IDLE_STATE)
> > >             [...]
> > >             # verify Card ID
> > >             data = self.bus.do_cmd(ALL_SEND_CID)
> > >             oid, pnm, psn = struct.unpack(">x2s5sxLxxx", data)
> > >             self.assertEqual(oid, "XY") # QEMU default
> > >             self.assertEqual(pnm, "QEMU!") # QEMU default
> > >             self.assertEqual(psn, 0xdeadbeef) # QEMU default
> >
> > Device qtests are better done in C than Python.  Python is not good at
> > binary I/O
> 
> 
> Why do you think that? what is missing in python 2 for binary io?

C code can reuse existing header files for struct definitions instead
of doing oid, pnm, psn = struct.unpack(">x2s5sxLxxx", data).

In general, Python's model for binary data is a marshalling (copy) model
rather than a type casting (in-place access) model.  It's fine for some
things but programs that deal with a lot of raw data may use third-party
unboxed data primitives like numpy's instead.  I definitely wouldn't say
that binary I/O is a strength of Python.

> > and porting this to Python 3 will be extra work later (Python
> > 2 is set for End-of-Life in 2020, see https://pythonclock.org/).
> >
> 
> You can write today code that work with both python 2 and 3. For binary
> io the key is using io.FileIO and io.BytesIO instead of open() and StringIO
> and CStringIO.

Yes, it's possible to write the code carefully and test under both
Python 2 & 3.  We have to do that for Python code in QEMU since the
world is currently transitioning and both Python versions are in use.

So in this case, where it's questionable to start a new device-level
testing framework in the first place, the extra trouble of dealing with
Python 2 & 3 makes it even less appealing.

Stefan

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]

  reply	other threads:[~2017-12-18 13:59 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-13 21:35 [Qemu-devel] [PATCH 0/6] QTests: use Python to run complex tests Philippe Mathieu-Daudé
2017-12-13 21:35 ` [Qemu-devel] [PATCH 1/6] iotests.py: split BlockQMPTestCase class of QMPTestCase Philippe Mathieu-Daudé
2017-12-13 21:35 ` [Qemu-devel] [PATCH 2/6] iotests.py: move the generic QMPTestCase to qtest.py Philippe Mathieu-Daudé
2017-12-13 21:35 ` [Qemu-devel] [PATCH 3/6] qtest.py: use TMPDIR/TEMP if the TEST_DIR env var is missing Philippe Mathieu-Daudé
2017-12-13 21:35 ` [Qemu-devel] [PATCH 4/6] qtest.py: add verify_machine(supported_machines) Philippe Mathieu-Daudé
2017-12-13 21:35 ` [Qemu-devel] [PATCH 5/6] qtest.py: add a simple main() which calls unittest.main() Philippe Mathieu-Daudé
2017-12-13 21:35 ` [Qemu-devel] [PATCH 6/6] tests: add a Makefile rule to run Python qtests Philippe Mathieu-Daudé
2017-12-14  9:39 ` [Qemu-devel] [PATCH 0/6] QTests: use Python to run complex tests Stefan Hajnoczi
2017-12-14 11:35   ` Paolo Bonzini
2017-12-14 15:39     ` [Qemu-devel] [Qemu-block] " Nir Soffer
2017-12-14 16:01       ` Philippe Mathieu-Daudé
2017-12-14 16:05       ` Markus Armbruster
2017-12-14 17:33         ` Paolo Bonzini
2017-12-14 19:08           ` Peter Maydell
2017-12-14 19:38             ` Paolo Bonzini
2017-12-14 14:33   ` [Qemu-devel] " Philippe Mathieu-Daudé
2017-12-14 17:18     ` Stefan Hajnoczi
2017-12-14 18:46       ` Philippe Mathieu-Daudé
2017-12-14 15:35   ` [Qemu-devel] [Qemu-block] " Nir Soffer
2017-12-18 13:59     ` Stefan Hajnoczi [this message]
2017-12-18 16:09       ` Paolo Bonzini

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=20171218135904.GF16653@stefanha-x1.localdomain \
    --to=stefanha@redhat.com \
    --cc=alistair.francis@xilinx.com \
    --cc=berrange@redhat.com \
    --cc=crosa@redhat.com \
    --cc=edgar.iglesias@xilinx.com \
    --cc=ehabkost@redhat.com \
    --cc=f4bug@amsat.org \
    --cc=famz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=ldoktor@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=nirsof@gmail.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-block@nongnu.org \
    --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).