111a82d14SPhilippe Mathieu-Daudé#!/usr/bin/env bash 234602dd6SFam Zheng## 334602dd6SFam Zheng## qemu-img compare test (qcow2 only ones) 434602dd6SFam Zheng## 534602dd6SFam Zheng## 634602dd6SFam Zheng## Copyright (C) 2013 Red Hat, Inc. 734602dd6SFam Zheng## 834602dd6SFam Zheng## This program is free software; you can redistribute it and/or modify 934602dd6SFam Zheng## it under the terms of the GNU General Public License as published by 1034602dd6SFam Zheng## the Free Software Foundation; either version 2 of the License, or 1134602dd6SFam Zheng## (at your option) any later version. 1234602dd6SFam Zheng## 1334602dd6SFam Zheng## This program is distributed in the hope that it will be useful, 1434602dd6SFam Zheng## but WITHOUT ANY WARRANTY; without even the implied warranty of 1534602dd6SFam Zheng## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1634602dd6SFam Zheng## GNU General Public License for more details. 1734602dd6SFam Zheng## 1834602dd6SFam Zheng## You should have received a copy of the GNU General Public License 1934602dd6SFam Zheng## along with this program. If not, see <http://www.gnu.org/licenses/>. 2034602dd6SFam Zheng## 2134602dd6SFam Zheng# 2234602dd6SFam Zheng# creator 2334602dd6SFam Zhengowner=famz@redhat.com 2434602dd6SFam Zheng 2534602dd6SFam Zhengseq=`basename $0` 2634602dd6SFam Zhengecho "QA output created by $seq" 2734602dd6SFam Zheng 2834602dd6SFam Zhengstatus=1 # failure is the default! 2934602dd6SFam Zheng 3034602dd6SFam Zheng_cleanup() 3134602dd6SFam Zheng{ 3234602dd6SFam Zheng echo "Cleanup" 3334602dd6SFam Zheng _cleanup_test_img 34f91ecbd7SMax Reitz _rm_test_img "${TEST_IMG2}" 350e596076SKevin Wolf rm -f "$TEST_DIR/blkdebug.conf" 3634602dd6SFam Zheng} 3734602dd6SFam Zhengtrap "_cleanup; exit \$status" 0 1 2 3 15 3834602dd6SFam Zheng 3934602dd6SFam Zheng_compare() 4034602dd6SFam Zheng{ 4134602dd6SFam Zheng $QEMU_IMG compare "$@" "$TEST_IMG" "${TEST_IMG2}" 4234602dd6SFam Zheng echo $? 4334602dd6SFam Zheng} 4434602dd6SFam Zheng 4534602dd6SFam Zheng# get standard environment, filters and checks 4634602dd6SFam Zheng. ./common.rc 4734602dd6SFam Zheng. ./common.filter 4834602dd6SFam Zheng. ./common.pattern 4934602dd6SFam Zheng 5034602dd6SFam Zheng_supported_fmt qcow2 5134602dd6SFam Zheng_supported_proto file 5234602dd6SFam Zheng_supported_os Linux 53*3be2024aSMax Reitz# blkdebug can only inject errors on bs->file 54*3be2024aSMax Reitz_unsupported_imgopts data_file 5534602dd6SFam Zheng 5634602dd6SFam Zheng# Setup test basic parameters 5734602dd6SFam ZhengTEST_IMG2=$TEST_IMG.2 5834602dd6SFam ZhengCLUSTER_SIZE=4096 5934602dd6SFam Zhengsize=1024M 6034602dd6SFam Zheng 6134602dd6SFam Zheng# Test cluster allocated in one, with IO error 6234602dd6SFam Zhengcat > "$TEST_DIR/blkdebug.conf"<<EOF 6334602dd6SFam Zheng[inject-error] 6434602dd6SFam Zhengevent = "read_aio" 6534602dd6SFam Zhengerrno = "5" 6634602dd6SFam Zhengonce ="off" 6734602dd6SFam ZhengEOF 6834602dd6SFam Zheng_make_test_img $size 6934602dd6SFam Zhengcp "$TEST_IMG" "$TEST_IMG2" 7034602dd6SFam Zhengio_pattern write 512 512 0 1 102 7134602dd6SFam ZhengTEST_IMG="blkdebug:$TEST_DIR/blkdebug.conf:$TEST_IMG" _compare 2>&1 |\ 7234602dd6SFam Zheng _filter_testdir | _filter_imgfmt 7334602dd6SFam Zheng 7434602dd6SFam Zheng# Test cluster allocated in one, with different sizes and IO error in the part 7534602dd6SFam Zheng# that exists only in one image 7634602dd6SFam Zhengcat > "$TEST_DIR/blkdebug.conf"<<EOF 7734602dd6SFam Zheng[inject-error] 7834602dd6SFam Zhengevent = "read_aio" 7934602dd6SFam Zhengerrno = "5" 8034602dd6SFam Zhengonce ="off" 8134602dd6SFam ZhengEOF 8234602dd6SFam Zheng_make_test_img $size 8334602dd6SFam ZhengTEST_IMG="$TEST_IMG2" _make_test_img 0 8434602dd6SFam Zhengio_pattern write 512 512 0 1 102 8534602dd6SFam ZhengTEST_IMG="blkdebug:$TEST_DIR/blkdebug.conf:$TEST_IMG" _compare 2>&1 |\ 8634602dd6SFam Zheng _filter_testdir | _filter_imgfmt 8734602dd6SFam Zheng 8834602dd6SFam Zheng# Cleanup 8934602dd6SFam Zhengstatus=0 90