yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-qemu-iotests-Test-case-for-backing-file-deletion.patch

958e1b
From 6f81b4847eb68ebdf54a8f1a771e19d112d74152 Mon Sep 17 00:00:00 2001
958e1b
Message-Id: <6f81b4847eb68ebdf54a8f1a771e19d112d74152.1418766606.git.jen@redhat.com>
958e1b
From: Fam Zheng <famz@redhat.com>
958e1b
Date: Thu, 4 Dec 2014 00:04:55 -0600
958e1b
Subject: [CHANGE 01/31] qemu-iotests: Test case for backing file deletion
958e1b
To: rhvirt-patches@redhat.com,
958e1b
    jen@redhat.com
958e1b
958e1b
RH-Author: Fam Zheng <famz@redhat.com>
958e1b
Message-id: <1417651524-18041-2-git-send-email-famz@redhat.com>
958e1b
Patchwork-id: 62674
958e1b
O-Subject: [RHEL-7.1 qemu-kvm PATCH v5 01/30] qemu-iotests: Test case for backing file deletion
958e1b
Bugzilla: 1002493
958e1b
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
958e1b
RH-Acked-by: Markus Armbruster <armbru@redhat.com>
958e1b
RH-Acked-by: Max Reitz <mreitz@redhat.com>
958e1b
958e1b
From: Max Reitz <mreitz@redhat.com>
958e1b
958e1b
Add a test case for trying to open an image file where it is impossible
958e1b
to open its backing file (in this case, because it was deleted). When
958e1b
doing this, qemu (or qemu-io in this case) should not crash but rather
958e1b
print an appropriate error message.
958e1b
958e1b
Signed-off-by: Max Reitz <mreitz@redhat.com>
958e1b
Reviewed-by: Fam Zheng <famz@redhat.com>
958e1b
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
958e1b
(cherry picked from commit 321fd7d2b88defe11528e4d5a9f686c89ebee1ee)
958e1b
Signed-off-by: Fam Zheng <famz@redhat.com>
958e1b
Signed-off-by: Jeff E. Nelson <jen@redhat.com>
958e1b
958e1b
Conflicts:
958e1b
	tests/qemu-iotests/group
958e1b
Trivial context conflict.
958e1b
958e1b
Signed-off-by: Jeff E. Nelson <jen@redhat.com>
958e1b
---
958e1b
 tests/qemu-iotests/069     | 59 ++++++++++++++++++++++++++++++++++++++++++++++
958e1b
 tests/qemu-iotests/069.out |  8 +++++++
958e1b
 tests/qemu-iotests/group   |  1 +
958e1b
 3 files changed, 68 insertions(+)
958e1b
 create mode 100755 tests/qemu-iotests/069
958e1b
 create mode 100644 tests/qemu-iotests/069.out
958e1b
958e1b
diff --git a/tests/qemu-iotests/069 b/tests/qemu-iotests/069
958e1b
new file mode 100755
958e1b
index 0000000..3042803
958e1b
--- /dev/null
958e1b
+++ b/tests/qemu-iotests/069
958e1b
@@ -0,0 +1,59 @@
958e1b
+#!/bin/bash
958e1b
+#
958e1b
+# Test case for deleting a backing file
958e1b
+#
958e1b
+# Copyright (C) 2013 Red Hat, Inc.
958e1b
+#
958e1b
+# This program is free software; you can redistribute it and/or modify
958e1b
+# it under the terms of the GNU General Public License as published by
958e1b
+# the Free Software Foundation; either version 2 of the License, or
958e1b
+# (at your option) any later version.
958e1b
+#
958e1b
+# This program is distributed in the hope that it will be useful,
958e1b
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
958e1b
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
958e1b
+# GNU General Public License for more details.
958e1b
+#
958e1b
+# You should have received a copy of the GNU General Public License
958e1b
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
958e1b
+#
958e1b
+
958e1b
+# creator
958e1b
+owner=mreitz@redhat.com
958e1b
+
958e1b
+seq="$(basename $0)"
958e1b
+echo "QA output created by $seq"
958e1b
+
958e1b
+here="$PWD"
958e1b
+tmp=/tmp/$$
958e1b
+status=1	# failure is the default!
958e1b
+
958e1b
+_cleanup()
958e1b
+{
958e1b
+	_cleanup_test_img
958e1b
+}
958e1b
+trap "_cleanup; exit \$status" 0 1 2 3 15
958e1b
+
958e1b
+# get standard environment, filters and checks
958e1b
+. ./common.rc
958e1b
+. ./common.filter
958e1b
+
958e1b
+_supported_fmt cow qed qcow qcow2 vmdk
958e1b
+_supported_proto generic
958e1b
+_supported_os Linux
958e1b
+
958e1b
+IMG_SIZE=128K
958e1b
+
958e1b
+echo
958e1b
+echo "=== Creating an image with a backing file and deleting that file ==="
958e1b
+echo
958e1b
+TEST_IMG="$TEST_IMG.base" _make_test_img $IMG_SIZE
958e1b
+_make_test_img -b "$TEST_IMG.base" $IMG_SIZE
958e1b
+rm -f "$TEST_IMG.base"
958e1b
+# Just open the image and close it right again (this should print an error message)
958e1b
+$QEMU_IO -c quit "$TEST_IMG" 2>&1 | _filter_testdir | _filter_imgfmt
958e1b
+
958e1b
+# success, all done
958e1b
+echo "*** done"
958e1b
+rm -f $seq.full
958e1b
+status=0
958e1b
diff --git a/tests/qemu-iotests/069.out b/tests/qemu-iotests/069.out
958e1b
new file mode 100644
958e1b
index 0000000..3648814
958e1b
--- /dev/null
958e1b
+++ b/tests/qemu-iotests/069.out
958e1b
@@ -0,0 +1,8 @@
958e1b
+QA output created by 069
958e1b
+
958e1b
+=== Creating an image with a backing file and deleting that file ===
958e1b
+
958e1b
+Formatting 'TEST_DIR/t.IMGFMT.base', fmt=IMGFMT size=131072 
958e1b
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=131072 backing_file='TEST_DIR/t.IMGFMT.base' 
958e1b
+qemu-io: can't open device TEST_DIR/t.IMGFMT: Could not open file: No such file or directory
958e1b
+*** done
958e1b
diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
958e1b
index 3fad61d..572438e 100644
958e1b
--- a/tests/qemu-iotests/group
958e1b
+++ b/tests/qemu-iotests/group
958e1b
@@ -71,6 +71,7 @@
958e1b
 066 rw auto
958e1b
 067 rw auto
958e1b
 068 rw auto
958e1b
+069 rw auto
958e1b
 070 rw auto
958e1b
 075 rw auto
958e1b
 076 auto
958e1b
-- 
958e1b
2.1.0
958e1b