Blame SOURCES/kvm-iotests-Add-test-221-to-catch-qemu-img-map-regressio.patch

ae23c9
From 8e5660a0047bcefbab18d5996acb4da2a1c298ae Mon Sep 17 00:00:00 2001
ae23c9
From: Max Reitz <mreitz@redhat.com>
ae23c9
Date: Mon, 15 Oct 2018 17:44:46 +0100
ae23c9
Subject: [PATCH 49/49] iotests: Add test 221 to catch qemu-img map regression
ae23c9
ae23c9
RH-Author: Max Reitz <mreitz@redhat.com>
ae23c9
Message-id: <20181015174446.31974-3-mreitz@redhat.com>
ae23c9
Patchwork-id: 82707
ae23c9
O-Subject: [RHEL-8 qemu-kvm PATCH v2 2/2] iotests: Add test 221 to catch qemu-img map regression
ae23c9
Bugzilla: 1639374
ae23c9
RH-Acked-by: John Snow <jsnow@redhat.com>
ae23c9
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
ae23c9
RH-Acked-by: Thomas Huth <thuth@redhat.com>
ae23c9
ae23c9
From: Eric Blake <eblake@redhat.com>
ae23c9
ae23c9
Although qemu-img creates aligned files (by rounding up), it
ae23c9
must also gracefully handle files that are not sector-aligned.
ae23c9
Test that the bug fixed in the previous patch does not recur.
ae23c9
ae23c9
It's a bit annoying that we can see the (implicit) hole past
ae23c9
the end of the file on to the next sector boundary, so if we
ae23c9
ever reach the point where we report a byte-accurate size rather
ae23c9
than our current behavior of always rounding up, this test will
ae23c9
probably need a slight modification.
ae23c9
ae23c9
Signed-off-by: Eric Blake <eblake@redhat.com>
ae23c9
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
ae23c9
(cherry picked from commit c6a9d2f6f9bc0c163b3a3073126464a2446bad5f)
ae23c9
Signed-off-by: Max Reitz <mreitz@redhat.com>
ae23c9
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
ae23c9
---
ae23c9
 tests/qemu-iotests/221     | 60 ++++++++++++++++++++++++++++++++++++++++++++++
ae23c9
 tests/qemu-iotests/221.out | 16 +++++++++++++
ae23c9
 tests/qemu-iotests/group   |  1 +
ae23c9
 3 files changed, 77 insertions(+)
ae23c9
 create mode 100755 tests/qemu-iotests/221
ae23c9
 create mode 100644 tests/qemu-iotests/221.out
