]> git.proxmox.com Git - mirror_qemu.git/blobdiff - tests/qemu-iotests/019
iotests: Improve image-clear tests on non-aligned image
[mirror_qemu.git] / tests / qemu-iotests / 019
index 3f858dc1ef425026f88e8abde4e222f1a4655305..24a789a25c0dfda02f4c4a96a8f309064554d6df 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 #
 # When using a backing file for the output image in qemu-img convert,
 # the backing file clusters must not copied. The data must still be
@@ -17,9 +17,7 @@
 # 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, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
-# USA
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 
 # creator
@@ -29,14 +27,13 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
 status=1       # failure is the default!
 
 _cleanup()
 {
        _cleanup_test_img
-    rm -f $TEST_IMG.base
-    rm -f $TEST_IMG.orig
+    rm -f "$TEST_IMG.base"
+    rm -f "$TEST_IMG.orig"
 }
 trap "_cleanup; exit \$status" 0 1 2 3 15
 
@@ -46,10 +43,18 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 . ./common.pattern
 
 # Any format supporting backing files
-_supported_fmt qcow qcow2 vmdk
+_supported_fmt qcow qcow2 vmdk qed
+_supported_proto file
 _supported_os Linux
+_unsupported_imgopts "subformat=monolithicFlat" \
+                     "subformat=twoGbMaxExtentFlat" \
+                     "subformat=twoGbMaxExtentSparse"
 
 TEST_OFFSETS="0 4294967296"
+CLUSTER_SIZE=65536
+
+TEST_IMG_SAVE="$TEST_IMG"
+TEST_IMG="$TEST_IMG.base"
 
 _make_test_img 6G
 
@@ -58,57 +63,68 @@ echo
 
 for offset in $TEST_OFFSETS; do
     # Some clusters with alternating backing file/image file reads
-    io writev $(( offset )) 512 1024 64
+    io_pattern writev $(( offset )) 512 1024 64 42
 
     # Complete backing clusters
-    io writev $(( offset  + 1024 * 1024))  65536 65536 1
+    io_pattern writev $(( offset  + 1024 * 1024))  $CLUSTER_SIZE $CLUSTER_SIZE 1 42
 done
 _check_test_img
 
 echo "Creating test image with backing file"
 echo
 
-mv $TEST_IMG $TEST_IMG.base
-_make_test_img -b $TEST_IMG.base 6G
+TEST_IMG="$TEST_IMG_SAVE.orig"
+_make_test_img -b "$TEST_IMG_SAVE.base" 6G
 
 echo "Filling test image"
 echo
 
 for offset in $TEST_OFFSETS; do
     # Some clusters with alternating backing file/image file reads
-    io writev $(( offset + 512 )) 512 1024 64
+    io_pattern writev $(( offset + 512 )) 512 1024 64 43
 
     # Complete test image clusters
-    io writev $(( offset + 1024 * 1024 + 65536))  65536 65536 1
+    io_pattern writev $(( offset + 1024 * 1024 + $CLUSTER_SIZE))  $CLUSTER_SIZE $CLUSTER_SIZE 1 43
 done
 _check_test_img
 
-mv $TEST_IMG $TEST_IMG.orig
-$QEMU_IMG convert -O $IMGFMT -B $TEST_IMG.base $TEST_IMG.orig $TEST_IMG
+TEST_IMG="$TEST_IMG_SAVE"
 
-echo "Checking if backing clusters are allocated when they shouldn't"
-echo
-for offset in $TEST_OFFSETS; do
-    # Complete backing clusters
-    is_allocated $(( offset  + 1024 * 1024))  65536 65536 1
-done
+# Test the conversion twice: One test with the old-style -B option and another
+# one with -o backing_file
 
-echo "Reading"
-echo
+for backing_option in "-B " "-o backing_file="; do
 
-for offset in $TEST_OFFSETS; do
-    # Some clusters with alternating backing file/image file reads
-    io readv $(( offset )) 512 1024 64
-    io readv $(( offset + 512 )) 512 1024 64
+    echo
+    echo Testing conversion with $backing_option"$TEST_IMG.base" | _filter_testdir | _filter_imgfmt
+    echo
+    $QEMU_IMG convert -f $IMGFMT -O $IMGFMT $backing_option"$TEST_IMG.base" "$TEST_IMG.orig" "$TEST_IMG"
 
-    # Complete test image clusters
-    io readv $(( offset  + 1024 * 1024))  65536 65536 1
-    io readv $(( offset + 1024 * 1024 + 65536))  65536 65536 1
+    echo "Checking if backing clusters are allocated when they shouldn't"
+    echo
+    for offset in $TEST_OFFSETS; do
+        # Complete backing clusters
+        is_allocated $(( offset  + 1024 * 1024))  $CLUSTER_SIZE $CLUSTER_SIZE 1
+    done
+
+    echo "Reading"
+    echo
+
+    for offset in $TEST_OFFSETS; do
+        # Some clusters with alternating backing file/image file reads
+        io_pattern readv $(( offset )) 512 1024 64 42
+        io_pattern readv $(( offset + 512 )) 512 1024 64 43
+
+        # Complete test image clusters
+        io_pattern readv $(( offset  + 1024 * 1024))  $CLUSTER_SIZE $CLUSTER_SIZE 1 42
+        io_pattern readv $(( offset + 1024 * 1024 + $CLUSTER_SIZE))  $CLUSTER_SIZE $CLUSTER_SIZE 1 43
+
+        # Empty sectors
+        io_zero readv $(( offset + 1024 * 1024 + $CLUSTER_SIZE * 4 )) $CLUSTER_SIZE $CLUSTER_SIZE 1
+    done
+    _check_test_img
 
-    # Empty sectors
-    io_zero readv $(( offset + 1024 * 1024 + 65536 * 4 )) 65536 65536 1
 done
-_check_test_img
 
 # success, all done
 echo "*** done"