1*ac5e2b20SKevin Wolf#!/bin/sh 2*ac5e2b20SKevin Wolf# 3*ac5e2b20SKevin Wolf# qcow2 pattern test with various cluster sizes 4*ac5e2b20SKevin Wolf# 5*ac5e2b20SKevin Wolf# Copyright (C) 2009 Red Hat, Inc. 6*ac5e2b20SKevin Wolf# 7*ac5e2b20SKevin Wolf# This program is free software; you can redistribute it and/or modify 8*ac5e2b20SKevin Wolf# it under the terms of the GNU General Public License as published by 9*ac5e2b20SKevin Wolf# the Free Software Foundation; either version 2 of the License, or 10*ac5e2b20SKevin Wolf# (at your option) any later version. 11*ac5e2b20SKevin Wolf# 12*ac5e2b20SKevin Wolf# This program is distributed in the hope that it will be useful, 13*ac5e2b20SKevin Wolf# but WITHOUT ANY WARRANTY; without even the implied warranty of 14*ac5e2b20SKevin Wolf# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15*ac5e2b20SKevin Wolf# GNU General Public License for more details. 16*ac5e2b20SKevin Wolf# 17*ac5e2b20SKevin Wolf# You should have received a copy of the GNU General Public License 18*ac5e2b20SKevin Wolf# along with this program. If not, see <http://www.gnu.org/licenses/>. 19*ac5e2b20SKevin Wolf# 20*ac5e2b20SKevin Wolf 21*ac5e2b20SKevin Wolf# creator 22*ac5e2b20SKevin Wolfowner=kwolf@redhat.com 23*ac5e2b20SKevin Wolf 24*ac5e2b20SKevin Wolfseq=`basename $0` 25*ac5e2b20SKevin Wolfecho "QA output created by $seq" 26*ac5e2b20SKevin Wolf 27*ac5e2b20SKevin Wolfhere=`pwd` 28*ac5e2b20SKevin Wolftmp=/tmp/$$ 29*ac5e2b20SKevin Wolfstatus=1 # failure is the default! 30*ac5e2b20SKevin Wolf 31*ac5e2b20SKevin Wolf_cleanup() 32*ac5e2b20SKevin Wolf{ 33*ac5e2b20SKevin Wolf _cleanup_test_img 34*ac5e2b20SKevin Wolf} 35*ac5e2b20SKevin Wolftrap "_cleanup; exit \$status" 0 1 2 3 15 36*ac5e2b20SKevin Wolf 37*ac5e2b20SKevin Wolf# get standard environment, filters and checks 38*ac5e2b20SKevin Wolf. ./common.rc 39*ac5e2b20SKevin Wolf. ./common.filter 40*ac5e2b20SKevin Wolf. ./common.pattern 41*ac5e2b20SKevin Wolf 42*ac5e2b20SKevin Wolf# much of this could be generic for any format supporting compression. 43*ac5e2b20SKevin Wolf_supported_fmt qcow qcow2 44*ac5e2b20SKevin Wolf_supported_os Linux 45*ac5e2b20SKevin Wolf 46*ac5e2b20SKevin WolfTEST_OFFSETS="0 4294967296" 47*ac5e2b20SKevin WolfTEST_OPS="writev read write readv" 48*ac5e2b20SKevin Wolf 49*ac5e2b20SKevin Wolf# Can't use 512 byte clusters, the tests use cluster halves 50*ac5e2b20SKevin WolfCLUSTER_SIZES="1024 4096 16384 65536" 51*ac5e2b20SKevin Wolf 52*ac5e2b20SKevin Wolffor CLUSTER_SIZE in $CLUSTER_SIZES; do 53*ac5e2b20SKevin Wolf 54*ac5e2b20SKevin Wolf echo "Creating new image; cluster size: $CLUSTER_SIZE" 55*ac5e2b20SKevin Wolf echo 56*ac5e2b20SKevin Wolf 57*ac5e2b20SKevin Wolf _make_test_img 8G 58*ac5e2b20SKevin Wolf 59*ac5e2b20SKevin Wolf echo "Testing empty image" 60*ac5e2b20SKevin Wolf echo 61*ac5e2b20SKevin Wolf 62*ac5e2b20SKevin Wolf for offset in $TEST_OFFSETS; do 63*ac5e2b20SKevin Wolf echo "At offset $offset:" 64*ac5e2b20SKevin Wolf for op in $TEST_OPS; do 65*ac5e2b20SKevin Wolf io_test $op $offset $CLUSTER_SIZE 3 66*ac5e2b20SKevin Wolf done 67*ac5e2b20SKevin Wolf _check_test_img 68*ac5e2b20SKevin Wolf done 69*ac5e2b20SKevin Wolf 70*ac5e2b20SKevin Wolf echo "Compressing image" 71*ac5e2b20SKevin Wolf echo 72*ac5e2b20SKevin Wolf 73*ac5e2b20SKevin Wolf mv $TEST_IMG $TEST_IMG.orig 74*ac5e2b20SKevin Wolf $QEMU_IMG convert -f $IMGFMT -O $IMGFMT -c $TEST_IMG.orig $TEST_IMG 75*ac5e2b20SKevin Wolf 76*ac5e2b20SKevin Wolf echo "Testing compressed image" 77*ac5e2b20SKevin Wolf echo 78*ac5e2b20SKevin Wolf 79*ac5e2b20SKevin Wolf for offset in $TEST_OFFSETS; do 80*ac5e2b20SKevin Wolf echo "With offset $offset:" 81*ac5e2b20SKevin Wolf for op in read readv; do 82*ac5e2b20SKevin Wolf io_test $op $offset $CLUSTER_SIZE 3 83*ac5e2b20SKevin Wolf done 84*ac5e2b20SKevin Wolf _check_test_img 85*ac5e2b20SKevin Wolf done 86*ac5e2b20SKevin Wolf 87*ac5e2b20SKevin Wolf echo "Testing compressed image with odd offsets" 88*ac5e2b20SKevin Wolf echo 89*ac5e2b20SKevin Wolf for offset in $TEST_OFFSETS; do 90*ac5e2b20SKevin Wolf # Some odd offset (1 sector), so tests will write to areas occupied partly 91*ac5e2b20SKevin Wolf # by old (compressed) data and empty clusters 92*ac5e2b20SKevin Wolf offset=$((offset + 512)) 93*ac5e2b20SKevin Wolf echo "With offset $offset:" 94*ac5e2b20SKevin Wolf for op in $TEST_OPS; do 95*ac5e2b20SKevin Wolf io_test $op $offset $CLUSTER_SIZE 3 96*ac5e2b20SKevin Wolf done 97*ac5e2b20SKevin Wolf _check_test_img 98*ac5e2b20SKevin Wolf done 99*ac5e2b20SKevin Wolf 100*ac5e2b20SKevin Wolf echo "Creating another new image" 101*ac5e2b20SKevin Wolf echo 102*ac5e2b20SKevin Wolf 103*ac5e2b20SKevin Wolf _make_test_img 8G 104*ac5e2b20SKevin Wolf 105*ac5e2b20SKevin Wolf echo "More complex patterns" 106*ac5e2b20SKevin Wolf echo 107*ac5e2b20SKevin Wolf 108*ac5e2b20SKevin Wolf for offset in $TEST_OFFSETS; do 109*ac5e2b20SKevin Wolf echo test2: With offset $offset 110*ac5e2b20SKevin Wolf io_test2 $offset $CLUSTER_SIZE 4 111*ac5e2b20SKevin Wolf _check_test_img 112*ac5e2b20SKevin Wolf done 113*ac5e2b20SKevin Wolf 114*ac5e2b20SKevin Wolfdone 115*ac5e2b20SKevin Wolf 116*ac5e2b20SKevin Wolf# success, all done 117*ac5e2b20SKevin Wolfecho "*** done" 118*ac5e2b20SKevin Wolfrm -f $seq.full 119*ac5e2b20SKevin Wolfstatus=0 120