Received: from eggs.gnu.org ([2001:4830:134:3::10]:50270) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bkSKG-0002rA-Gv for qemu-devel@nongnu.org; Thu, 15 Sep 2016 04:47:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bkSKD-00069v-95 for qemu-devel@nongnu.org; Thu, 15 Sep 2016 04:47:20 -0400 Date: Thu, 15 Sep 2016 10:47:03 +0200 From: Kevin Wolf Message-ID: <20160915084703.GC4726@noname.redhat.com> References: <1471625435-6190-1-git-send-email-kwolf@redhat.com> <1471625435-6190-11-git-send-email-kwolf@redhat.com> <32842c09-6dce-b68b-d95e-de3813099faa@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="wxDdMuZNg1r63Hyj" Content-Disposition: inline In-Reply-To: <32842c09-6dce-b68b-d95e-de3813099faa@redhat.com> Subject: Re: [Qemu-devel] [PATCH 10/10] qemu-iotests/118: Test media change with qdev name List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: qemu-block@nongnu.org, mreitz@redhat.com, qemu-devel@nongnu.org --wxDdMuZNg1r63Hyj Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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. > >=20 > > Signed-off-by: Kevin Wolf > > --- > > tests/qemu-iotests/118 | 85 ++++++++++++++++++++++++++++++++++-= -------- > > tests/qemu-iotests/iotests.py | 5 +++ > > 2 files changed, 73 insertions(+), 17 deletions(-) > >=20 >=20 > > @@ -76,9 +79,15 @@ class GeneralChangeTestsBaseClass(ChangeBaseClass): > > self.assert_qmp(result, 'return[0]/inserted/image/filename', n= ew_img) > > =20 > > def test_blockdev_change_medium(self): > > - result =3D self.vm.qmp('blockdev-change-medium', device=3D'dri= ve0', > > - filename=3Dnew_= img, > > - format=3Diotest= s.imgfmt) > > + if self.device_name is not None: > > + result =3D self.vm.qmp('blockdev-change-medium', > > + id=3Dself.device_name, filename=3Dnew= _img, > > + format=3Diotests.imgfmt) > > + else: > > + result =3D self.vm.qmp('blockdev-change-medium', > > + device=3D'drive0', filename=3Dnew_img, > > + format=3Diotests.imgfmt) >=20 > 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: if else 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 --wxDdMuZNg1r63Hyj Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQIcBAEBAgAGBQJX2mAHAAoJEH8JsnLIjy/WlzgP/3tYlC4szaBQu2bVV4wh6Hcq 13EYW4kNM5TsCKUY7hkQu0+k4qkqkN5I4pNK3r0ZD7Co+fha1Bu+Kwm5AL772PHN Sil4GzKGIEXFC1oNx2TUGPvrbsNSnMhcn70hexmDIlRXReqTPC2eKcIrZZVnoqG3 wRlbySqEjCF/Ma+BA5gScxFGs1PifJR+1Qpbp1UV+8BWNoj4WQcUbWsxICkG8UtQ jGwNfNc2SaWoGPgJi6hBF2MjTjTWZikUkwQGfIK6/R9WSGSjQAwyh6CzAMp70vck AdaXSvKtRyYfHxii9XJgnxxiM1Y+VkEu2Hvd/HINnIm1bwVrB75dyV7i/FQ8zJlL Um59vz5RASRw46FtwAcKIco7Z6uTR26jkD/HNdgo0wiDpImJk+g58UoPnbAiGmKt 31qRM5Y6ax0XhawuVzeTiyxdUKV0pIVG5ewlBGJ0cPE5qIHeICc6ndwqFLOoOLJO CMcDJGvsbLKxBtKi+mgjs9NKFxtyiMkGlDkcx8L2fmTKC58BHTYJVIqFqn8/6Wd8 SevnBX3/8Y0yyE5CIk5zsHDs+e8xH7utw5mC8Hm520ao07B8IT9McEtlvIijlX3T Wu/VpCKnUVac5VrFZ2iOFnb1thaZSXTV30vjQbhE+sS79y/4PZ0Hcom8e4Ur/zKc hlLit33PI8QXazL8zKIO =BdMj -----END PGP SIGNATURE----- --wxDdMuZNg1r63Hyj--