1*6bf19c94SChristoph Hellwig#!/bin/sh 2*6bf19c94SChristoph Hellwig# 3*6bf19c94SChristoph Hellwig# qcow2 pattern test, empty and compressed image 4*6bf19c94SChristoph Hellwig# 5*6bf19c94SChristoph Hellwig# Copyright (C) 2009 Red Hat, Inc. 6*6bf19c94SChristoph Hellwig# 7*6bf19c94SChristoph Hellwig# This program is free software; you can redistribute it and/or modify 8*6bf19c94SChristoph Hellwig# it under the terms of the GNU General Public License as published by 9*6bf19c94SChristoph Hellwig# the Free Software Foundation; either version 2 of the License, or 10*6bf19c94SChristoph Hellwig# (at your option) any later version. 11*6bf19c94SChristoph Hellwig# 12*6bf19c94SChristoph Hellwig# This program is distributed in the hope that it will be useful, 13*6bf19c94SChristoph Hellwig# but WITHOUT ANY WARRANTY; without even the implied warranty of 14*6bf19c94SChristoph Hellwig# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15*6bf19c94SChristoph Hellwig# GNU General Public License for more details. 16*6bf19c94SChristoph Hellwig# 17*6bf19c94SChristoph Hellwig# You should have received a copy of the GNU General Public License 18*6bf19c94SChristoph Hellwig# along with this program; if not, write to the Free Software 19*6bf19c94SChristoph Hellwig# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 20*6bf19c94SChristoph Hellwig# USA 21*6bf19c94SChristoph Hellwig# 22*6bf19c94SChristoph Hellwig 23*6bf19c94SChristoph Hellwig# creator 24*6bf19c94SChristoph Hellwigowner=kwolf@redhat.com 25*6bf19c94SChristoph Hellwig 26*6bf19c94SChristoph Hellwigseq=`basename $0` 27*6bf19c94SChristoph Hellwigecho "QA output created by $seq" 28*6bf19c94SChristoph Hellwig 29*6bf19c94SChristoph Hellwighere=`pwd` 30*6bf19c94SChristoph Hellwigtmp=/tmp/$$ 31*6bf19c94SChristoph Hellwigstatus=1 # failure is the default! 32*6bf19c94SChristoph Hellwig 33*6bf19c94SChristoph Hellwig_cleanup() 34*6bf19c94SChristoph Hellwig{ 35*6bf19c94SChristoph Hellwig _cleanup_test_img 36*6bf19c94SChristoph Hellwig} 37*6bf19c94SChristoph Hellwigtrap "_cleanup; exit \$status" 0 1 2 3 15 38*6bf19c94SChristoph Hellwig 39*6bf19c94SChristoph Hellwig# get standard environment, filters and checks 40*6bf19c94SChristoph Hellwig. ./common.rc 41*6bf19c94SChristoph Hellwig. ./common.filter 42*6bf19c94SChristoph Hellwig. ./common.pattern 43*6bf19c94SChristoph Hellwig 44*6bf19c94SChristoph Hellwig# much of this could be generic for any format supporting compression. 45*6bf19c94SChristoph Hellwig_supported_fmt qcow2 46*6bf19c94SChristoph Hellwig_supported_os Linux 47*6bf19c94SChristoph Hellwig 48*6bf19c94SChristoph HellwigTEST_OFFSETS="0 4294967296" 49*6bf19c94SChristoph HellwigTEST_OPS="writev read write readv" 50*6bf19c94SChristoph Hellwig 51*6bf19c94SChristoph Hellwig_make_test_img 6G 52*6bf19c94SChristoph Hellwig 53*6bf19c94SChristoph Hellwigecho "Testing empty image" 54*6bf19c94SChristoph Hellwigecho 55*6bf19c94SChristoph Hellwig 56*6bf19c94SChristoph Hellwigfor offset in $TEST_OFFSETS; do 57*6bf19c94SChristoph Hellwig echo "At offset $offset:" 58*6bf19c94SChristoph Hellwig for op in $TEST_OPS; do 59*6bf19c94SChristoph Hellwig io_test $op $offset 60*6bf19c94SChristoph Hellwig done 61*6bf19c94SChristoph Hellwig _check_test_img 62*6bf19c94SChristoph Hellwigdone 63*6bf19c94SChristoph Hellwig 64*6bf19c94SChristoph Hellwig 65*6bf19c94SChristoph Hellwigecho "Compressing image" 66*6bf19c94SChristoph Hellwigecho 67*6bf19c94SChristoph Hellwig 68*6bf19c94SChristoph Hellwigmv $TEST_IMG $TEST_IMG.orig 69*6bf19c94SChristoph Hellwig$QEMU_IMG convert -f qcow2 -O qcow2 -c $TEST_IMG.orig $TEST_IMG 70*6bf19c94SChristoph Hellwig 71*6bf19c94SChristoph Hellwigecho "Testing compressed image" 72*6bf19c94SChristoph Hellwigecho 73*6bf19c94SChristoph Hellwig 74*6bf19c94SChristoph Hellwigfor offset in $TEST_OFFSETS; do 75*6bf19c94SChristoph Hellwig echo "With offset $offset:" 76*6bf19c94SChristoph Hellwig for op in read readv; do 77*6bf19c94SChristoph Hellwig io_test $op $offset 78*6bf19c94SChristoph Hellwig done 79*6bf19c94SChristoph Hellwig _check_test_img 80*6bf19c94SChristoph Hellwigdone 81*6bf19c94SChristoph Hellwig 82*6bf19c94SChristoph Hellwigecho "Testing compressed image with odd offsets" 83*6bf19c94SChristoph Hellwigecho 84*6bf19c94SChristoph Hellwigfor offset in $TEST_OFFSETS; do 85*6bf19c94SChristoph Hellwig # Some odd offset (1 sector), so tests will write to areas occupied partly 86*6bf19c94SChristoph Hellwig # by old (compressed) data and empty clusters 87*6bf19c94SChristoph Hellwig offset=$((offset + 512)) 88*6bf19c94SChristoph Hellwig echo "With offset $offset:" 89*6bf19c94SChristoph Hellwig for op in $TEST_OPS; do 90*6bf19c94SChristoph Hellwig io_test $op $offset 91*6bf19c94SChristoph Hellwig done 92*6bf19c94SChristoph Hellwig _check_test_img 93*6bf19c94SChristoph Hellwigdone 94*6bf19c94SChristoph Hellwig 95*6bf19c94SChristoph Hellwig# success, all done 96*6bf19c94SChristoph Hellwigecho "*** done" 97*6bf19c94SChristoph Hellwigrm -f $seq.full 98*6bf19c94SChristoph Hellwigstatus=0 99