thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

Blame SOURCES/kvm-qemu-iotests-Test-auto-read-only-with-drive-and-bloc.patch

26ba25
From 72289af7eb92b390e00872e8c981e9dd8ebe70fe Mon Sep 17 00:00:00 2001
26ba25
From: Kevin Wolf <kwolf@redhat.com>
26ba25
Date: Thu, 10 Jan 2019 12:44:41 +0000
26ba25
Subject: [PATCH 11/14] qemu-iotests: Test auto-read-only with -drive and
26ba25
 -blockdev
26ba25
26ba25
RH-Author: Kevin Wolf <kwolf@redhat.com>
26ba25
Message-id: <20190110124442.30132-12-kwolf@redhat.com>
26ba25
Patchwork-id: 83961
26ba25
O-Subject: [RHEL-8.0 qemu-kvm PATCH 11/12] qemu-iotests: Test auto-read-only with -drive and -blockdev
26ba25
Bugzilla: 1644996
26ba25
RH-Acked-by: Max Reitz <mreitz@redhat.com>
26ba25
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
26ba25
RH-Acked-by: Eric Blake <eblake@redhat.com>
26ba25
26ba25
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
26ba25
Reviewed-by: Eric Blake <eblake@redhat.com>
26ba25
(cherry picked from commit 36f808fa15f85a894c2f6cce9df46d27e8f0f129)
26ba25
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
26ba25
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
26ba25
---
26ba25
 tests/qemu-iotests/232     | 147 +++++++++++++++++++++++++++++++++++++++++++++
26ba25
 tests/qemu-iotests/232.out |  59 ++++++++++++++++++
26ba25
 tests/qemu-iotests/group   |   1 +
26ba25
 3 files changed, 207 insertions(+)
26ba25
 create mode 100755 tests/qemu-iotests/232
26ba25
 create mode 100644 tests/qemu-iotests/232.out
26ba25
26ba25
diff --git a/tests/qemu-iotests/232 b/tests/qemu-iotests/232
26ba25
new file mode 100755
26ba25
index 0000000..bc2972d
26ba25
--- /dev/null
26ba25
+++ b/tests/qemu-iotests/232
26ba25
@@ -0,0 +1,147 @@
26ba25
+#!/bin/bash
26ba25
+#
26ba25
+# Test for auto-read-only
26ba25
+#
26ba25
+# Copyright (C) 2018 Red Hat, Inc.
26ba25
+#
26ba25
+# This program is free software; you can redistribute it and/or modify
26ba25
+# it under the terms of the GNU General Public License as published by
26ba25
+# the Free Software Foundation; either version 2 of the License, or
26ba25
+# (at your option) any later version.
26ba25
+#
26ba25
+# This program is distributed in the hope that it will be useful,
26ba25
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
26ba25
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
26ba25
+# GNU General Public License for more details.
26ba25
+#
26ba25
+# You should have received a copy of the GNU General Public License
26ba25
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
26ba25
+#
26ba25
+
26ba25
+# creator
26ba25
+owner=kwolf@redhat.com
26ba25
+
26ba25
+seq=`basename $0`
26ba25
+echo "QA output created by $seq"
26ba25
+
26ba25
+here=`pwd`
26ba25
+status=1	# failure is the default!
26ba25
+
26ba25
+_cleanup()
26ba25
+{
26ba25
+    _cleanup_test_img
26ba25
+    rm -f $TEST_IMG.snap
26ba25
+}
26ba25
+trap "_cleanup; exit \$status" 0 1 2 3 15
26ba25
+
26ba25
+# get standard environment, filters and checks
26ba25
+. ./common.rc
26ba25
+. ./common.filter
26ba25
+
26ba25
+_supported_fmt generic
26ba25
+_supported_proto file
26ba25
+_supported_os Linux
26ba25
+
26ba25
+function do_run_qemu()
26ba25
+{
26ba25
+    echo Testing: "$@"
26ba25
+    (
26ba25
+        if ! test -t 0; then
26ba25
+            while read cmd; do
26ba25
+                echo $cmd
26ba25
+            done
26ba25
+        fi
26ba25
+        echo quit
26ba25
+    ) | $QEMU -nographic -monitor stdio -nodefaults "$@"
26ba25
+    echo
26ba25
+}
26ba25
+
26ba25
+function run_qemu()
26ba25
+{
26ba25
+    do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qemu | _filter_hmp |
26ba25
+        _filter_generated_node_ids | _filter_imgfmt
26ba25
+}
26ba25
+
26ba25
+function run_qemu_info_block()
26ba25
+{
26ba25
+    echo "info block -n" | run_qemu "$@" | grep -e "(file" -e "QEMU_PROG"
26ba25
+}
26ba25
+
26ba25
+size=128M
26ba25
+
26ba25
+_make_test_img $size
26ba25
+
26ba25
+echo
26ba25
+echo "=== -drive with read-write image: read-only/auto-read-only combinations ==="
26ba25
+echo
26ba25
+
26ba25
+run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=on,auto-read-only=off
26ba25
+run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=on,auto-read-only=on
26ba25
+run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=on
26ba25
+echo
26ba25
+run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=off,auto-read-only=off
26ba25
+run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=off,auto-read-only=on
26ba25
+run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=off
26ba25
+echo
26ba25
+run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,auto-read-only=off
26ba25
+run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,auto-read-only=on
26ba25
+run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none
26ba25
+
26ba25
+echo
26ba25
+echo "=== -drive with read-only image: read-only/auto-read-only combinations ==="
26ba25
+echo
26ba25
+
26ba25
+chmod a-w $TEST_IMG
26ba25
+
26ba25
+run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=on,auto-read-only=off
26ba25
+run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=on,auto-read-only=on
26ba25
+run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=on
26ba25
+echo
26ba25
+run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=off,auto-read-only=off
26ba25
+run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=off,auto-read-only=on
26ba25
+run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=off
26ba25
+echo
26ba25
+run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,auto-read-only=off
26ba25
+run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,auto-read-only=on
26ba25
+run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none
26ba25
+
26ba25
+echo
26ba25
+echo "=== -blockdev with read-write image: read-only/auto-read-only combinations ==="
26ba25
+echo
26ba25
+
26ba25
+chmod a+w $TEST_IMG
26ba25
+
26ba25
+run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=on,auto-read-only=off
26ba25
+run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=on,auto-read-only=on
26ba25
+run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=on
26ba25
+echo
26ba25
+run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=off,auto-read-only=off
26ba25
+run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=off,auto-read-only=on
26ba25
+run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=off
26ba25
+echo
26ba25
+run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,auto-read-only=off
26ba25
+run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,auto-read-only=on
26ba25
+run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0
26ba25
+
26ba25
+echo
26ba25
+echo "=== -blockdev with read-only image: read-only/auto-read-only combinations ==="
26ba25
+echo
26ba25
+
26ba25
+chmod a-w $TEST_IMG
26ba25
+
26ba25
+run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=on,auto-read-only=off
26ba25
+run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=on,auto-read-only=on
26ba25
+run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=on
26ba25
+echo
26ba25
+run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=off,auto-read-only=off
26ba25
+run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=off,auto-read-only=on
26ba25
+run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=off
26ba25
+echo
26ba25
+run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,auto-read-only=off
26ba25
+run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,auto-read-only=on
26ba25
+run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0
26ba25
+
26ba25
+# success, all done
26ba25
+echo "*** done"
26ba25
+rm -f $seq.full
26ba25
+status=0
26ba25
diff --git a/tests/qemu-iotests/232.out b/tests/qemu-iotests/232.out
26ba25
new file mode 100644
26ba25
index 0000000..dcb683a
26ba25
--- /dev/null
26ba25
+++ b/tests/qemu-iotests/232.out
26ba25
@@ -0,0 +1,59 @@
26ba25
+QA output created by 232
26ba25
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
26ba25
+
26ba25
+=== -drive with read-write image: read-only/auto-read-only combinations ===
26ba25
+
26ba25
+NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only)
26ba25
+NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only)
26ba25
+NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only)
26ba25
+
26ba25
+NODE_NAME: TEST_DIR/t.IMGFMT (file)
26ba25
+NODE_NAME: TEST_DIR/t.IMGFMT (file)
26ba25
+NODE_NAME: TEST_DIR/t.IMGFMT (file)
26ba25
+
26ba25
+NODE_NAME: TEST_DIR/t.IMGFMT (file)
26ba25
+NODE_NAME: TEST_DIR/t.IMGFMT (file)
26ba25
+NODE_NAME: TEST_DIR/t.IMGFMT (file)
26ba25
+
26ba25
+=== -drive with read-only image: read-only/auto-read-only combinations ===
26ba25
+
26ba25
+NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only)
26ba25
+NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only)
26ba25
+NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only)
26ba25
+
26ba25
+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
26ba25
+NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only)
26ba25
+NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only)
26ba25
+
26ba25
+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
26ba25
+NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only)
26ba25
+NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only)
26ba25
+
26ba25
+=== -blockdev with read-write image: read-only/auto-read-only combinations ===
26ba25
+
26ba25
+node0: TEST_DIR/t.IMGFMT (file, read-only)
26ba25
+node0: TEST_DIR/t.IMGFMT (file, read-only)
26ba25
+node0: TEST_DIR/t.IMGFMT (file, read-only)
26ba25
+
26ba25
+node0: TEST_DIR/t.IMGFMT (file)
26ba25
+node0: TEST_DIR/t.IMGFMT (file)
26ba25
+node0: TEST_DIR/t.IMGFMT (file)
26ba25
+
26ba25
+node0: TEST_DIR/t.IMGFMT (file)
26ba25
+node0: TEST_DIR/t.IMGFMT (file)
26ba25
+node0: TEST_DIR/t.IMGFMT (file)
26ba25
+
26ba25
+=== -blockdev with read-only image: read-only/auto-read-only combinations ===
26ba25
+
26ba25
+node0: TEST_DIR/t.IMGFMT (file, read-only)
26ba25
+node0: TEST_DIR/t.IMGFMT (file, read-only)
26ba25
+node0: TEST_DIR/t.IMGFMT (file, read-only)
26ba25
+
26ba25
+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
26ba25
+node0: TEST_DIR/t.IMGFMT (file, read-only)
26ba25
+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
26ba25
+
26ba25
+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
26ba25
+node0: TEST_DIR/t.IMGFMT (file, read-only)
26ba25
+QEMU_PROG: -blockdev driver=file,filename=TEST_DIR/t.IMGFMT,node-name=node0: Could not open 'TEST_DIR/t.IMGFMT': Permission denied
26ba25
+*** done
26ba25
diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
26ba25
index b30689e..61c0f9c 100644
26ba25
--- a/tests/qemu-iotests/group
26ba25
+++ b/tests/qemu-iotests/group
26ba25
@@ -224,4 +224,5 @@
26ba25
 226 auto quick
26ba25
 229 auto quick
26ba25
 231 auto quick
26ba25
+232 auto quick
26ba25
 234 auto quick migration
26ba25
-- 
26ba25
1.8.3.1
26ba25