From patchwork Mon Aug 15 13:29:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 9280963 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 3B94A60467 for ; Mon, 15 Aug 2016 13:34:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2D4D828C95 for ; Mon, 15 Aug 2016 13:34:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2213D28C97; Mon, 15 Aug 2016 13:34:09 +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 17E7B28C95 for ; Mon, 15 Aug 2016 13:34:07 +0000 (UTC) Received: from localhost ([::1]:37033 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bZI1m-0005wE-6t for patchwork-qemu-devel@patchwork.kernel.org; Mon, 15 Aug 2016 09:34:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53906) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bZHxm-00032A-JV for qemu-devel@nongnu.org; Mon, 15 Aug 2016 09:30:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bZHxe-0007Hf-H0 for qemu-devel@nongnu.org; Mon, 15 Aug 2016 09:29:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51528) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bZHxX-0007Fu-46; Mon, 15 Aug 2016 09:29:43 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (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 B869AC04D2EF; Mon, 15 Aug 2016 13:29:42 +0000 (UTC) Received: from localhost (ovpn-116-127.phx2.redhat.com [10.3.116.127]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u7FDTfcC004521 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 15 Aug 2016 09:29:42 -0400 From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 15 Aug 2016 15:29:27 +0200 Message-Id: <20160815132927.2502-6-mreitz@redhat.com> In-Reply-To: <20160815132927.2502-1-mreitz@redhat.com> References: <20160815132927.2502-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 15 Aug 2016 13:29:42 +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 for-2.7? v3 5/5] iotests: Test case for wrong runtime option types 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: Kevin Wolf , Jeff Cody , qemu-devel@nongnu.org, "Richard W . M . Jones" , Paolo Bonzini , Max Reitz Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Max Reitz Reviewed-by: Kevin Wolf Reviewed-by: Jeff Cody --- tests/qemu-iotests/162 | 96 ++++++++++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/162.out | 17 ++++++++ tests/qemu-iotests/group | 1 + 3 files changed, 114 insertions(+) create mode 100755 tests/qemu-iotests/162 create mode 100644 tests/qemu-iotests/162.out diff --git a/tests/qemu-iotests/162 b/tests/qemu-iotests/162 new file mode 100755 index 0000000..0b43ea3 --- /dev/null +++ b/tests/qemu-iotests/162 @@ -0,0 +1,96 @@ +#!/bin/bash +# +# Test case for specifying runtime options of the wrong type to some +# block drivers +# +# Copyright (C) 2016 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +# creator +owner=mreitz@redhat.com + +seq="$(basename $0)" +echo "QA output created by $seq" + +here="$PWD" +status=1 # failure is the default! + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter + +_supported_fmt generic +_supported_os Linux + +echo +echo '=== NBD ===' +# NBD expects all of its arguments to be strings + +# So this should not crash +$QEMU_IMG info 'json:{"driver": "nbd", "host": 42}' + +# And this should not treat @port as if it had not been specified +# (We cannot use localhost with an invalid port here, but we need to use a +# non-existing domain, because otherwise the error message will not contain +# the port) +$QEMU_IMG info 'json:{"driver": "nbd", "host": "does.not.exist.example.com", "port": 42}' + +# This is a test for NBD's bdrv_refresh_filename() implementation: It expects +# either host or path to be set, but it must not assume that they are set to +# strings in the options QDict +$QEMU_NBD -k "$PWD/42" -f raw null-co:// & +sleep 0.5 +$QEMU_IMG info 'json:{"driver": "nbd", "path": 42}' | grep '^image' +rm -f 42 + + +echo +echo '=== SSH ===' +# SSH expects all of its arguments to be strings, except for @port, which is +# expected to be an integer + +# So "0" should be converted to an integer here (instead of crashing) +$QEMU_IMG info 'json:{"driver": "ssh", "host": "localhost", "port": "0", "path": "/foo"}' +# The same, basically (all values for --image-opts are seen as strings in qemu) +$QEMU_IMG info --image-opts \ + driver=ssh,host=localhost,port=0,path=/foo + +# This, however, should fail because of the wrong type +$QEMU_IMG info 'json:{"driver": "ssh", "host": "localhost", "port": 0.42, "path": "/foo"}' +# Not really the same: Here, "0.42" will be passed instead of 0.42, but still, +# qemu should not try to convert "0.42" to an integer +$QEMU_IMG info --image-opts \ + driver=ssh,host=localhost,port=0.42,path=/foo + + +echo +echo '=== blkdebug ===' +# blkdebug expects all of its arguments to be strings, but its +# bdrv_refresh_filename() implementation should not assume that they have been +# passed as strings in the original options QDict. +# So this should emit blkdebug:42:null-co:// as the filename: +touch 42 +$QEMU_IMG info 'json:{"driver": "blkdebug", "config": 42, + "image.driver": "null-co"}' \ + | grep '^image' +rm -f 42 + + +# success, all done +echo +echo '*** done' +rm -f $seq.full +status=0 diff --git a/tests/qemu-iotests/162.out b/tests/qemu-iotests/162.out new file mode 100644 index 0000000..9bba723 --- /dev/null +++ b/tests/qemu-iotests/162.out @@ -0,0 +1,17 @@ +QA output created by 162 + +=== NBD === +qemu-img: Could not open 'json:{"driver": "nbd", "host": 42}': Failed to connect socket: Invalid argument +qemu-img: Could not open 'json:{"driver": "nbd", "host": "does.not.exist.example.com", "port": 42}': address resolution failed for does.not.exist.example.com:42: Name or service not known +image: nbd+unix://?socket=42 + +=== SSH === +qemu-img: Could not open 'json:{"driver": "ssh", "host": "localhost", "port": "0", "path": "/foo"}': Failed to connect socket: Connection refused +qemu-img: Could not open 'driver=ssh,host=localhost,port=0,path=/foo': Failed to connect socket: Connection refused +qemu-img: Could not open 'json:{"driver": "ssh", "host": "localhost", "port": 0.42, "path": "/foo"}': Parameter 'port' expects a number +qemu-img: Could not open 'driver=ssh,host=localhost,port=0.42,path=/foo': Parameter 'port' expects a number + +=== blkdebug === +image: blkdebug:42:null-co:// + +*** done diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index 3a3973e..50ddeed 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -157,3 +157,4 @@ 155 rw auto 156 rw auto quick 157 auto +162 auto quick