From patchwork Mon Jul 11 19:50:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: clord@redhat.com X-Patchwork-Id: 9224077 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id ABDE6604DB for ; Mon, 11 Jul 2016 19:54:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9D65127CCB for ; Mon, 11 Jul 2016 19:54:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 920D927E15; Mon, 11 Jul 2016 19:54:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 233D627CCB for ; Mon, 11 Jul 2016 19:54:29 +0000 (UTC) Received: from localhost ([::1]:35817 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bMhHf-00087o-Uq for patchwork-qemu-devel@patchwork.kernel.org; Mon, 11 Jul 2016 15:54:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56268) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bMhE6-0002MM-EJ for qemu-devel@nongnu.org; Mon, 11 Jul 2016 15:50:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bMhE5-00040f-8X for qemu-devel@nongnu.org; Mon, 11 Jul 2016 15:50:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55955) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bMhE1-0003zJ-JD; Mon, 11 Jul 2016 15:50:41 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2543585542; Mon, 11 Jul 2016 19:50:41 +0000 (UTC) Received: from dhcp-17-138.bos.redhat.com (dhcp-17-130.bos.redhat.com [10.18.17.130]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u6BJobLG008248; Mon, 11 Jul 2016 15:50:40 -0400 From: Colin Lord To: qemu-devel@nongnu.org Date: Mon, 11 Jul 2016 15:50:36 -0400 Message-Id: <1468266636-16861-4-git-send-email-clord@redhat.com> In-Reply-To: <1468266636-16861-1-git-send-email-clord@redhat.com> References: <1468266636-16861-1-git-send-email-clord@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 11 Jul 2016 19:50:41 +0000 (UTC) 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: Test format probes X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, Colin Lord , qemu-block@nongnu.org, mreitz@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Adds a new iotest for testing that the format probing functions work as expected. This is done by booting up a vm with a disk image without specifying the image format. Then the format is checked using a call to query-block. For any format specified, at least one check is done with an image of the given format, and one check is done against a raw image. This is to ensure that a probe correctly returns a high score when the format is matched, and does not return a high score when the format should not be matched, as would be the case with raw images. Signed-off-by: Colin Lord --- tests/qemu-iotests/158 | 53 +++++++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/158.out | 5 ++++ tests/qemu-iotests/group | 1 + tests/qemu-iotests/iotests.py | 5 ++++ 4 files changed, 64 insertions(+) create mode 100644 tests/qemu-iotests/158 create mode 100644 tests/qemu-iotests/158.out diff --git a/tests/qemu-iotests/158 b/tests/qemu-iotests/158 new file mode 100644 index 0000000..70ad298 --- /dev/null +++ b/tests/qemu-iotests/158 @@ -0,0 +1,53 @@ +#!/usr/bin/env python + +import iotests + +imgs = {'raw': ['grub_mbr.raw'], 'bochs': ['empty.bochs'], + 'cloop': ['simple-pattern.cloop'], + 'parallels': ['parallels-v1', 'parallels-v2'], + 'qcow': ['empty.qcow'], 'qcow2': ['empty.qcow2'], + 'qed': ['empty.qed'], 'vdi': ['empty.vdi'], + 'vpc': ['virtualpc-dynamic.vhd'], 'vhdx': ['iotest-dynamic-1G.vhdx'], + 'vmdk': ['iotest-version3.vmdk'], 'luks': ['empty.luks'], + 'dmg': ['empty.dmg']} + +class TestProbingFormats(iotests.QMPTestCase): + def setUp(self): + self.vm = iotests.VM() + self.img_paths = [] + luks_opts = '' + if iotests.imgfmt == 'luks': + luks_opts = (',key-secret=sec0') + for img_name in imgs[iotests.imgfmt]: + self.img_paths.append(iotests.use_sample_image(img_name)) + self.vm.add_drive_raw('file=%s,id=drive%s,media=cdrom%s' % + (self.img_paths[-1], len(self.img_paths) - 1, + luks_opts)) + if iotests.imgfmt == 'luks': + self.vm.use_luks() + if iotests.imgfmt != 'raw': + self.img_paths.append(iotests.use_sample_image(imgs['raw'][0])) + self.vm.add_drive_raw('file=%s,id=drive%s,media=cdrom' % + (self.img_paths[-1], len(self.img_paths) - 1)) + self.vm.launch() + + def tearDown(self): + self.vm.shutdown() + for img in self.img_paths: + iotests.rm_test_image(img) + + def test_probe_detects_format(self): + result = self.vm.qmp('query-block') + for i in range(len(self.img_paths) - 1): + self.assert_qmp(result, 'return[%s]/inserted/image/format' % + i, iotests.imgfmt) + + def test_probe_detects_raw(self): + result = self.vm.qmp('query-block') + self.assert_qmp(result, 'return[%s]/inserted/image/format' % + (len(self.img_paths) - 1), 'raw') + +if __name__ == '__main__': + iotests.main(supported_fmts=['raw', 'bochs', 'cloop', 'parallels', 'qcow', + 'qcow2', 'qed', 'vdi', 'vpc', 'vhdx', 'vmdk', + 'luks', 'dmg']) diff --git a/tests/qemu-iotests/158.out b/tests/qemu-iotests/158.out new file mode 100644 index 0000000..fbc63e6 --- /dev/null +++ b/tests/qemu-iotests/158.out @@ -0,0 +1,5 @@ +.. +---------------------------------------------------------------------- +Ran 2 tests + +OK diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index 1c6fcb6..4563e81 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -156,3 +156,4 @@ 154 rw auto backing quick 155 rw auto 156 rw auto quick +158 quick diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 3ba0de2..101ae91 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -49,6 +49,7 @@ if os.environ.get('QEMU_OPTIONS'): imgfmt = os.environ.get('IMGFMT', 'raw') imgproto = os.environ.get('IMGPROTO', 'file') test_dir = os.environ.get('TEST_DIR') +imgkeysecret = os.environ.get('IMGKEYSECRET') output_dir = os.environ.get('OUTPUT_DIR', '.') cachemode = os.environ.get('CACHEMODE') qemu_default_machine = os.environ.get('QEMU_DEFAULT_MACHINE') @@ -208,6 +209,10 @@ class VM(object): self._num_drives += 1 return self + def use_luks(self): + self._args.append('-object') + self._args.append('secret,id=sec0,data=%s' % imgkeysecret) + def pause_drive(self, drive, event=None): '''Pause drive r/w operations''' if not event: