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