1908eaf68SStefan 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 44*1f7bf7d0SPeter Lieven_supported_proto file 45ac5e2b20SKevin Wolf_supported_os Linux 46ac5e2b20SKevin Wolf 47ac5e2b20SKevin WolfTEST_OFFSETS="0 4294967296" 48ac5e2b20SKevin WolfTEST_OPS="writev read write readv" 49ac5e2b20SKevin Wolf 50ac5e2b20SKevin Wolf# Can't use 512 byte clusters, the tests use cluster halves 51ac5e2b20SKevin WolfCLUSTER_SIZES="1024 4096 16384 65536" 52ac5e2b20SKevin Wolf 53ac5e2b20SKevin Wolffor CLUSTER_SIZE in $CLUSTER_SIZES; do 54ac5e2b20SKevin Wolf 55ac5e2b20SKevin Wolf echo "Creating new image; cluster size: $CLUSTER_SIZE" 56ac5e2b20SKevin Wolf echo 57ac5e2b20SKevin Wolf 58ac5e2b20SKevin Wolf _make_test_img 8G 59ac5e2b20SKevin Wolf 60ac5e2b20SKevin Wolf echo "Testing empty image" 61ac5e2b20SKevin Wolf echo 62ac5e2b20SKevin Wolf 63ac5e2b20SKevin Wolf for offset in $TEST_OFFSETS; do 64ac5e2b20SKevin Wolf echo "At offset $offset:" 65ac5e2b20SKevin Wolf for op in $TEST_OPS; do 66ac5e2b20SKevin Wolf io_test $op $offset $CLUSTER_SIZE 3 67ac5e2b20SKevin Wolf done 68ac5e2b20SKevin Wolf _check_test_img 69ac5e2b20SKevin Wolf done 70ac5e2b20SKevin Wolf 71ac5e2b20SKevin Wolf echo "Compressing image" 72ac5e2b20SKevin Wolf echo 73ac5e2b20SKevin Wolf 74fef9c191SJeff Cody mv "$TEST_IMG" "$TEST_IMG.orig" 75fef9c191SJeff Cody $QEMU_IMG convert -f $IMGFMT -O $IMGFMT -c "$TEST_IMG.orig" "$TEST_IMG" 76ac5e2b20SKevin Wolf 77ac5e2b20SKevin Wolf echo "Testing compressed image" 78ac5e2b20SKevin Wolf echo 79ac5e2b20SKevin Wolf 80ac5e2b20SKevin Wolf for offset in $TEST_OFFSETS; do 81ac5e2b20SKevin Wolf echo "With offset $offset:" 82ac5e2b20SKevin Wolf for op in read readv; do 83ac5e2b20SKevin Wolf io_test $op $offset $CLUSTER_SIZE 3 84ac5e2b20SKevin Wolf done 85ac5e2b20SKevin Wolf _check_test_img 86ac5e2b20SKevin Wolf done 87ac5e2b20SKevin Wolf 88ac5e2b20SKevin Wolf echo "Testing compressed image with odd offsets" 89ac5e2b20SKevin Wolf echo 90ac5e2b20SKevin Wolf for offset in $TEST_OFFSETS; do 91ac5e2b20SKevin Wolf # Some odd offset (1 sector), so tests will write to areas occupied partly 92ac5e2b20SKevin Wolf # by old (compressed) data and empty clusters 93ac5e2b20SKevin Wolf offset=$((offset + 512)) 94ac5e2b20SKevin Wolf echo "With offset $offset:" 95ac5e2b20SKevin Wolf for op in $TEST_OPS; do 96ac5e2b20SKevin Wolf io_test $op $offset $CLUSTER_SIZE 3 97ac5e2b20SKevin Wolf done 98ac5e2b20SKevin Wolf _check_test_img 99ac5e2b20SKevin Wolf done 100ac5e2b20SKevin Wolf 101ac5e2b20SKevin Wolf echo "Creating another new image" 102ac5e2b20SKevin Wolf echo 103ac5e2b20SKevin Wolf 104ac5e2b20SKevin Wolf _make_test_img 8G 105ac5e2b20SKevin Wolf 106ac5e2b20SKevin Wolf echo "More complex patterns" 107ac5e2b20SKevin Wolf echo 108ac5e2b20SKevin Wolf 109ac5e2b20SKevin Wolf for offset in $TEST_OFFSETS; do 110ac5e2b20SKevin Wolf echo test2: With offset $offset 111ac5e2b20SKevin Wolf io_test2 $offset $CLUSTER_SIZE 4 112ac5e2b20SKevin Wolf _check_test_img 113ac5e2b20SKevin Wolf done 114ac5e2b20SKevin Wolf 115ac5e2b20SKevin Wolfdone 116ac5e2b20SKevin Wolf 117ac5e2b20SKevin Wolf# success, all done 118ac5e2b20SKevin Wolfecho "*** done" 119ac5e2b20SKevin Wolfrm -f $seq.full 120ac5e2b20SKevin Wolfstatus=0 121