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