ae23c9
ae23c9
diff --git a/tests/qemu-iotests/221 b/tests/qemu-iotests/221
ae23c9
new file mode 100755
ae23c9
index 0000000..41c4e4b
ae23c9
--- /dev/null
ae23c9
+++ b/tests/qemu-iotests/221
ae23c9
@@ -0,0 +1,60 @@
ae23c9
+#!/bin/bash
ae23c9
+#
ae23c9
+# Test qemu-img vs. unaligned images
ae23c9
+#
ae23c9
+# Copyright (C) 2018 Red Hat, Inc.
ae23c9
+#
ae23c9
+# This program is free software; you can redistribute it and/or modify
ae23c9
+# it under the terms of the GNU General Public License as published by
ae23c9
+# the Free Software Foundation; either version 2 of the License, or
ae23c9
+# (at your option) any later version.
ae23c9
+#
ae23c9
+# This program is distributed in the hope that it will be useful,
ae23c9
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
ae23c9
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
ae23c9
+# GNU General Public License for more details.
ae23c9
+#
ae23c9
+# You should have received a copy of the GNU General Public License
ae23c9
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
ae23c9
+#
ae23c9
+
ae23c9
+seq="$(basename $0)"
ae23c9
+echo "QA output created by $seq"
ae23c9
+
ae23c9
+here="$PWD"
ae23c9
+status=1 # failure is the default!
ae23c9
+
ae23c9
+_cleanup()
ae23c9
+{
ae23c9
+    _cleanup_test_img
ae23c9
+}
ae23c9
+trap "_cleanup; exit \$status" 0 1 2 3 15
ae23c9
+
ae23c9
+# get standard environment, filters and checks
ae23c9
+. ./common.rc
ae23c9
+. ./common.filter
ae23c9
+
ae23c9
+_supported_fmt raw
ae23c9
+_supported_proto file
ae23c9
+_supported_os Linux
ae23c9
+
ae23c9
+echo
ae23c9
+echo "=== Check mapping of unaligned raw image ==="
ae23c9
+echo
ae23c9
+
ae23c9
+_make_test_img 43009 # qemu-img create rounds size up
ae23c9
+$QEMU_IMG map --output=json "$TEST_IMG" | _filter_qemu_img_map
ae23c9
+
ae23c9
+truncate --size=43009 "$TEST_IMG" # so we resize it and check again
ae23c9
+$QEMU_IMG map --output=json "$TEST_IMG" | _filter_qemu_img_map
ae23c9
+
ae23c9
+$QEMU_IO -c 'w 43008 1' "$TEST_IMG" | _filter_qemu_io # writing also rounds up
ae23c9
+$QEMU_IMG map --output=json "$TEST_IMG" | _filter_qemu_img_map
ae23c9
+
ae23c9
+truncate --size=43009 "$TEST_IMG" # so we resize it and check again
ae23c9
+$QEMU_IMG map --output=json "$TEST_IMG" | _filter_qemu_img_map
ae23c9
+
ae23c9
+# success, all done
ae23c9
+echo '*** done'
ae23c9
+rm -f $seq.full
ae23c9
+status=0
ae23c9
diff --git a/tests/qemu-iotests/221.out b/tests/qemu-iotests/221.out
ae23c9
new file mode 100644
ae23c9
index 0000000..a9c0190
ae23c9
--- /dev/null
ae23c9
+++ b/tests/qemu-iotests/221.out
ae23c9
@@ -0,0 +1,16 @@
ae23c9
+QA output created by 221
ae23c9
+
ae23c9
+=== Check mapping of unaligned raw image ===
ae23c9
+
ae23c9
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=43009
ae23c9
+[{ "start": 0, "length": 43520, "depth": 0, "zero": true, "data": false, "offset": OFFSET}]
ae23c9
+[{ "start": 0, "length": 43520, "depth": 0, "zero": true, "data": false, "offset": OFFSET}]
ae23c9
+wrote 1/1 bytes at offset 43008
ae23c9
+1 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
ae23c9
+[{ "start": 0, "length": 40960, "depth": 0, "zero": true, "data": false, "offset": OFFSET},
ae23c9
+{ "start": 40960, "length": 2049, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
ae23c9
+{ "start": 43009, "length": 511, "depth": 0, "zero": true, "data": false, "offset": OFFSET}]
ae23c9
+[{ "start": 0, "length": 40960, "depth": 0, "zero": true, "data": false, "offset": OFFSET},
ae23c9
+{ "start": 40960, "length": 2049, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
ae23c9
+{ "start": 43009, "length": 511, "depth": 0, "zero": true, "data": false, "offset": OFFSET}]
ae23c9
+*** done
ae23c9
diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
ae23c9
index 0242b2f..1cb2ccb 100644
ae23c9
--- a/tests/qemu-iotests/group
ae23c9
+++ b/tests/qemu-iotests/group
ae23c9
@@ -218,6 +218,7 @@
ae23c9
 217 rw auto quick
ae23c9
 218 rw auto quick
ae23c9
 219 rw auto
ae23c9
+221 rw auto quick
ae23c9
 222 rw auto quick
ae23c9
 223 rw auto quick
ae23c9
 226 auto quick
ae23c9
-- 
ae23c9
1.8.3.1
ae23c9