All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Eric Blake <eblake@redhat.com>
Cc: qemu-block@nongnu.org, mreitz@redhat.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 10/10] qemu-iotests/118: Test media change with qdev name
Date: Thu, 15 Sep 2016 10:47:03 +0200	[thread overview]
Message-ID: <20160915084703.GC4726@noname.redhat.com> (raw)
In-Reply-To: <32842c09-6dce-b68b-d95e-de3813099faa@redhat.com>

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

Am 15.09.2016 um 00:13 hat Eric Blake geschrieben:
> On 08/19/2016 11:50 AM, Kevin Wolf wrote:
> > We just added the option to use qdev device names in all device related
> > block QMP commands. This patch converts some of the test cases in 118 to
> > use qdev device names instead of BlockBackend names to cover the new
> > way. It converts cases for each of the media change commands, but only
> > for CD-ROM and not everywhere, so that the old way is still tested, too.
> > 
> > Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> > ---
> >  tests/qemu-iotests/118        | 85 ++++++++++++++++++++++++++++++++++---------
> >  tests/qemu-iotests/iotests.py |  5 +++
> >  2 files changed, 73 insertions(+), 17 deletions(-)
> > 
> 
> > @@ -76,9 +79,15 @@ class GeneralChangeTestsBaseClass(ChangeBaseClass):
> >          self.assert_qmp(result, 'return[0]/inserted/image/filename', new_img)
> >  
> >      def test_blockdev_change_medium(self):
> > -        result = self.vm.qmp('blockdev-change-medium', device='drive0',
> > -                                                       filename=new_img,
> > -                                                       format=iotests.imgfmt)
> > +        if self.device_name is not None:
> > +            result = self.vm.qmp('blockdev-change-medium',
> > +                                 id=self.device_name, filename=new_img,
> > +                                 format=iotests.imgfmt)
> > +        else:
> > +            result = self.vm.qmp('blockdev-change-medium',
> > +                                 device='drive0', filename=new_img,
> > +                                 format=iotests.imgfmt)
> 
> I'm not enough of a python guru to know if there is any way to compress
> this to a shorter format (I do know, however, that the lack of an
> obvious ?: operator in python can indeed result in verbose if/else
> clauses compared to other languages).

Not a Python guru either, but it does have an equivalent for the ?:
operator, just with a weird syntax:

    <value1> if <condition> else <value2>

However, I'm not sure if that would be applicable here. It depends on
whether not passing an option at all and passing None does the same
thing, or if None sends something like an empty object or JSON null.

> At any rate, the ultimate test is whether the change still passes; and
> looks like you have good coverage of using exactly one or the other
> argument.  Do you also want to add tests (either here, or in 11/10) that
> validate that providing neither 'device' nor 'id' gives a sane error,
> likewise that providing both has sane behavior?  (For now, our behavior
> is that we fail, although it could also be argued that sane behavior
> would validate that 'id' happens to be currently in use by 'device' and
> only fail if they are not pointing to the same backend).

I think failure is right. If you're using the new interface, you should
be using the new interface only.

Anyway, adding tests for this probably makes sense, I'll have a look.

Kevin

[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]

  reply	other threads:[~2016-09-15  8:47 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-19 16:50 [Qemu-devel] [PATCH 00/10] block: Accept qdev IDs in device level QMP commands Kevin Wolf
2016-08-19 16:50 ` [Qemu-devel] [PATCH 01/10] block: Add blk_by_dev() Kevin Wolf
2016-08-19 16:50 ` [Qemu-devel] [PATCH 02/10] qdev-monitor: Factor out find_device_state() Kevin Wolf
2016-08-19 16:50 ` [Qemu-devel] [PATCH 03/10] qdev-monitor: Add blk_by_qdev_id() Kevin Wolf
2016-08-19 16:50 ` [Qemu-devel] [PATCH 04/10] block: Accept device model name for blockdev-open/close-tray Kevin Wolf
2016-09-14 20:49   ` Eric Blake
2016-09-15  8:35     ` Kevin Wolf
2016-09-15 15:51       ` Eric Blake
2016-09-19 15:10         ` Kevin Wolf
2016-08-19 16:50 ` [Qemu-devel] [PATCH 05/10] block: Accept device model name for x-blockdev-insert-medium Kevin Wolf
2016-09-14 20:57   ` Eric Blake
2016-09-15  8:37     ` Kevin Wolf
2016-09-15 15:53       ` Eric Blake
2016-08-19 16:50 ` [Qemu-devel] [PATCH 06/10] block: Accept device model name for x-blockdev-remove-medium Kevin Wolf
2016-09-14 21:01   ` Eric Blake
2016-08-19 16:50 ` [Qemu-devel] [PATCH 07/10] block: Accept device model name for eject Kevin Wolf
2016-09-14 21:09   ` Eric Blake
2016-08-19 16:50 ` [Qemu-devel] [PATCH 08/10] block: Accept device model name for blockdev-change-medium Kevin Wolf
2016-09-14 22:06   ` Eric Blake
2016-08-19 16:50 ` [Qemu-devel] [PATCH 09/10] block: Accept device model name for block_set_io_throttle Kevin Wolf
2016-09-14 22:07   ` Eric Blake
2016-08-19 16:50 ` [Qemu-devel] [PATCH 10/10] qemu-iotests/118: Test media change with qdev name Kevin Wolf
2016-09-14 22:13   ` Eric Blake
2016-09-15  8:47     ` Kevin Wolf [this message]
2016-09-15 16:16     ` Sascha Silbe
2016-09-15 16:23       ` Eric Blake
2016-09-15 16:28       ` Sascha Silbe
2016-09-15 16:33         ` Eric Blake
2016-09-15 17:57           ` Sascha Silbe
2016-09-05 15:55 ` [Qemu-devel] [PATCH 00/10] block: Accept qdev IDs in device level QMP commands Kevin Wolf
2016-09-14 13:03   ` [Qemu-devel] [Qemu-block] " Kevin Wolf
2016-09-14 21:52     ` John Snow

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=20160915084703.GC4726@noname.redhat.com \
    --to=kwolf@redhat.com \
    --cc=eblake@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /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.