xref: /openbmc/qemu/tests/qemu-iotests/013 (revision fef9c191)
1908eaf68SStefan Hajnoczi#!/bin/bash
26bf19c94SChristoph Hellwig#
38fc1024cSKevin Wolf# qcow2 pattern test, empty and compressed image - 4k cluster patterns
46bf19c94SChristoph Hellwig#
56bf19c94SChristoph Hellwig# Copyright (C) 2009 Red Hat, Inc.
66bf19c94SChristoph Hellwig#
76bf19c94SChristoph Hellwig# This program is free software; you can redistribute it and/or modify
86bf19c94SChristoph Hellwig# it under the terms of the GNU General Public License as published by
96bf19c94SChristoph Hellwig# the Free Software Foundation; either version 2 of the License, or
106bf19c94SChristoph Hellwig# (at your option) any later version.
116bf19c94SChristoph Hellwig#
126bf19c94SChristoph Hellwig# This program is distributed in the hope that it will be useful,
136bf19c94SChristoph Hellwig# but WITHOUT ANY WARRANTY; without even the implied warranty of
146bf19c94SChristoph Hellwig# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
156bf19c94SChristoph Hellwig# GNU General Public License for more details.
166bf19c94SChristoph Hellwig#
176bf19c94SChristoph Hellwig# You should have received a copy of the GNU General Public License
18e8c212d6SChristoph Hellwig# along with this program.  If not, see <http://www.gnu.org/licenses/>.
196bf19c94SChristoph Hellwig#
206bf19c94SChristoph Hellwig
216bf19c94SChristoph Hellwig# creator
226bf19c94SChristoph Hellwigowner=kwolf@redhat.com
236bf19c94SChristoph Hellwig
246bf19c94SChristoph Hellwigseq=`basename $0`
256bf19c94SChristoph Hellwigecho "QA output created by $seq"
266bf19c94SChristoph Hellwig
276bf19c94SChristoph Hellwighere=`pwd`
286bf19c94SChristoph Hellwigtmp=/tmp/$$
296bf19c94SChristoph Hellwigstatus=1	# failure is the default!
306bf19c94SChristoph Hellwig
316bf19c94SChristoph Hellwig_cleanup()
326bf19c94SChristoph Hellwig{
336bf19c94SChristoph Hellwig	_cleanup_test_img
346bf19c94SChristoph Hellwig}
356bf19c94SChristoph Hellwigtrap "_cleanup; exit \$status" 0 1 2 3 15
366bf19c94SChristoph Hellwig
376bf19c94SChristoph Hellwig# get standard environment, filters and checks
386bf19c94SChristoph Hellwig. ./common.rc
396bf19c94SChristoph Hellwig. ./common.filter
406bf19c94SChristoph Hellwig. ./common.pattern
416bf19c94SChristoph Hellwig
426bf19c94SChristoph Hellwig# much of this could be generic for any format supporting compression.
43e76a8e89SChristoph Hellwig_supported_fmt qcow qcow2
449cdfa1b3SMORITA Kazutaka_supported_proto generic
456bf19c94SChristoph Hellwig_supported_os Linux
466bf19c94SChristoph Hellwig
476bf19c94SChristoph HellwigTEST_OFFSETS="0 4294967296"
486bf19c94SChristoph HellwigTEST_OPS="writev read write readv"
498fc1024cSKevin WolfCLUSTER_SIZE=4096
506bf19c94SChristoph Hellwig
516bf19c94SChristoph Hellwig_make_test_img 6G
526bf19c94SChristoph Hellwig
536bf19c94SChristoph Hellwigecho "Testing empty image"
546bf19c94SChristoph Hellwigecho
556bf19c94SChristoph Hellwig
566bf19c94SChristoph Hellwigfor offset in $TEST_OFFSETS; do
576bf19c94SChristoph Hellwig    echo "At offset $offset:"
586bf19c94SChristoph Hellwig    for op in $TEST_OPS; do
598fc1024cSKevin Wolf        io_test $op $offset $CLUSTER_SIZE 8
606bf19c94SChristoph Hellwig    done
616bf19c94SChristoph Hellwig    _check_test_img
626bf19c94SChristoph Hellwigdone
636bf19c94SChristoph Hellwig
646bf19c94SChristoph Hellwig
656bf19c94SChristoph Hellwigecho "Compressing image"
666bf19c94SChristoph Hellwigecho
676bf19c94SChristoph Hellwig
68*fef9c191SJeff Codymv "$TEST_IMG" "$TEST_IMG.orig"
69*fef9c191SJeff Cody$QEMU_IMG convert -f $IMGFMT -O $IMGFMT -c "$TEST_IMG.orig" "$TEST_IMG"
706bf19c94SChristoph Hellwig
716bf19c94SChristoph Hellwigecho "Testing compressed image"
726bf19c94SChristoph Hellwigecho
736bf19c94SChristoph Hellwig
746bf19c94SChristoph Hellwigfor offset in $TEST_OFFSETS; do
756bf19c94SChristoph Hellwig    echo "With offset $offset:"
766bf19c94SChristoph Hellwig    for op in read readv; do
778fc1024cSKevin Wolf        io_test $op $offset $CLUSTER_SIZE 8
786bf19c94SChristoph Hellwig    done
796bf19c94SChristoph Hellwig    _check_test_img
806bf19c94SChristoph Hellwigdone
816bf19c94SChristoph Hellwig
826bf19c94SChristoph Hellwigecho "Testing compressed image with odd offsets"
836bf19c94SChristoph Hellwigecho
846bf19c94SChristoph Hellwigfor offset in $TEST_OFFSETS; do
856bf19c94SChristoph Hellwig    # Some odd offset (1 sector), so tests will write to areas occupied partly
866bf19c94SChristoph Hellwig    # by old (compressed) data and empty clusters
876bf19c94SChristoph Hellwig    offset=$((offset + 512))
886bf19c94SChristoph Hellwig    echo "With offset $offset:"
896bf19c94SChristoph Hellwig    for op in $TEST_OPS; do
908fc1024cSKevin Wolf        io_test $op $offset $CLUSTER_SIZE 8
916bf19c94SChristoph Hellwig    done
926bf19c94SChristoph Hellwig    _check_test_img
936bf19c94SChristoph Hellwigdone
946bf19c94SChristoph Hellwig
956bf19c94SChristoph Hellwig# success, all done
966bf19c94SChristoph Hellwigecho "*** done"
976bf19c94SChristoph Hellwigrm -f $seq.full
986bf19c94SChristoph Hellwigstatus=0
99