From nobody Sat May 4 00:47:44 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1564606148; cv=none; d=zoho.com; s=zohoarc; b=HKwC+DrbAaUbSEDk9G4dphkTC9Ej+Kiub/wml7+Jh8GXsZNYgvXYJ/cOgUPwF0gLlK7z70y066rOexNPLsvSQZxdYcHV1ExZwmx8KQY9N53hOj+PpQ1vCbyvRuDuejY3UQc3wjAyMVH+htPs+PFru2i/72y7BE8/ZpbGmIhAXPA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564606148; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=FyDVklG0d6VwuUxaxkTSvA0Cyr+nlSmiuBcaGV5YB+o=; b=FrdnLuKuda/PVqwT5yOdOdyMH1a8d9Y+lzdWEKislKM6obm2YHfA7/Y/6VjZe/kXTrNr2MnGlJCQv5pdAoCOVsfaRZ6r2qZG/jALiMsakn55lUb/PknpEhknLPyKE/MCe7cvvVczFeBa6MiXdGinT7u9Rs4KRCuPeEFUjnZG5WI= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1564606148647805.1481289100493; Wed, 31 Jul 2019 13:49:08 -0700 (PDT) Received: from localhost ([::1]:44446 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvX1-0003Rs-N8 for importer@patchew.org; Wed, 31 Jul 2019 16:49:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34027) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvQL-0003gg-1Y for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:42:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hsvQJ-0005ly-Rc for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:42:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51186) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hsvQH-0005jf-CX; Wed, 31 Jul 2019 16:42:09 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A55BD30860B6; Wed, 31 Jul 2019 20:42:08 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-122.ams2.redhat.com [10.36.116.122]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9708B5C207; Wed, 31 Jul 2019 20:42:07 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Wed, 31 Jul 2019 22:42:01 +0200 Message-Id: <20190731204203.10732-2-kwolf@redhat.com> In-Reply-To: <20190731204203.10732-1-kwolf@redhat.com> References: <20190731204203.10732-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Wed, 31 Jul 2019 20:42:08 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 1/3] iotests/118: Test media change for scsi-cd X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" The test covered only floppy and ide-cd. Add scsi-cd as well. Signed-off-by: Kevin Wolf Reviewed-by: Max Reitz --- tests/qemu-iotests/118 | 20 ++++++++++++++++++++ tests/qemu-iotests/118.out | 4 ++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/tests/qemu-iotests/118 b/tests/qemu-iotests/118 index 499c5f0901..3c20d2d61f 100755 --- a/tests/qemu-iotests/118 +++ b/tests/qemu-iotests/118 @@ -33,6 +33,8 @@ def interface_to_device_name(interface): return 'ide-cd' elif interface =3D=3D 'floppy': return 'floppy' + elif interface =3D=3D 'scsi': + return 'scsi-cd' else: return None =20 @@ -297,6 +299,8 @@ class TestInitiallyFilled(GeneralChangeTestsBaseClass): qemu_img('create', '-f', iotests.imgfmt, new_img, '1440k') self.vm =3D iotests.VM() self.vm.add_drive(old_img, 'media=3D%s' % media, 'none') + if interface =3D=3D 'scsi': + self.vm.add_device('virtio-scsi-pci') self.vm.add_device('%s,drive=3Ddrive0,id=3D%s' % (interface_to_device_name(interface), self.device_name)) @@ -330,6 +334,8 @@ class TestInitiallyEmpty(GeneralChangeTestsBaseClass): def setUp(self, media, interface): qemu_img('create', '-f', iotests.imgfmt, new_img, '1440k') self.vm =3D iotests.VM().add_drive(None, 'media=3D%s' % media, 'no= ne') + if interface =3D=3D 'scsi': + self.vm.add_device('virtio-scsi-pci') self.vm.add_device('%s,drive=3Ddrive0,id=3D%s' % (interface_to_device_name(interface), self.device_name)) @@ -363,6 +369,20 @@ class TestCDInitiallyEmpty(TestInitiallyEmpty): def setUp(self): self.TestInitiallyEmpty.setUp(self, 'cdrom', 'ide') =20 +class TestSCSICDInitiallyFilled(TestInitiallyFilled): + TestInitiallyFilled =3D TestInitiallyFilled + has_real_tray =3D True + + def setUp(self): + self.TestInitiallyFilled.setUp(self, 'cdrom', 'scsi') + +class TestSCSICDInitiallyEmpty(TestInitiallyEmpty): + TestInitiallyEmpty =3D TestInitiallyEmpty + has_real_tray =3D True + + def setUp(self): + self.TestInitiallyEmpty.setUp(self, 'cdrom', 'scsi') + class TestFloppyInitiallyFilled(TestInitiallyFilled): TestInitiallyFilled =3D TestInitiallyFilled has_real_tray =3D False diff --git a/tests/qemu-iotests/118.out b/tests/qemu-iotests/118.out index 4823c113d5..b4ff997a8c 100644 --- a/tests/qemu-iotests/118.out +++ b/tests/qemu-iotests/118.out @@ -1,5 +1,5 @@ -............................................................... +..........................................................................= ............... ---------------------------------------------------------------------- -Ran 63 tests +Ran 89 tests =20 OK --=20 2.20.1 From nobody Sat May 4 00:47:44 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1564606497; cv=none; d=zoho.com; s=zohoarc; b=R/wi3g5njJ8FBTrlr1E/G0vBsiyuvr0Z4V3VQLpYwwJunGIo1bil9tL+bqSPxIp3qxvIPNVS3NvezmptzMPbpFT4f3d4qim7HPI4KKcondbzd3ejZMLJH4UYl7GAtRjTI05RaZB4BQlyStEf38P9BhhXnK5WVQWUtZSyEZME/ZQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564606497; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=b8JWS2tTRmbOzxEYyQMjbEd57Grvqsbep3KxtpTMUa0=; b=JfUxZtzK+0nWwWX4FDV7PeXbZ6PNkVOZjvxIf7jCK/v482F/3PxrMKBeo1k3hHBqG7ig8AkxvgHkCeoXpewvf/3kHn31GF53DaApV8zTXdnk4fexQo2PtIZk1x7q0U5OsRHKDpvgDD+sRCqyre5axcRdl/UafdbsBkpGGqH1kTw= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1564606497163420.1987273409378; Wed, 31 Jul 2019 13:54:57 -0700 (PDT) Received: from localhost ([::1]:44544 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvcd-00065P-WB for importer@patchew.org; Wed, 31 Jul 2019 16:54:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34050) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvQM-0003nS-ST for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:42:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hsvQL-0005ml-Iz for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:42:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46966) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hsvQI-0005kj-NT; Wed, 31 Jul 2019 16:42:10 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0BE4F300C72A; Wed, 31 Jul 2019 20:42:10 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-122.ams2.redhat.com [10.36.116.122]) by smtp.corp.redhat.com (Postfix) with ESMTP id EF14A5C207; Wed, 31 Jul 2019 20:42:08 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Wed, 31 Jul 2019 22:42:02 +0200 Message-Id: <20190731204203.10732-3-kwolf@redhat.com> In-Reply-To: <20190731204203.10732-1-kwolf@redhat.com> References: <20190731204203.10732-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Wed, 31 Jul 2019 20:42:10 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 2/3] iotests/118: Create test classes dynamically X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" We're getting a ridiculous number of child classes of TestInitiallyFilled and TestInitiallyEmpty that differ only in a few attributes that we want to test in all combinations. Instead of explicitly writing down every combination, let's use a loop and create those classes dynamically. Signed-off-by: Kevin Wolf Reviewed-by: Max Reitz --- tests/qemu-iotests/118 | 69 +++++++++++++----------------------------- 1 file changed, 21 insertions(+), 48 deletions(-) diff --git a/tests/qemu-iotests/118 b/tests/qemu-iotests/118 index 3c20d2d61f..c281259215 100755 --- a/tests/qemu-iotests/118 +++ b/tests/qemu-iotests/118 @@ -294,15 +294,15 @@ class GeneralChangeTestsBaseClass(ChangeBaseClass): class TestInitiallyFilled(GeneralChangeTestsBaseClass): was_empty =3D False =20 - def setUp(self, media, interface): + def setUp(self): qemu_img('create', '-f', iotests.imgfmt, old_img, '1440k') qemu_img('create', '-f', iotests.imgfmt, new_img, '1440k') self.vm =3D iotests.VM() - self.vm.add_drive(old_img, 'media=3D%s' % media, 'none') - if interface =3D=3D 'scsi': + self.vm.add_drive(old_img, 'media=3D%s' % self.media, 'none') + if self.interface =3D=3D 'scsi': self.vm.add_device('virtio-scsi-pci') self.vm.add_device('%s,drive=3Ddrive0,id=3D%s' % - (interface_to_device_name(interface), + (interface_to_device_name(self.interface), self.device_name)) self.vm.launch() =20 @@ -331,13 +331,13 @@ class TestInitiallyFilled(GeneralChangeTestsBaseClass= ): class TestInitiallyEmpty(GeneralChangeTestsBaseClass): was_empty =3D True =20 - def setUp(self, media, interface): + def setUp(self): qemu_img('create', '-f', iotests.imgfmt, new_img, '1440k') - self.vm =3D iotests.VM().add_drive(None, 'media=3D%s' % media, 'no= ne') - if interface =3D=3D 'scsi': + self.vm =3D iotests.VM().add_drive(None, 'media=3D%s' % self.media= , 'none') + if self.interface =3D=3D 'scsi': self.vm.add_device('virtio-scsi-pci') self.vm.add_device('%s,drive=3Ddrive0,id=3D%s' % - (interface_to_device_name(interface), + (interface_to_device_name(self.interface), self.device_name)) self.vm.launch() =20 @@ -355,50 +355,23 @@ class TestInitiallyEmpty(GeneralChangeTestsBaseClass): # Should be a no-op self.assert_qmp(result, 'return', {}) =20 -class TestCDInitiallyFilled(TestInitiallyFilled): - TestInitiallyFilled =3D TestInitiallyFilled - has_real_tray =3D True - - def setUp(self): - self.TestInitiallyFilled.setUp(self, 'cdrom', 'ide') - -class TestCDInitiallyEmpty(TestInitiallyEmpty): - TestInitiallyEmpty =3D TestInitiallyEmpty - has_real_tray =3D True - - def setUp(self): - self.TestInitiallyEmpty.setUp(self, 'cdrom', 'ide') +# Do this in a function to avoid leaking variables like case into the glob= al +# name space (otherwise tests would be run for the abstract base classes) +def create_basic_test_classes(): + for (media, interface, has_real_tray) in [ ('cdrom', 'ide', True), + ('cdrom', 'scsi', True), + ('disk', 'floppy', False) ]: =20 -class TestSCSICDInitiallyFilled(TestInitiallyFilled): - TestInitiallyFilled =3D TestInitiallyFilled - has_real_tray =3D True + for case in [ TestInitiallyFilled, TestInitiallyEmpty ]: =20 - def setUp(self): - self.TestInitiallyFilled.setUp(self, 'cdrom', 'scsi') + attr =3D { 'media': media, + 'interface': interface, + 'has_real_tray': has_real_tray } =20 -class TestSCSICDInitiallyEmpty(TestInitiallyEmpty): - TestInitiallyEmpty =3D TestInitiallyEmpty - has_real_tray =3D True + name =3D '%s_%s_%s' % (case.__name__, media, interface) + globals()[name] =3D type(name, (case, ), attr) =20 - def setUp(self): - self.TestInitiallyEmpty.setUp(self, 'cdrom', 'scsi') - -class TestFloppyInitiallyFilled(TestInitiallyFilled): - TestInitiallyFilled =3D TestInitiallyFilled - has_real_tray =3D False - - def setUp(self): - self.TestInitiallyFilled.setUp(self, 'disk', 'floppy') - -class TestFloppyInitiallyEmpty(TestInitiallyEmpty): - TestInitiallyEmpty =3D TestInitiallyEmpty - has_real_tray =3D False - - def setUp(self): - self.TestInitiallyEmpty.setUp(self, 'disk', 'floppy') - # FDDs not having a real tray and there not being a medium inside = the - # tray at startup means the tray will be considered open - self.has_opened =3D True +create_basic_test_classes() =20 class TestChangeReadOnly(ChangeBaseClass): device_name =3D 'qdev0' --=20 2.20.1 From nobody Sat May 4 00:47:44 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1564606532; cv=none; d=zoho.com; s=zohoarc; b=MKTyCP0A1p2jKND4WPVhuBpSwnvdzmPtT9+5q5RL/pxlKiOFhcpzs9nl/IsY50tLTHGpeE/ZwaicruKivP3/5c9c6Q9BarlJz62BW3sykcbde1bNFo2q0KOuWlQWnkBK7Jwmz/mwHMuU/nzHk/41uhUy4szm2gFkqlTph72ywUo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564606532; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=qV8njF11XonUKK5mZpveEx4VWJO6FwdOmEQGiGM53JY=; b=a3wdX85hgA33cfuhCCiLDDUdpoyE6N0RSz6v6190axJgOR8ZQLIJp7l/mun133pb6eOxT1F+vAeV2yoH46W7F9LOOaflYgz2ms/n7FJ7ilspvpwvvzuqyABcfu25U6goteQ4y8/BupRAnYS/X00pVgeJLxCFss1JE5iHSjRzv4I= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1564606532698376.23874274456057; Wed, 31 Jul 2019 13:55:32 -0700 (PDT) Received: from localhost ([::1]:44554 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvd9-0007Zv-Na for importer@patchew.org; Wed, 31 Jul 2019 16:55:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34073) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvQO-0003pJ-96 for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:42:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hsvQN-0005nT-1Z for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:42:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57136) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hsvQK-0005lg-1U; Wed, 31 Jul 2019 16:42:12 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5AFE17F7B5; Wed, 31 Jul 2019 20:42:11 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-122.ams2.redhat.com [10.36.116.122]) by smtp.corp.redhat.com (Postfix) with ESMTP id 518005C207; Wed, 31 Jul 2019 20:42:10 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Wed, 31 Jul 2019 22:42:03 +0200 Message-Id: <20190731204203.10732-4-kwolf@redhat.com> In-Reply-To: <20190731204203.10732-1-kwolf@redhat.com> References: <20190731204203.10732-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 31 Jul 2019 20:42:11 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 3/3] iotests/118: Add -blockdev based tests X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" The code path for -device drive=3D or without a drive=3D... option for empty drives, which is supposed to be used with -blockdev differs enough from the -drive based path with a user-owned BlockBackend, so we want to test both paths at least for the basic tests implemented by TestInitiallyFilled and TestInitiallyEmpty. This would have caught the bug recently fixed for inserting read-only nodes into a scsi-cd created without a drive=3D... option. Signed-off-by: Kevin Wolf Reviewed-by: Max Reitz --- tests/qemu-iotests/118 | 43 ++++++++++++++++++++++++++------------ tests/qemu-iotests/118.out | 4 ++-- 2 files changed, 32 insertions(+), 15 deletions(-) diff --git a/tests/qemu-iotests/118 b/tests/qemu-iotests/118 index c281259215..6f45779ee9 100755 --- a/tests/qemu-iotests/118 +++ b/tests/qemu-iotests/118 @@ -42,10 +42,14 @@ class ChangeBaseClass(iotests.QMPTestCase): has_opened =3D False has_closed =3D False =20 + device_name =3D 'qdev0' + use_drive =3D False + def process_events(self): for event in self.vm.get_qmp_events(wait=3DFalse): if (event['event'] =3D=3D 'DEVICE_TRAY_MOVED' and - event['data']['device'] =3D=3D 'drive0'): + (event['data']['device'] =3D=3D 'drive0' or + event['data']['id'] =3D=3D self.device_name)): if event['data']['tray-open'] =3D=3D False: self.has_closed =3D True else: @@ -69,9 +73,11 @@ class ChangeBaseClass(iotests.QMPTestCase): =20 class GeneralChangeTestsBaseClass(ChangeBaseClass): =20 - device_name =3D 'qdev0' - def test_change(self): + # 'change' requires a drive name, so skip the test for blockdev + if not self.use_drive: + return + result =3D self.vm.qmp('change', device=3D'drive0', target=3Dnew_i= mg, arg=3Diotests.imgfmt) self.assert_qmp(result, 'return', {}) @@ -298,7 +304,13 @@ class TestInitiallyFilled(GeneralChangeTestsBaseClass): qemu_img('create', '-f', iotests.imgfmt, old_img, '1440k') qemu_img('create', '-f', iotests.imgfmt, new_img, '1440k') self.vm =3D iotests.VM() - self.vm.add_drive(old_img, 'media=3D%s' % self.media, 'none') + if self.use_drive: + self.vm.add_drive(old_img, 'media=3D%s' % self.media, 'none') + else: + self.vm.add_blockdev([ 'node-name=3Ddrive0', + 'driver=3D%s' % iotests.imgfmt, + 'file.driver=3Dfile', + 'file.filename=3D%s' % old_img ]) if self.interface =3D=3D 'scsi': self.vm.add_device('virtio-scsi-pci') self.vm.add_device('%s,drive=3Ddrive0,id=3D%s' % @@ -333,11 +345,14 @@ class TestInitiallyEmpty(GeneralChangeTestsBaseClass): =20 def setUp(self): qemu_img('create', '-f', iotests.imgfmt, new_img, '1440k') - self.vm =3D iotests.VM().add_drive(None, 'media=3D%s' % self.media= , 'none') + self.vm =3D iotests.VM() + if self.use_drive: + self.vm.add_drive(None, 'media=3D%s' % self.media, 'none') if self.interface =3D=3D 'scsi': self.vm.add_device('virtio-scsi-pci') - self.vm.add_device('%s,drive=3Ddrive0,id=3D%s' % + self.vm.add_device('%s,%sid=3D%s' % (interface_to_device_name(self.interface), + 'drive=3Ddrive0,' if self.use_drive else '', self.device_name)) self.vm.launch() =20 @@ -363,13 +378,15 @@ def create_basic_test_classes(): ('disk', 'floppy', False) ]: =20 for case in [ TestInitiallyFilled, TestInitiallyEmpty ]: - - attr =3D { 'media': media, - 'interface': interface, - 'has_real_tray': has_real_tray } - - name =3D '%s_%s_%s' % (case.__name__, media, interface) - globals()[name] =3D type(name, (case, ), attr) + for use_drive in [ True, False ]: + attr =3D { 'media': media, + 'interface': interface, + 'has_real_tray': has_real_tray, + 'use_drive': use_drive } + + name =3D '%s_%s_%s_%s' % (case.__name__, media, interface, + 'drive' if use_drive else 'blockde= v') + globals()[name] =3D type(name, (case, ), attr) =20 create_basic_test_classes() =20 diff --git a/tests/qemu-iotests/118.out b/tests/qemu-iotests/118.out index b4ff997a8c..bf5bfd5aca 100644 --- a/tests/qemu-iotests/118.out +++ b/tests/qemu-iotests/118.out @@ -1,5 +1,5 @@ -..........................................................................= ............... +..........................................................................= ...........................................................................= .................. ---------------------------------------------------------------------- -Ran 89 tests +Ran 167 tests =20 OK --=20 2.20.1