blob: d39d0cd88b6516f8514a1bf0e146f08c0fd72317 [file] [log] [blame]
Philippe Mathieu-Daudé11a82d12019-03-07 15:58:38 +01001#!/usr/bin/env bash
Vladimir Sementsov-Ogievskiy9dd003a2021-01-16 16:44:19 +03002# group: rw auto
Christoph Hellwig6bf19c92009-06-22 18:29:05 +02003#
Kevin Wolf8fc10242009-10-01 14:29:59 -03004# qcow2 pattern test, empty and compressed image - 4k cluster patterns
Christoph Hellwig6bf19c92009-06-22 18:29:05 +02005#
6# Copyright (C) 2009 Red Hat, Inc.
7#
8# This program is free software; you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation; either version 2 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
Christoph Hellwige8c212d2009-07-16 19:26:54 +020019# along with this program. If not, see <http://www.gnu.org/licenses/>.
Christoph Hellwig6bf19c92009-06-22 18:29:05 +020020#
21
22# creator
23owner=kwolf@redhat.com
24
25seq=`basename $0`
26echo "QA output created by $seq"
27
Christoph Hellwig6bf19c92009-06-22 18:29:05 +020028status=1 # failure is the default!
29
30_cleanup()
31{
32 _cleanup_test_img
33}
34trap "_cleanup; exit \$status" 0 1 2 3 15
35
36# get standard environment, filters and checks
37. ./common.rc
38. ./common.filter
39. ./common.pattern
40
41# much of this could be generic for any format supporting compression.
Christoph Hellwige76a8e82009-07-09 15:26:11 +020042_supported_fmt qcow qcow2
Peter Lieven1f7bf7d2014-02-03 10:26:14 +010043_supported_proto file
Christoph Hellwig6bf19c92009-06-22 18:29:05 +020044_supported_os Linux
45
46TEST_OFFSETS="0 4294967296"
47TEST_OPS="writev read write readv"
Kevin Wolf8fc10242009-10-01 14:29:59 -030048CLUSTER_SIZE=4096
Christoph Hellwig6bf19c92009-06-22 18:29:05 +020049
50_make_test_img 6G
51
52echo "Testing empty image"
53echo
54
55for offset in $TEST_OFFSETS; do
56 echo "At offset $offset:"
57 for op in $TEST_OPS; do
Kevin Wolf8fc10242009-10-01 14:29:59 -030058 io_test $op $offset $CLUSTER_SIZE 8
Christoph Hellwig6bf19c92009-06-22 18:29:05 +020059 done
60 _check_test_img
61done
62
63
64echo "Compressing image"
65echo
66
Jeff Codyfef9c192013-09-25 08:12:22 -040067mv "$TEST_IMG" "$TEST_IMG.orig"
68$QEMU_IMG convert -f $IMGFMT -O $IMGFMT -c "$TEST_IMG.orig" "$TEST_IMG"
Christoph Hellwig6bf19c92009-06-22 18:29:05 +020069
70echo "Testing compressed image"
71echo
72
73for offset in $TEST_OFFSETS; do
74 echo "With offset $offset:"
75 for op in read readv; do
Kevin Wolf8fc10242009-10-01 14:29:59 -030076 io_test $op $offset $CLUSTER_SIZE 8
Christoph Hellwig6bf19c92009-06-22 18:29:05 +020077 done
78 _check_test_img
79done
80
81echo "Testing compressed image with odd offsets"
82echo
83for offset in $TEST_OFFSETS; do
84 # Some odd offset (1 sector), so tests will write to areas occupied partly
85 # by old (compressed) data and empty clusters
86 offset=$((offset + 512))
87 echo "With offset $offset:"
88 for op in $TEST_OPS; do
Kevin Wolf8fc10242009-10-01 14:29:59 -030089 io_test $op $offset $CLUSTER_SIZE 8
Christoph Hellwig6bf19c92009-06-22 18:29:05 +020090 done
91 _check_test_img
92done
93
94# success, all done
95echo "*** done"
96rm -f $seq.full
97status=0