From patchwork Mon Nov 5 16:37:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 10668769 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 00F8B14E2 for ; Mon, 5 Nov 2018 17:09:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DC72929C54 for ; Mon, 5 Nov 2018 17:09:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D052729C67; Mon, 5 Nov 2018 17:09:34 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, 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 1654F29C54 for ; Mon, 5 Nov 2018 17:09:33 +0000 (UTC) Received: from localhost ([::1]:36391 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gJiNY-0003bN-Vv for patchwork-qemu-devel@patchwork.kernel.org; Mon, 05 Nov 2018 12:09:33 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52075) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gJhwt-000381-9B for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:42:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gJhwn-000529-If for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:41:56 -0500 Received: from mx1.redhat.com ([209.132.183.28]:56228) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gJhwc-0005Rs-EU; Mon, 05 Nov 2018 11:41:44 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 564563001FD1; Mon, 5 Nov 2018 16:39:10 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-117-198.ams2.redhat.com [10.36.117.198]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4F5F760C5C; Mon, 5 Nov 2018 16:39:08 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Mon, 5 Nov 2018 17:37:37 +0100 Message-Id: <20181105163744.25139-30-kwolf@redhat.com> In-Reply-To: <20181105163744.25139-1-kwolf@redhat.com> References: <20181105163744.25139-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Mon, 05 Nov 2018 16:39:10 +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] [PULL 29/36] qemu-iotests: Test auto-read-only with -drive and -blockdev 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, peter.maydell@linaro.org, qemu-devel@nongnu.org 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: Kevin Wolf Reviewed-by: Eric Blake --- tests/qemu-iotests/232 | 147 +++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/232.out | 59 +++++++++++++++ tests/qemu-iotests/group | 1 + 3 files changed, 207 insertions(+) create mode 100755 tests/qemu-iotests/232 create mode 100644 tests/qemu-iotests/232.out diff --git a/tests/qemu-iotests/232 b/tests/qemu-iotests/232 new file mode 100755 index 0000000000..bc2972d124 --- /dev/null +++ b/tests/qemu-iotests/232 @@ -0,0 +1,147 @@ +#!/bin/bash +# +# Test for auto-read-only +# +# Copyright (C) 2018 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=kwolf@redhat.com + +seq=`basename $0` +echo "QA output created by $seq" + +here=`pwd` +status=1 # failure is the default! + +_cleanup() +{ + _cleanup_test_img + rm -f $TEST_IMG.snap +} +trap "_cleanup; exit \$status" 0 1 2 3 15 + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter + +_supported_fmt generic +_supported_proto file +_supported_os Linux + +function do_run_qemu() +{ + echo Testing: "$@" + ( + if ! test -t 0; then + while read cmd; do + echo $cmd + done + fi + echo quit + ) | $QEMU -nographic -monitor stdio -nodefaults "$@" + echo +} + +function run_qemu() +{ + do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qemu | _filter_hmp | + _filter_generated_node_ids | _filter_imgfmt +} + +function run_qemu_info_block() +{ + echo "info block -n" | run_qemu "$@" | grep -e "(file" -e "QEMU_PROG" +} + +size=128M + +_make_test_img $size + +echo +echo "=== -drive with read-write image: read-only/auto-read-only combinations ===" +echo + +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=on,auto-read-only=off +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=on,auto-read-only=on +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=on +echo +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=off,auto-read-only=off +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=off,auto-read-only=on +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=off +echo +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,auto-read-only=off +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,auto-read-only=on +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none + +echo +echo "=== -drive with read-only image: read-only/auto-read-only combinations ===" +echo + +chmod a-w $TEST_IMG + +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=on,auto-read-only=off +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=on,auto-read-only=on +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=on +echo +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=off,auto-read-only=off +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=off,auto-read-only=on +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=off +echo +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,auto-read-only=off +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,auto-read-only=on +run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none + +echo +echo "=== -blockdev with read-write image: read-only/auto-read-only combinations ===" +echo + +chmod a+w $TEST_IMG + +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=on,auto-read-only=off +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=on,auto-read-only=on +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=on +echo +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=off,auto-read-only=off +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=off,auto-read-only=on +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=off +echo +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,auto-read-only=off +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,auto-read-only=on +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0 + +echo +echo "=== -blockdev with read-only image: read-only/auto-read-only combinations ===" +echo + +chmod a-w $TEST_IMG + +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=on,auto-read-only=off +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=on,auto-read-only=on +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=on +echo +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=off,auto-read-only=off +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=off,auto-read-only=on +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=off +echo +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,auto-read-only=off +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,auto-read-only=on +run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0 + +# success, all done +echo "*** done" +rm -f $seq.full +status=0 diff --git a/tests/qemu-iotests/232.out b/tests/qemu-iotests/232.out new file mode 100644 index 0000000000..dcb683afa3 --- /dev/null +++ b/tests/qemu-iotests/232.out @@ -0,0 +1,59 @@ +QA output created by 232 +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 + +=== -drive with read-write image: read-only/auto-read-only combinations === + +NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only) +NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only) +NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only) + +NODE_NAME: TEST_DIR/t.IMGFMT (file) +NODE_NAME: TEST_DIR/t.IMGFMT (file) +NODE_NAME: TEST_DIR/t.IMGFMT (file) + +NODE_NAME: TEST_DIR/t.IMGFMT (file) +NODE_NAME: TEST_DIR/t.IMGFMT (file) +NODE_NAME: TEST_DIR/t.IMGFMT (file) + +=== -drive with read-only image: read-only/auto-read-only combinations === + +NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only) +NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only) +NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only) + +QEMU_PROG: -drive driver=file,file=TEST_DIR/t.IMGFMT,if=none,read-only=off,auto-read-only=off: Could not open 'TEST_DIR/t.IMGFMT': Permission denied +NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only) +NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only) + +QEMU_PROG: -drive driver=file,file=TEST_DIR/t.IMGFMT,if=none,auto-read-only=off: Could not open 'TEST_DIR/t.IMGFMT': Permission denied +NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only) +NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only) + +=== -blockdev with read-write image: read-only/auto-read-only combinations === + +node0: TEST_DIR/t.IMGFMT (file, read-only) +node0: TEST_DIR/t.IMGFMT (file, read-only) +node0: TEST_DIR/t.IMGFMT (file, read-only) + +node0: TEST_DIR/t.IMGFMT (file) +node0: TEST_DIR/t.IMGFMT (file) +node0: TEST_DIR/t.IMGFMT (file) + +node0: TEST_DIR/t.IMGFMT (file) +node0: TEST_DIR/t.IMGFMT (file) +node0: TEST_DIR/t.IMGFMT (file) + +=== -blockdev with read-only image: read-only/auto-read-only combinations === + +node0: TEST_DIR/t.IMGFMT (file, read-only) +node0: TEST_DIR/t.IMGFMT (file, read-only) +node0: TEST_DIR/t.IMGFMT (file, read-only) + +QEMU_PROG: -blockdev driver=file,filename=TEST_DIR/t.IMGFMT,node-name=node0,read-only=off,auto-read-only=off: Could not open 'TEST_DIR/t.IMGFMT': Permission denied +node0: TEST_DIR/t.IMGFMT (file, read-only) +QEMU_PROG: -blockdev driver=file,filename=TEST_DIR/t.IMGFMT,node-name=node0,read-only=off: Could not open 'TEST_DIR/t.IMGFMT': Permission denied + +QEMU_PROG: -blockdev driver=file,filename=TEST_DIR/t.IMGFMT,node-name=node0,auto-read-only=off: Could not open 'TEST_DIR/t.IMGFMT': Permission denied +node0: TEST_DIR/t.IMGFMT (file, read-only) +QEMU_PROG: -blockdev driver=file,filename=TEST_DIR/t.IMGFMT,node-name=node0: Could not open 'TEST_DIR/t.IMGFMT': Permission denied +*** done diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index 31f6e77dcb..ebe4fe78bc 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -227,3 +227,4 @@ 227 auto quick 229 auto quick 231 auto quick +232 auto quick